Renamed sampled-piano to piano.

Renamed sampled-piano to piano.

--- src/overtunes/songs/row_row_row_your_boat.clj
+++ src/overtunes/songs/row_row_row_your_boat.clj
@@ -1,7 +1,7 @@
 (ns overtunes.songs.row-row-row-your-boat
   (:use
     [overtone.live :only [at now]]
-    [overtone.inst.sampled-piano :only [sampled-piano]]))
+    [overtone.inst.sampled-piano :only [sampled-piano] :rename {sampled-piano piano}]))

 (defn sum-n [series n] (reduce + (take n series)))
 (def major-scale (partial sum-n (cycle [2 2 1 2 2 2 1])))
@@ -16,7 +16,7 @@
 (def durations [1 1 2/3 1/3 1, 2/3 1/3 2/3 1/3 2, 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3, 2/3 1/3 2/3 1/3 2])

 (defn melody# [timing notes]
-  (let [note# #(at (timing %1) (sampled-piano (g-major %2)))]
+  (let [note# #(at (timing %1) (piano (g-major %2)))]
     (dorun (map-indexed note# notes))))

 (defn play# []


(MAINT) Fix formatting

(MAINT) Fix formatting

--- test/integration/puppetlabs/puppetserver/bootstrap_int_test.clj
+++ test/integration/puppetlabs/puppetserver/bootstrap_int_test.clj
@@ -15,9 +15,9 @@
       (let [pk-dir (str bootstrap/master-conf-dir "/ssl/private_keys")
             pks (fs/find-files pk-dir #".*pem$")]
         (is (= ca/private-key-dir-perms (ca/get-file-perms pk-dir)))
-        (is (= ca/private-key-perms (ca/get-file-perms
-                               (str bootstrap/master-conf-dir
-                                    "/ssl/ca/ca_key.pem"))))
+        (is (= ca/private-key-perms
+               (ca/get-file-perms (str bootstrap/master-conf-dir
+                                       "/ssl/ca/ca_key.pem"))))
         (doseq [pk pks]
           (is (= ca/private-key-perms (ca/get-file-perms (.getPath pk)))))))
     (is (true? true)))))


Fixing alive/is-dead

Fixing alive/is-dead

--- src/civs/model/core.clj
+++ src/civs/model/core.clj
@@ -16,10 +16,10 @@
 (defrecord Population [children young-men young-women old-men old-women])

 (defn total-persons [pop]
-  (+ (:children pop) (:young-men pop) (:young-women pop) (:old-men pop) (:old-women pop)))
+  (int (+ (:children pop) (:young-men pop) (:young-women pop) (:old-men pop) (:old-women pop))))

 (defn active-persons [pop]
-  (+ (:young-men pop) (:young-women pop)))
+  (int (+ (:young-men pop) (:young-women pop))))

 ; ###########################################################
 ;  Culture


Remove migration function. It doesn't work :(. Anyway I already migrated manually.

--- src/clj/nonojure/db.clj
+++ src/clj/nonojure/db.clj
@@ -126,14 +126,6 @@
   (mc/upsert pref-coll {:_id email} (assoc preferences
                                       :_id email)))

-(defn migrate-ids-to-numbers []
-  (doseq [nono (mc/find-maps nono-coll)]
-    (let [old-id (:_id nono)
-          new-id (get-next-sequence nono-coll)]
-      (mc/insert nono-coll (assoc nono :_id new-id))
-      (mc/remove nono-coll {:_id old-id})
-      (mc/update progress-coll {:puzzle old-id} {$set {:puzzle new-id}}))))
-
 #_(

    (migrate-ids-to-numbers)


don't need the #

don't need the #

--- src/clj_http/client.clj
+++ src/clj_http/client.clj
@@ -481,8 +481,8 @@
       wrap-links
       wrap-unknown-host))

-(def #^{:doc
-        "Executes the HTTP request corresponding to the given map and returns
+(def ^{:doc
+       "Executes the HTTP request corresponding to the given map and returns
    the response map for corresponding to the resulting HTTP response.

    In addition to the standard Ring request keys, the following keys are also


switch to com.unboundid.util.Base64

switch to com.unboundid.util.Base64

--- src/clj_ldap/client.clj
+++ src/clj_ldap/client.clj
@@ -29,6 +29,8 @@
             PostReadRequestControl
             PreReadResponseControl
             PostReadResponseControl])
+  (:import [com.unboundid.util
+            Base64])
   (:import [com.unboundid.util.ssl
             SSLUtil
             TrustAllTrustManager
@@ -38,7 +40,7 @@

 (defn encode [attr]
   (if (.needsBase64Encoding attr)
-    (.encode (sun.misc.BASE64Encoder.) (.getValueByteArray attr))
+    (Base64/encode (.getValueByteArray attr))
     (.getValue attr)))

 (defn- extract-attribute


moved sequence functions to just after prototypes. changed check from (when x) to (when-not (nil? x)). copied docstrings from clojure/core.clj.

--- src/cljs/cljs/core.cljs
+++ src/cljs/cljs/core.cljs
@@ -189,6 +189,98 @@
     (if (next s)
       (recur (conj ret (first s)) (next s))
       (seq ret))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; sequence fns ;;;;;;;;;;;;;;
+
+(defn count
+  "Returns the number of items in the collection. (count nil) returns
+  0.  Also works on strings, arrays, and Maps"
+  [coll]
+  (if coll
+    (if (satisfies? ICounted coll)
+      (-count coll)
+      (loop [s (seq coll) n 0]
+	(if (first s)
+	  (recur (rest s) (inc n))
+	  n)))
+    0))
+
+(defn nth
+  "Returns the value at the index. get returns nil if index out of
+  bounds, nth throws an exception unless not-found is supplied.  nth
+  also works for strings, arrays, regex Matchers and Lists, and,
+  in O(n) time, for sequences."
+  ([coll n]
+     (when-not (nil? coll)
+       (-nth coll n)))
+  ([coll n not-found]
+     (when-not (nil? coll)
+       (-nth coll n not-found))))
+
+(defn get
+  "Returns the value mapped to key, not-found or nil if key not present."
+  ([o k]
+     (when-not (nil? o)
+       (-lookup o k)))
+  ([o k not-found]
+     (when-not (nil? o)
+       (-lookup o k not-found))))
+
+(defn assoc
+  "assoc[iate]. When applied to a map, returns a new map of the
+   same (hashed/sorted) type, that contains the mapping of key(s) to
+   val(s). When applied to a vector, returns a new vector that
+   contains val at index. Note - index must be <= (count vector)."
+  [coll k v]
+  (when-not (nil? coll)
+    (-assoc coll k v)))
+
+(defn dissoc
+  "dissoc[iate]. Returns a new map of the same (hashed/sorted) type,
+  that does not contain a mapping for key(s)."
+  [coll k]
+  (when-not (nil? coll)
+    (-dissoc coll k)))
+
+(defn with-meta
+  "Returns an object of the same type and value as obj, with
+  map m as its metadata."
+  [o meta]
+  (when-not (nil? o) (-with-meta o meta)))
+
+(defn meta
+  "Returns the metadata of obj, returns nil if there is no metadata."
+  [o]
+  (when-not (nil? o) (-meta o)))
+
+(defn peek
+  "For a list or queue, same as first, for a vector, same as, but much
+  more efficient than, last. If the collection is empty, returns nil."
+  [coll]
+  (when-not (nil? coll) (-peek coll)))
+
+(defn pop
+  "For a list or queue, returns a new list/queue without the first
+  item, for a vector, returns a new vector without the last item. If
+  the collection is empty, throws an exception.  Note - not the same
+  as next/butlast."
+  [coll]
+  (when-not (nil? coll) (-pop coll)))
+
+(defn contains?
+  "Returns true if key is present in the given collection, otherwise
+  returns false.  Note that for numerically indexed collections like
+  vectors and arrays, this tests if the numeric key is within the
+  range of indexes. 'contains?' operates constant or logarithmic time;
+  it will not perform a linear search for a value.  See also 'some'."
+  [coll v]
+  (when-not (nil? coll) (-contains? coll v)))
+
+(defn disj
+  "disj[oin]. Returns a new set of the same (hashed/sorted) type, that
+  does not contain key(s)."
+  [coll v]
+  (when-not (nil? coll) (-disjoin coll v)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; arrays ;;;;;;;;;;;;;;;;

@@ -789,66 +881,3 @@
                    s)))]
     (lazy-seq (step n coll))))

-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; sequence fns ;;;;;;;;;;;;;;
-
-(defn count
-  [coll]
-  (if coll
-    (if (satisfies? ICounted coll)
-      (-count coll)
-      (loop [s (seq coll) n 0]
-	(if (first s)
-	  (recur (rest s) (inc n))
-	  n)
-	#_(count (seq coll))))
-    0))
-
-(defn nth
-  ([coll n]
-     (when coll
-       (-nth coll n)))
-  ([coll n not-found]
-     (when coll
-       (-nth coll n not-found))))
-
-(defn get
-  ([o k]
-     (when o
-       (-lookup o k)))
-  ([o k not-found]
-     (when o
-       (-lookup o k not-found))))
-
-(defn assoc
-  [coll k v]
-  (when coll
-    (-assoc coll k v)))
-
-(defn dissoc
-  [coll k]
-  (when coll
-    (-dissoc coll k)))
-
-(defn with-meta
-  [o meta]
-  (when o (-with-meta o meta)))
-
-(defn meta
-  [o]
-  (when o (-meta o)))
-
-(defn peek
-  [coll]
-  (when coll (-peek coll)))
-
-(defn pop
-  [coll]
-  (when coll (-pop coll)))
-
-(defn contains?
-  [coll v]
-  (when coll (-contains? coll v)))
-
-(defn disj
-  [coll v]
-  (when coll (-disjoin coll v)))


Add refactor-nrepl to plugins

Add refactor-nrepl to plugins

--- roles/clojure/files/profiles.clj
+++ roles/clojure/files/profiles.clj
@@ -19,7 +19,8 @@
                   [lein-marginalia "0.7.1"]
                   [lein-pprint "1.1.1"]
                   [lein-swank "1.4.4"]
-                  [lein-try "0.4.3"]]
+                  [lein-try "0.4.3"]
+                  [refactor-nrepl "0.2.2"]]

         :injections [(require
                       '[alembic.still :refer [distill]]


rest of Defining Functions

rest of Defining Functions

--- src/mark-volkmann-tutorial/defining-functions.clj
+++ src/mark-volkmann-tutorial/defining-functions.clj
@@ -43,8 +43,108 @@

 ; anonymous fun - short, in one place higher-order function arguments
 (def years [1940 1944 1961 1985 1987])
-(filter (fn [year] (even? year)) years)
-(filter #(even? %) years)
+(filter (fn [year] (even? year)) years)   ; fn body can contain many forms
+(filter #(even? %) years)                 ; #() can contain only one form, or use #(do ...), % - argument
+                                          ; %1, %2, ... more
 ;; my experiments
 (filter (partial even?) years)
-(filter even? years)+(filter even? years)
+
+(defn pair-test [test-fn n1 n2]
+  (if (test-fn n1 n2) "pass" "fail"))
+
+; Use a test-fn that determines wheter
+; the sum of its two arguments is an even number.
+(pair-test #(even? (+ %1 %2)) 3 5)
+
+
+; overload based on type in Java, based on arity in Clojure
+; but defmulti & defmethod can do this
+; :default disptach
+(defmulti what-am-i class) ; class is the disptach function
+; (defmethod method-name dispatch-value [args-list] body)
+(defmethod what-am-i Number [arg] (println arg "is a Number"))
+(defmethod what-am-i String [arg] (println arg "is a String"))
+(defmethod what-am-i :default [arg] (println arg "is something else"))
+(what-am-i 19)
+(what-am-i "Hello")
+(what-am-i true)
+; custom dispatch function
+
+; _ (underscore) as placeholder, ommited value - destructing
+(defn callback1 [a b c] (+ a b c))
+(defn callback2 [a _ c] (+ a c))
+(defn caller [callback value]
+  (callback (+ value 1) (+ value 2) (+ value 3)))
+(caller callback1 10)
+(caller callback2 10)
+
+; complement - returns fun oposite to given
+(defn teenager? [age] (and (>= age 13) (< age 20)))
+; (defn not-teen? (complement teenager?)) ; java.lang.IllegalArgumentException: Parameter declaration "complement" should be a vector
+(def not-teen? (complement teenager?))
+(not-teen? 47)
+
+; comp - combine functions, call order - from right to left
+(defn times2 [n] (* n 2))
+(defn minus3 [n] (- n 3))
+; Note the use of def instead of defn because comp returns
+; a function that is then bound to "my-composition".
+(def my-composition (comp minus3 times2))
+(my-composition 4)
+
+; partial - curring (partial aplication) -> returns functions so alse use def instead of defn
+(def times2 (partial * 2))
+(times2 3 4)
+
+; use of map & partial
+; defn- : not public https://clojuredocs.org/clojure.core/defn-
+(defn- polymonial
+  "computes the value of a polymonial
+  with the given coefficients for a given value x"
+  [coefs x]
+  ; For example, if coefs contains 3 values then exponents is (2 1 0).
+  (let [exponents (reverse (range (count coefs)))]
+    ; Multiply each coefficient by x raised to the corresponding exponent
+    ; and sum those results.
+    ; coefs go into %1 and exponents go into %2.
+    (apply + (map #(* %1 (Math/pow x %2)) coefs exponents))))
+
+(defn- derivative
+  "computes the value of the derivative of a polynomial
+   with the given coefficients for a given value x"
+  [coefs x]
+  ; The coefficients of the derivative of a polymonial
+  ; multiplying all but the last coefficient by its corresponding exponent.
+  ; The extra exponent will be ignored.
+  (let [exponents (reverse (range (count coefs)))
+        derivative-coefs (map #(* %1 %2) (butlast coefs) exponents)]
+    (polymonial derivative-coefs x)))
+
+(def f (partial polymonial [2 1 3])) ; 2x^2 + x + 3
+(def f-prime (partial derivative [2 1 3])) ; 4x + 1
+
+(defn- polymonial
+  "computes the value of a polymonial
+  with the given coefficients for a given value x"
+  [coefs x]
+  (reduce #(+ (* x %1) %2) coefs))
+
+(println "f(2) =" (f 2))
+(println "f'(2) =" (f-prime 2))
+
+; memoize - function memoization (caching) - better performance, but requires memory
+; time - eval expr & return print elapsed time for its
+(def memo-f (memoize f))
+
+(println "printing call")
+(time (f 2))
+
+(println "without memoization")
+; Note use of an underscore for the binding thath isn't used.
+(dotimes [_ 3] (time (f 2)))
+
+(println "with memoization")
+(dotimes [_ 3] (time (memo-f 2)))
+
+


Fix bug in available specializations

Fix bug in available specializations

--- src/kmg/domain.clj
+++ src/kmg/domain.clj
@@ -184,7 +184,10 @@
 (defn available-specialization-ids
   [db user]
   (let [completed  (completed-specialization-ids db user)]
-    (flatten (map #(children-specialization-ids db %) completed))))
+    (->> (map #(children-specialization-ids db %) completed)
+         flatten
+         (remove completed))))
+
 ;; (available-specialization-ids (db) "user1")
 ;; (get-spec-id (db) "spec2")


Zap obsolete tests.

Zap obsolete tests.

--- test/cljx/active/clojure/lens_test.cljx
+++ test/cljx/active/clojure/lens_test.cljx
@@ -228,13 +228,6 @@
   (is (= {:foo 'baz :bar 'bar}
          (lens/shove {:foo 'foo :bar 'bar} :foo 'baz))))

-(deftest path
-  (let [l (lens/in :foo :baz)]
-    (is (= 'baz
-           (lens/yank {:foo {:bla 'bla :baz 'baz} :bar 'bar} l)))
-    (is (= {:foo {:bla 'bla :baz 'bam} :bar 'bar}
-           (lens/shove {:foo {:bla 'bla :baz 'baz} :bar 'bar} l 'bam)))))
-
 (deftest at-index
   (let [l (lens/at-index 2)]
     (is (= 'baz
@@ -248,21 +241,4 @@
       (= 'bar
          (lens/shove 'baz lens/id 'bar))))

-(deftest at-key
-  (is (= {:k 'bar :v 'baz}
-         (lens/yank [{:k 'foo :v 'bar} {:k 'bar :v 'baz} {:k 'bla :v 'bam}]
-                    (lens/at-key :k 'bar))))
-  (is (= [{:k 'foo :v 'bar} {:k 'bar :v 'blam} {:k 'bla :v 'bam}]
-         (lens/shove [{:k 'foo :v 'bar} {:k 'bar :v 'baz} {:k 'bla :v 'bam}]
-                     (lens/at-key :k 'bar)
-                     {:k 'bar :v 'blam}))))
-
-(deftest map-keyed
-  (let [d [{:k 'foo :v 'bar} {:k 'bar :v 'baz} {:k 'bla :v 'bam}]]
-    (is (= [[{:k 'foo :v 'bar} 'foo 'foo]
-            [{:k 'bar :v 'baz} 'bar 'bar]
-            [{:k 'bla :v 'bam} 'bla 'bla]]
-           (lens/map-keyed :k
-                           (fn [el key lens]
-                             [el key (:k (lens/yank d lens))])
-                           d)))))
+


releasing v0.5.0

releasing v0.5.0

--- core/project.clj
+++ core/project.clj
@@ -1,4 +1,4 @@
-(defproject samsara/samsara-core "0.5.0-SNAPSHOT"
+(defproject samsara/samsara-core "0.5.0"
   :description "Event stream processing pipeline"

   :url "https://samsara.github.com/"


Use a flash message to notify the user that the repair has been initiated

--- src/mdr2/views.clj
+++ src/mdr2/views.clj
@@ -282,10 +282,8 @@
   [id]
   (let [production (prod/find id)]
     (repair/repair production)
-    ;; FIXME: might be worth it to set a flash message saying that the
-    ;; repair has been initiated
-    (response/redirect "/")))
-
+    (-> (response/redirect-after-post "/")
+        (assoc :flash {:message "Repair has been initiated"}))))

 (defn production-set-state [id state]
   (let [production (prod/find id)]


Fix a comment typo

Fix a comment typo

--- src/mdr2/views.clj
+++ src/mdr2/views.clj
@@ -49,7 +49,7 @@
                       ;; enable the "Recorded" button if the next state is "recorded",
                       ;; there is an DAISY export and the production has been imported from
                       ;; the libary, i.e. is not handled via ABACUS or
-                      ;; the production has already a library signatur
+                      ;; the production has already a library signature
                       ;; as is the case with productions that are
                       ;; repaired
                       (and (= next-state "recorded")


Added functions to read stats from DB

Added functions to read stats from DB

--- src/arachnida/db_interface.clj
+++ src/arachnida/db_interface.clj
@@ -32,9 +32,67 @@
     "Zapis dat do tabulky."
     [db product repo branch sha message author date files-changed insertions deletions]
     (jdbc/insert! db "commits" {:product product :repo repo :branch branch
-                                             :sha     sha     :message message
-                                             :author author   :date date
-                                             :files_changed files-changed
-                                             :insertions insertions
-                                             :deletions deletions}))
+                                :sha     sha     :message message
+                                :author author   :date date
+                                :files_changed files-changed
+                                :insertions insertions
+                                :deletions deletions}))

+(defn read-authors
+    []
+    (jdbc/query db-spec/data-db
+                               ["select author as author,
+                                        count(*) as commits_count,
+                                        sum(files_changed) as files_changed,
+                                        sum(insertions) as insertions,
+                                        sum(deletions) as deletions
+                                 from commits
+                                 where date between '2015-01-01' and '2015-12-31'
+                                 group by author order by author"]))
+
+(defn read-stat-per-weeks-from-db
+    [first-day last-day]
+    (jdbc/query db-spec/data-db ["select count(*) as commits_count,
+                                         sum(files_changed) as files_changed,
+                                         sum(insertions) as insertions,
+                                         sum(deletions) as deletions
+                                 from commits
+                                 where date between ? and ?" first-day last-day]))
+
+(defn read-stat-per-weeks-for-author-from-db
+    [first-day last-day author]
+    (jdbc/query db-spec/data-db ["select count(*) as commits_count,
+                                         sum(files_changed) as files_changed,
+                                         sum(insertions) as insertions,
+                                         sum(deletions) as deletions
+                                 from commits
+                                 where date between ? and ? and author=?" first-day last-day author]))
+
+(defn read-statistic-for-week-from-db
+    [first-day last-day author]
+    (jdbc/query db-spec/data-db ["select repo,
+                                         count(*) as commits,
+                                         sum(files_changed) as files,
+                                         sum(insertions) as insertions,
+                                         sum(deletions) as deletions
+                                 from  commits
+                                 where date between ? and ?
+                                   and author=?
+                                 group by repo
+                                 order by repo" first-day last-day author]))
+
+(defn read-commits-for-week
+    [first-day last-day author]
+    (jdbc/query db-spec/data-db ["select id,
+                                         (select name from products where products.id=commits.product) as product,
+                                         (select name from repos where repos.id=commits.repo) as repo,
+                                         sha, branch, message, date
+                                  from commits
+                                  where date between ? and ? and author=?
+                                  order by product, repo, date" first-day last-day author]))
+
+(defn read-commit-info
+    [commit-id]
+    (if commit-id
+        (jdbc/query db-spec/data-db ["select * from changed_files where commit_id=?" commit-id])))
+


Browse button behaves same way for all doc-cbx settings Doc, Value, Meta, and All

--- src/clj_ns_browser/browser.clj
+++ src/clj_ns_browser/browser.clj
@@ -797,8 +797,6 @@
       (b/transform (fn [o] (selection (id :doc-cbx))))
       (b/transform (fn [o]
         (case o
-          ("All" "Doc") (invoke-soon (config! (id :browse-btn) :enabled? true))
-
           ("Examples" "See alsos" "Comments")
           (if-let [fqn (config (id :doc-tf) :text)]
             (future
@@ -807,7 +805,7 @@
                 (invoke-soon
                  (config! (id :browse-btn) :enabled? r)))))

-          nil))))  ; do nothing if no match
+          (invoke-soon (config! (id :browse-btn) :enabled? true))))))
     ;;
     (b/bind
       (apply b/funnel [(id :doc-tf) (id :doc-cbx)])
@@ -843,13 +841,11 @@
           (when-let [fqn (config (id :doc-tf) :text)]
             (future
               (case o
-                ("All" "Doc") (bdoc* fqn)
-
                 ("Examples" "See alsos" "Comments")
                 (when-let [url (clojuredocs-url fqn)]
                   (clojure.java.browse/browse-url url))

-                nil)))))))  ; do nothing if no match
+                (bdoc* fqn))))))))
     ;;
     ;; edit-btn pressed =>
     ;; if we find a local file (not inside jar), then send to $EDITOR.


fix home route bug

fix home route bug

--- src/cljs/offcourse/routes.cljs
+++ src/cljs/offcourse/routes.cljs
@@ -56,4 +56,5 @@

   (defroute (:home route-names) []
     (response :collection
+              :collection-type :named-collection
               :collection-name :featured)))


Clean up try/cratch

Clean up try/cratch

--- src/clojure/nightcode/lein.clj
+++ src/clojure/nightcode/lein.clj
@@ -177,9 +177,8 @@
   [in-out func]
   (->> (fn []
          (try (func)
-           (catch Exception e (when-let [error (.getMessage e)]
-                                (println error))))
-         (println "\n===" (utils/get-string :finished) "==="))
+           (catch Exception e (some-> (.getMessage e) println))
+           (finally (println "\n===" (utils/get-string :finished) "==="))))
        (redirect-io in-out)
        (fn [])
        Thread.


fix mobile nav to homepage

fix mobile nav to homepage

--- src/cornwalltechjam/layout.clj
+++ src/cornwalltechjam/layout.clj
@@ -107,7 +107,7 @@
          [:button {:type "button", :class "navbar-toggle", :data-toggle "collapse", :data-target "#bs-example-navbar-collapse-1"}
           [:span {:class "sr-only"} "Toggle navigation"]
           [:i {:class "fa fa-bars"}]]
-         [:a {:id "ar-brand", :class "navbar-brand hidden-lg hidden-md hidden-sm", :href "index.html"} "Cornwall "
+         [:a {:id "ar-brand", :class "navbar-brand hidden-lg hidden-md hidden-sm", :href "/index.html"} "Cornwall "
           [:span {} "Tech Jam"]]]

         [:div {:class "collapse navbar-collapse", :id "bs-example-navbar-collapse-1"}


Remove uneeded import

Remove uneeded import

--- test/src/clojure/neko/activity_test.clj
+++ test/src/clojure/neko/activity_test.clj
@@ -35,7 +35,6 @@
               [context :only [*context*]]
               find-view
               test-utils]
-        neko.test-utils
         junit.assert))

 (defn -init []


adding ns to state order to avoid collisions

--- src/mount/core.clj
+++ src/mount/core.clj
@@ -28,12 +28,15 @@
     (and suspend (not resume)) (throw
                                  (IllegalArgumentException. "suspendable state should have a resume function (i.e. missing :resume fn)"))))

+(defn- with-ns [ns name]
+  (str ns "/" name))
+
 (defmacro defstate [state & body]
   (let [[state params] (macro/name-with-attributes state body)
         {:keys [start stop suspend resume] :as lifecycle} (apply hash-map params)]
     (validate lifecycle)
     (let [s-meta (cond-> {:mount-state mount-state
-                          :order (make-state-seq state)
+                          :order (make-state-seq (with-ns *ns* state))
                           :start `(fn [] ~start)
                           :status #{:stopped}}
                    stop (assoc :stop `(fn [] ~stop))


Make the countries filter styling less busy

--- frontend/styles/faceboard/css/people.clj
+++ frontend/styles/faceboard/css/people.clj
@@ -41,8 +41,7 @@
               :padding-top (px 6)
               :border-top "2px solid #ccc"])))
        (>> countries-filter-item
-         [:background-color filter-item-background-normal-color
-          :color people-desk-background-color
+         [:color people-desk-background-color
           :margin-bottom (px 2)
           :margin-right (px 2)
           :border-radius (px 2)
@@ -51,17 +50,9 @@
           :height (px 16)
           :float :left]
          (>> &.selected
-           [:background-color filter-item-background-selected-color]
-           (>> flag
-             [:opacity 1]))
-         (>> &:hover
-           [:background-color filter-item-background-hovered-color]
-           (>> flag
-             [:opacity 1]))
-         (>> flag
-           [:position :relative
-            :opacity 0.7
-            ]))
+           [:background-color filter-item-background-selected-color])
+         (>> &:hover
+           [:background-color filter-item-background-hovered-color]))
        (>> tags-filter-item
          [:float :left
           :padding (px 1 4)


fail early and avoid being bitten by cascading conservative handling of output folders

--- src/corpusmaker/cli.clj
+++ src/corpusmaker/cli.clj
@@ -11,14 +11,17 @@
     "Compute the incoming links count for dbpedia resources"
     [[link-file "The link file in N-TRIPLE format"]
      [redirect-file "The redirect file in N-TRIPLE format"]
-     [output-folder "The output folder" "."] ;; TODO handle HDFS URLs
+     [output-folder "The output folder (should not exist)" "counts-output"]
+     ;; TODO handle HDFS URLs
      remaining]
     (try
       (if (or (= link-file nil) (= redirect-file nil))
         (do (println "ERROR: missing link file or redirect file") 3)
         ;; TODO: find a way to report progress?
         ;; TODO: handle the stdin case
-        (do (time (count-incoming link-file redirect-file output-folder)) 0))
+        (if (.exists (java.io.File. output-folder))
+          (do (println "ERROR: output folder already exists") 3)
+          (do (time (count-incoming link-file redirect-file output-folder)) 0)))
       (catch java.io.FileNotFoundException fnfe
         (println "ERROR:" (.getMessage fnfe)) 2))))


added comments and example file paths

added comments and example file paths

--- src/distillery/core.clj
+++ src/distillery/core.clj
@@ -39,20 +39,34 @@

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

-(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\11.01 Theoretische, technische, praktische, angewandte Informatik.clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\11.01 Theoretische, technische, praktische, angewandte Informatik.clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\12.01.1 Datenstrukturen, Array, Queue, Stack.clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\12.01.2 Baum als Datenstruktur.clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\Algorithmen und Datenstrukturen 001.clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\Algorithmen und Datenstrukturen 002.clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\Algorithmen und Datenstrukturen 003.clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\Algorithmen und Datenstrukturen 004.clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\Bernd Senf 3. Bankgeheimnis Geldschöpfung - Monetative als Lösung (720).clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\Binomialverteilung_Formel von Bernoulli, Stochastik, Nachhilfe online, Hilfe in Mathe (720).clj")
+(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\Der Lambda-Kalkül (720).clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\Einseitiger(rechtsseitiger) Hypothesentest_mit Ablesen aus der Tabelle, Stochastik, Nachhilfe online (720).clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\IS-Kurve im Vier-Quadrantenschema Die Herleitung (720).clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\Gauß-Algorithmus_Lineares Gleichungssystem lösen (einfach_schnell erklärt), Nachhilfe online (720).clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\Makroökonomie online lernen - VWL Tutorium (360).clj")
+;(def path "D:\\Daten\\FH\\OLL\\Media\\Audio\\de-DE\\Parabeln_Quadratische Funktion_en Übersicht (Scheitelpunkt,Stauchung,Streckung,etc.) (720).clj")

-(def results (load-data path))
-(def phrases (map best-alternate results))
-;(def phrases (mapcat :alternates results))
-(def words (mapcat :words phrases))
-(def nouns (filter noun? words))
+(def results (load-data path)) ;; Load the recgnition results
+(def phrases (map best-alternate results)) ;; Extract the best phrases from the alternates
+;(def phrases (mapcat :alternates results)) ;; Take all phrases from the results
+(def words (mapcat :words phrases)) ;; Extract the words (text, confidence)
+(def nouns (filter noun? words)) ;; Only take words with first character upper case

 (def grouped-nouns
   (let
-    [groups (group-by :text nouns)
-     confidences (map (partial map-group-items :confidence) groups)
-     squaresums (map (partial map-pair-value squared-sum) confidences)
-     ordered (reverse (sort-by #(get % 1) squaresums))]
+    [groups (group-by :text nouns) ;; Group words by text
+     confidences (map (partial map-group-items :confidence) groups) ;; Reject additional text per confidence
+     squaresums (map (partial map-pair-value squared-sum) confidences) ;; Build square sums of confidence per word
+     ordered (reverse (sort-by #(get % 1) squaresums))] ;; Sort the words by sum of squared confidence
     ordered))

-(pprint (take 20 grouped-nouns))
+(pprint (take 20 grouped-nouns)) ;; Print the head of the resulting list


fixed function call generate-txt-result-files!

--- src/distillery/core.clj
+++ src/distillery/core.clj
@@ -72,7 +72,7 @@
   [job-descr]
   (let [job (prepare-and-analyze job-descr)]
     (generate-xml-result-file! job)
-    (generate-txt-result-file! job)
+    (generate-txt-result-files! job)
     (when (get-in job [:configuration :visualize-result])
       (generate-website! job)))
   nil)


bugfix do not add '?action=render' to wikipedia resources using the file protocol

--- src/distillery/data.clj
+++ src/distillery/data.clj
@@ -72,8 +72,10 @@

 (defn load-text-from-wikipedia
   "Loads the textual content from an Wikipedia page."
-  [url & opts]
-  (let [url (str url "?action=render")
+  [^String url & opts]
+  (let [url (if (.startsWith url "file://")
+              url
+              (str url "?action=render"))
         nodes (-> (build-reader url opts)
                   (eh/html-resource)
                   (eh/transform #{[:script]


allow for request and cust in rollbar/send-error

--- src/pc/rollbar.clj
+++ src/pc/rollbar.clj
@@ -140,5 +140,11 @@
 (defn report-error
   "Reports an exception at the 'error' level"
   [error-string & [params]]
-  (let [data-map (base-data (profile/env) "error")]
-    (send-payload (build-payload (token) [data-map (assoc params :body {:message {:body error-string}})]))))
+  (let [data-map (base-data (profile/env) "error")
+        request-map (when (:request params)
+                      (request-data (:request params) (:cust params)))]
+    (send-payload (build-payload (token) [data-map
+                                          request-map
+                                          (-> params
+                                            (assoc :body {:message {:body error-string}})
+                                            (dissoc :request :cust))]))))


cleanup

cleanup

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@6364 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -486,8 +486,7 @@
   (swap! (.state this) assoc :stop false :pause false)
   (let [out-queue (GentleLinkedBlockingQueue.)
         settings (convert-settings acq-settings)
-        acq-thread (Thread. #(run-acquisition this
-          settings out-queue))
+        acq-thread (Thread. #(run-acquisition this settings out-queue))
         processors (ProcessorStack. out-queue (.getTaggedImageProcessors acq-eng))
         out-queue-2 (.begin processors)
         display (LiveAcqDisplay. mmc out-queue-2 (make-summary-metadata settings)


Fixed acquire button (1 of 2)

Fixed acquire button (1 of 2)

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@8585 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -694,6 +694,7 @@
   {:init-width (core getImageWidth)
    :init-height (core getImageHeight)
    :pixel-type (get-pixel-type)
+   :bit-depth (core getImageBitDepth)
    :binning (core getProperty (core getCameraDevice) "Binning")})

 (defn acquire-tagged-image []


fix mistake

fix mistake

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@8478 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -473,7 +473,7 @@
       (core stopSequenceAcquisition))
     (stop-trigger)
     (core setAutoShutter (@state :init-auto-shutter))
-    (core set-exposure (core getCameraDevice) (@state :init-exposure))
+    (set-exposure (core getCameraDevice) (@state :init-exposure))
     (set-stage-position (@state :default-z-drive) (@state :init-z-position))
     (when (and (@state :init-continuous-focus)
                (not (core isContinuousFocusEnabled)))


move defn arglists down, to make room for docstrings (eventually).

--- src/overtone/gui/sequencer.clj
+++ src/overtone/gui/sequencer.clj
@@ -8,7 +8,8 @@
         [seesaw.mig :only [mig-panel]])
   (:require [seesaw.bind :as bind]))

-(defn- make-initial-state [metro steps instruments init-vals]
+(defn- make-initial-state
+  [metro steps instruments init-vals]
   {:playing?  false
    :metronome metro
    :steps     steps
@@ -24,37 +25,44 @@

 (def ^{:private true} NEW_ENTRY {:on true})

-(defn- toggle-playing [state]
+(defn- toggle-playing
+  [state]
   (update-in state [:playing?] not))

-(defn- get-entry [state row col]
+(defn- get-entry
+  [state row col]
   (get-in state [:rows row :value col]))

-(defn- set-entry [state row col v]
+(defn- set-entry
+  [state row col v]
   (if (< row (count (:rows state)))
     (assoc-in state [:rows row :value col] v)
     state))

-(defn- update-entry [state row col v]
+(defn- update-entry
+  [state row col v]
   (if (< row (count (:rows state)))
     (update-in state [:rows row :value col] merge NEW_ENTRY v)
     state))

-(defn- mute-entry [state row col]
+(defn- mute-entry
+  [state row col]
   (update-in state [:rows row :value col]
              (fn [v]
                (if (associative? v)
                  (assoc-in v [:on] false)
                  v))))

-(defn- toggle-entry [state row col]
+(defn- toggle-entry
+  [state row col]
   (update-in state [:rows row :value col]
              (fn [v]
                (if (associative? v)
                  (update-in v [:on] not)
                  NEW_ENTRY))))

-(defn- delete-entry [state row col]
+(defn- delete-entry
+  [state row col]
   (set-entry state row col false))

 (defn- get-row-param
@@ -132,7 +140,8 @@
                   default)]
     (double (/ (- p-val min) (- max min)))))

-(defn- paint-grid [state ^javax.swing.JComponent c g]
+(defn- paint-grid
+  [state ^javax.swing.JComponent c g]
   (let [w    (width c)
         h    (height c)
         rows (count (:rows state))
@@ -187,7 +196,8 @@
         param  (scaled-param-map state r y-val)]
     {:row r :col c :r-size r-size :c-size c-size :y-val y-val :param param}))

-(defn- on-grid-clicked [state e]
+(defn- on-grid-clicked
+  [state e]
   (let [{:keys [row col param]} (parse-grid-click state e)
         new-state (cond (.isControlDown e) (delete-entry state row col)
                         (.isAltDown e)     (update-entry state row col param)
@@ -200,7 +210,8 @@

     new-state))

-(defn- on-grid-drag [state e]
+(defn- on-grid-drag
+  [state e]
   (let [{:keys [row col r-size c-size y-val param]} (parse-grid-click state e)]
     (cond (.isControlDown e) (delete-entry state row col)
           (.isShiftDown e)   (mute-entry state row col)
@@ -215,11 +226,13 @@
               index))
           rows)))

-(defn- on-param-selection [state inst e]
+(defn- on-param-selection
+  [state inst e]
   (let [r (inst->index (:rows state) inst)]
     (assoc-in state [:rows r :param] (selection e))))

-(defn- step-grid [state-atom]
+(defn- step-grid
+  [state-atom]
   (let [state @state-atom

         c (canvas :background :darkgrey


Improve docstring for shape

Improve docstring for shape

--- src/play_clj/core_graphics.clj
+++ src/play_clj/core_graphics.clj
@@ -32,11 +32,19 @@

 (defmacro shape
   "Returns an entity based on [ShapeRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html).
-
-    ; create a red rectangle
+You may pass in a type (see `shape-type`) or an existing `shape` entity that you
+want to modify.
+
+A `shape` can draw multiple sub-shapes internally, allowing you to create more
+complicated shapes. If you use `assoc` to set the overall :x and :y of the
+`shape`, each sub-shape's x and y position will be relative to it.
+
+    ; create a green and red rectangle
     (shape :filled
+           :set-color (color :green)
+           :rect 0 0 10 30
            :set-color (color :red)
-           :rect 0 0 10 30)
+           :rect 10 0 10 30)
     ; create an empty shape, then set it to a green rectangle
     (shape (shape :filled)
            :set-color (color :green)


added (typed) functions to 'puns.greyt

added (typed) functions to 'puns.greyt

--- src/puns/greyt.clj
+++ src/puns/greyt.clj
@@ -1,7 +1,74 @@
+;; -*- mode: clojure; mode: typed-clojure -*-
+
 (ns puns.greyt
   "Greyt punster"
-  {:author "Eric Bailey"})
+  {:author "Eric Bailey"}
+  (:import (clojure.lang LazySeq PersistentVector)
+           (java.io BufferedReader)
+           (java.lang CharSequence)
+           (java.net URL)
+           (java.util.regex Pattern))
+  (:require [clojure.core.typed :refer [Any AVec IFn U ann defalias]]
+            [clojure.java.io :refer [reader resource]]
+            [clojure.string :refer [split upper-case]]))

+;; ===== TYPE ALIASES =====
+
+(defalias ABoolean (U Boolean nil))
+
+(defalias AString (U String nil))
+
+(defalias AVecString (U (PersistentVector String) nil))
+
+(defalias AAVecString (U (AVec String) nil))
+
+
+;; ===== MISC ANNOTATIONS =====
+
+(ann ^:no-check clojure.core/line-seq
+     (IFn [BufferedReader -> (LazySeq String)]))
+
+(ann ^:no-check clojure.core/some? (IFn [Any -> Boolean]))
+
+(ann ^:no-check clojure.java.io/reader (IFn [URL -> BufferedReader]))
+
+(ann ^:no-check clojure.java.io/resource (IFn [String -> URL]))
+
+;; FIXME: LAME HACK
+(ann clojure.string/split (IFn [AString Pattern -> (PersistentVector String)]))
+
+
+;; ===== MAIN =====
+
+(ann is-word? (IFn [String -> (IFn [String -> AAVecString])]
+                   [String String -> AAVecString]))
+(defn- is-word?
+  ([word]
+   (fn [line] (is-word? word line)))
+  ([word line]
+   (let [[k v] (split line #"  ")]
+     (when (= k word) (split v #" ")))))
+
+(ann starts-with? (IFn [String -> (IFn [String -> Boolean])]))
+(defn- starts-with? [^String s1] (fn [^String s2] (.startsWith s2 s1)))
+
+(ann syllables (IFn [String -> AAVecString]))
+(defn syllables
+  "Takes a string a and returns a vector of its syllables, if it's found in
+  the dictionary, otherwise nil."
+  [word]
+  (let [word (upper-case word)]
+    (with-open [dict (reader (resource "cmudict.0.7a.txt"))]
+      (some (is-word? word) (drop 212 (line-seq dict))))))
+
+(ann ey? (IFn [String -> ABoolean]))
+(defn ey?
+  "Is this grey or not?"
+  [word]
+  (when-let [coll (syllables (upper-case word))]
+    (some? (seq (filter (starts-with? "EY") coll)))))
+
+(ann pen-pun (IFn [String -> String]))
 (defn pen-pun
   "TODO: Make greyt puns."
   [s] s)


CMR-1700: Changing bootstrap of virtual products to use core.async to improve performance.

--- bootstrap-app/src/cmr/bootstrap/data/util.clj
+++ bootstrap-app/src/cmr/bootstrap/data/util.clj
@@ -44,7 +44,8 @@
       (concept-service/save-concept-revision mdb-context  {:concept-id concept-id
                                                            :revision-id revision-id
                                                            :deleted true})
-      (index-service/delete-concept indexer-context concept-id revision-id true))
+      (index-service/delete-concept indexer-context concept-id revision-id
+                                    {:ignore-conflict? true}))
     (catch clojure.lang.ExceptionInfo e
       (let [data (ex-data e)]
         (if (= (:type data) :conflict)


fix links

fix links

--- src/site/index.clj
+++ src/site/index.clj
@@ -86,7 +86,7 @@
               [:h3 (:h3 typescale)]]
              [:p.desc {:position "relative"} (s/&padding 0.5 1)]])
      [:div.container
-      (block-header (url (str items-type)) items-type (count items))
+      (block-header (url (name items-type)) items-type (count items))
       (apply grid
              (for [p (take 3 items)]
                [[:div.card


bumped version to 0.17.0

bumped version to 0.17.0

--- src/unspun/db.cljs
+++ src/unspun/db.cljs
@@ -8,7 +8,7 @@
             [shared.ui :refer [get-dimensions]]
             ))

-(def version "v0.16.1")
+(def version "v0.17.0")

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


fix position. the placement of the reverse matters!

--- src/useful/map.clj
+++ src/useful/map.clj
@@ -103,8 +103,7 @@
 (defn position
   "Returns a map from item to the position of its first occurence in coll."
   [coll]
-  (into {} (map-indexed (fn [idx val] [val idx])
-                        (reverse coll)))) ; so earlier values clobber later ones
+  (into {} (reverse (map-indexed (fn [idx val] [val idx]) coll))))

 (defn filter-keys-by-val
   "Returns all keys in map for which (pred value) returns true."


premerge

premerge

--- test/minijava/test_compile.clj
+++ test/minijava/test_compile.clj
@@ -9,7 +9,7 @@
                  (accept [_ name] (not (nil? (re-find #"java$" name)))))
         files (-> "resources/sample" java.io.File. (.listFiles filter))]
     (doseq [f files]
-    (println (compile-program f)))))
+    (dorun (compile-program f)))))

 (deftest test-factorial
@@ -34,7 +34,7 @@

 }" ]

- (println (compile-program prog))
+ (dorun (compile-program prog))

 ))

@@ -141,7 +141,7 @@

 }"]

- (println (compile-program prog))
+ (dorun (compile-program prog))

 ))


Revised advice-pointcut relation.
New relations advice-pointcutdefinition and pointcutdefinition-pointcut.
Issue #7, #6.

Example query:
 (damp.ekeko/ekeko* [?aspect ?advice ?pcdefinition ?pc]
                         (aspect-pointcutdefinition ?aspect
?pcdefinition)
                         (pointcutdefinition-pointcut ?pcdefinition ?pc)
                         (advice-pointcut ?advice ?pc))


added trapazoid and simpson's rule functions

--- src/hydrofoil/model.clj
+++ src/hydrofoil/model.clj
@@ -113,19 +113,29 @@
          1
          (/ 1 pieces)))

-(defn riemann-sum-abstracted
+(defn integral-abstracted
   "Will do a riemann sum on the function:
   State will be a function, either left, right, or middle, based on the style of riemann sum.
   Pices is how boxes it makes, aka the resolution of the riemann sum"
   [function state pieces]
   (reduce #(+ %1 (* (/ 1 pieces) (function %2))) 0 (state pieces)))

-(defn riemann-sum-production
+(defn integral-production
   "same as riemann sum but if might be faster, you need to figure our left, right, middle
   functions on your own"
   [function start-x end-x increment pieces]
   (reduce #(+ %1 (* (/ 1 pieces) (function %2))) 0 (range start-x end-x increment)))

+(defn trapazoid-integral
+  [function pieces]
+  (* 0.5 (+ (integral-abstracted function left-rule pieces)
+            (integral-abstracted function right-rule pieces))))
+
+(defn simpson-integral
+  [function pieces]
+  (+ (/ (trapazoid-integral function (/ pieces 2)) 3)
+     (/ (* 2 (integral-abstracted function middle-rule (/ pieces 2))) 3)))
+
 ;;(defn lift-function
 ;;  [])


adding role

adding role

--- test/celestial/test/persistency.clj
+++ test/celestial/test/persistency.clj
@@ -48,7 +48,7 @@
      (validate-user {:username "foo" :password "bar" :roles admin :envs [""]})  =>
        (throws ExceptionInfo (with-m? {:envs '(({0 ("must be a keyword")}))} ))
      (validate-user {:username "foo" :password "bar" :roles ["foo"] :envs []})  =>
-       (throws ExceptionInfo (with-m? {:roles '(({0 ("role must be either #{:celestial.roles/anonymous :celestial.roles/user :celestial.roles/admin}")}))} ))
+       (throws ExceptionInfo (with-m? {:roles '(({0 ("role must be either #{:celestial.roles/super-user :celestial.roles/anonymous :celestial.roles/user :celestial.roles/admin}")}))} ))
       )

 (fact "aws volumes validations"


Fix docstring

Fix docstring

--- src/karmanaut/utils.clj
+++ src/karmanaut/utils.clj
@@ -34,7 +34,7 @@
   (quot (.getTime dt) 1000))

 (defn hours-since-midnight [dt]
-  "Number of seconds elapsed since midnight"
+  "Number of hours elapsed since midnight"
   (let [mn (midnight dt)
         mnsec (seconds-since-epoch mn)
         dtsec (seconds-since-epoch dt)]


Fix not being able to load editor

Fix not being able to load editor

Not loading simple mode was causing dockerfile.js to throw:
CodeMirror.defineSimpleMode is not a function

--- src/lt/objs/editor.cljs
+++ src/lt/objs/editor.cljs
@@ -1008,6 +1008,9 @@
                         (load/js (str "core/node_modules/codemirror/addon/fold/" file) :sync))
                       (load/css "node_modules/codemirror/addon/fold/foldgutter.css")
                       (load/js "core/node_modules/codemirror/keymap/sublime.js" :sync)
+
+                      ;; Provides defineSimpleMode for some modes
+                      (load/js "core/node_modules/codemirror/addon/mode/simple.js" :sync)
                       (doseq [path (files/filter-walk #(and (= (files/ext %) "js")
                                                             (not (some (fn [m] (> (.indexOf % (str "core/node_modules/codemirror/mode/" m "/")) -1))
                                                                        mode-blacklist))


prevent lazy seq exception

prevent lazy seq exception

--- src/node/game/core.cljs
+++ src/node/game/core.cljs
@@ -68,8 +68,8 @@
           (swap! state assoc-in [:corp :servers :remote]
                  (vec (map-indexed
                        (fn [i s]
-                         {:content (for [c (:content s)] (update-in c [:zone] assoc 2 i))
-                          :ices (for [c (:ices s)] (update-in c [:zone] assoc 2 i))})
+                         {:content (for [c (:content s)] (update-in c [:zone] #(assoc (vec %) 2 i)))
+                          :ices (for [c (:ices s)] (update-in c [:zone] #(assoc 2 i)))})
                        (get-in @state [:corp :servers :remote]))))))
       moved-card)))


FM | 398 | exposed config error page

FM | 398 | exposed config error page

--- src/objective8/core.clj
+++ src/objective8/core.clj
@@ -39,7 +39,8 @@
   (if (or (all-okta-credentials-provided?) (:private-mode-enabled config/environment))
     (m/wrap-handlers-except handlers #(friend/wrap-authorize % #{:signed-in})
                             #{:fe/error-log-in :fe/sign-in :fe/create-profile-get
-                              :fe/create-profile-post :fe/authorisation-page})
+                              :fe/create-profile-post :fe/authorisation-page
+                              :fe/error-configuration})
     (m/wrap-just-these-handlers handlers #(friend/wrap-authorize % #{:signed-in})
                                 #{:fe/create-objective-form :fe/create-objective-form-post :fe/add-a-question
                                   :fe/add-question-form-post :fe/add-answer-form-post :fe/create-profile-get


RS & AB | #0 | wrap-ssl-redirect in a slightly different way

--- src/objective8/core.clj
+++ src/objective8/core.clj
@@ -103,9 +103,10 @@
       (wrap-xss-protection true {:mode :block})
       (wrap-frame-options :sameorigin)

-      (#(if (config/get-var "ENABLE_HTTPS_ONLY")
-          wrap-ssl-redirect
-          %))))
+      ((if (config/get-var "ENABLE_HTTPS_ONLY")
+         wrap-ssl-redirect
+         identity
+         ))))

 (defonce server (atom nil))
 (defonce scheduler (atom nil))


DRY up email sending.

DRY up email sending.

--- src/oc/email/mailer.clj
+++ src/oc/email/mailer.clj
@@ -17,47 +17,50 @@
 (def default-reply-to (str "hello@" c/email-from-domain))
 (def default-inviter "OpenCompany")

-(defn- email-snapshot
+(defn- email
+  "Send an email."
+  [{:keys [to source reply-to subject]} body]
+  (timbre/info "Sending email: " to)
+  (let [text (:text body)
+        text-body (if text {:text text} {})
+        html (:html body)
+        html-body (if html (assoc text-body :html html) text-body)]
+    (ses/send-email creds
+      :destination {:to-addresses [to]}
+      :source source
+      :reply-to-addresses [reply-to]
+      :message {:subject subject
+                :body html-body})))
+
+(defn- email-snapshots
   "Send emails to all to recipients in parallel."
-  [{to :to reply-to :reply-to subject :subject snap :snapshot} body]
-  (let [snapshot (keywordize-keys snap)
+  [{:keys [to reply-to subject snapshot]} body]
+  (let [snapshot (keywordize-keys snapshot)
         company-slug (:company-slug snapshot)
         company-name (:name snapshot)]
-    (doall (pmap
-      #(do
-        (timbre/info "Sending email: " %)
-        (ses/send-email creds
-          :destination {:to-addresses [%]}
-          :source (str company-name "<" company-slug "@" c/email-from-domain ">")
-          :reply-to-addresses [(if (s/blank? reply-to) default-reply-to reply-to)]
-          :message {:subject subject
-                    :body {:html body}}))
-        to))))
+    (doall (pmap #(do
+      (email {
+        :to %
+        :source (str company-name "<" company-slug "@" c/email-from-domain ">")
+        :reply-to (if (s/blank? reply-to) default-reply-to reply-to)
+        :subject subject} {:html body})) to))))

 (defn send-snapshot [{note :note snapshot :snapshot :as msg}]
+  "Create an HTML snapshot and email it to the specified recipients."
   (let [uuid-fragment (subs (str (java.util.UUID/randomUUID)) 0 4)
         html-file (str uuid-fragment ".html")
         inline-file (str uuid-fragment ".inline.html")]
     (try
       (spit html-file (content/html (assoc snapshot :note note))) ; create the email in a tmp file
       (shell/sh "juice" html-file inline-file) ; inline the CSS
-      (email-snapshot msg (slurp inline-file)) ; email it to the recipients
+      (email-snapshots msg (slurp inline-file)) ; email it to the recipients
       (finally
         ; remove the tmp files
         (io/delete-file html-file true)
         (io/delete-file inline-file true)))))

-(defn- email-invite
-  [{:keys [to reply-to subject company-name]} body]
-  (timbre/info "Sending email: " to)
-  (ses/send-email creds
-    :destination {:to-addresses [to]}
-    :source (str default-inviter " <" default-reply-to ">")
-    :reply-to-addresses [(if (s/blank? reply-to) default-reply-to reply-to)]
-    :message {:subject subject
-              :body {:text (:text body)}}))
-
 (defn send-invite [message]
+  "Create an HTML and text invite and email it to the specified recipients."
   (let [uuid-fragment (subs (str (java.util.UUID/randomUUID)) 0 4)
         html-file (str uuid-fragment ".html")
         inline-file (str uuid-fragment ".inline.html")
@@ -67,12 +70,14 @@
         prefix (if (s/blank? from) "You've been invited" (str from " invites you"))
         company (if (s/blank? company-name) "" (str company-name " on "))
         subject (str prefix " to join " company "OpenCompany")
-        invitation (assoc msg :subject subject)]
+        invitation (-> msg
+                      (assoc :subject subject)
+                      (assoc :source (str default-inviter " <" default-reply-to ">")))]
     (try
       (spit html-file (invite/html invitation)) ; create the email in a tmp file
       (shell/sh "juice" html-file inline-file) ; inline the CSS
-      (email-invite invitation {:text (invite/text invitation)
-                                :html (slurp inline-file)}) ; email it to the recipients
+      (email invitation {:text (invite/text invitation)})
+                         ;:html (slurp inline-file)}) ; email it to the recipients
       (finally
         ; remove the tmp files
         (io/delete-file html-file true)


All tests pass, for whatever that's worth in this altered state

--- src/omhome/web_test.clj
+++ src/omhome/web_test.clj
@@ -14,7 +14,7 @@
     (or
       (not (.startsWith href "/"))
       (contains? pages href)
-      (contains? pages (str href "index.html.old")))))
+      (contains? pages (str href "index.html")))))

 (fact
   "All links are valid"


stdout logging of summary

stdout logging of summary

--- src/ontrail/summary.clj
+++ src/ontrail/summary.clj
@@ -66,5 +66,6 @@
     (get-summary {:sport sport :user user :date {:$gte first-day :$lte last-day}} sport)))

 (defn get-overall-summary [user]
+  (println (str "Getting overall summary: " user))
   (let [all-sports (mc/distinct EXERCISE "sport" {:user user})]
     (map #(get-summary {:user user :sport %} %) all-sports)))


Improve onyx seq logging message.

Improve onyx seq logging message.

--- src/onyx/plugin/seq.clj
+++ src/onyx/plugin/seq.clj
@@ -25,7 +25,7 @@
        (vreset! rst sequential)
        (vreset! offset 0))
       (do
-       (info "ABS plugin, recover dropping:" checkpoint (take checkpoint sequential))
+       (info "onyx.plugin.seq is recovering state by dropping" checkpoint "elements.")
        (vreset! rst (drop checkpoint sequential))
        (vreset! offset checkpoint))))


Update 'About' the game

Update 'About' the game

--- resources/localization.clj
+++ resources/localization.clj
@@ -49,11 +49,11 @@

 ## Jak hra funguje? ##

-V případě DB-quizu jsou herní otázky náhodně generovány na základě databáze. Ve hře je jako databáze použita sémantická podoba české Wikipedia, která je vytvářena v projektu [DBpedia](http://dbpedia.org/). Alternativně lze použít otázky z tabulek v Google Spreadsheets.
+V případě DB-quizu jsou herní otázky náhodně generovány na základě databáze. Ve hře jsou jako databáze použity sémantické podoba české a anglické Wikipedie, která jsou vytvářena v projektu [DBpedia](http://dbpedia.org/). Alternativně lze použít otázky z tabulek v Google Spreadsheets.

 Otázky ve hře jsou generovány automaticky, takže se může stát, že v nich bude prozrazena hádaná odpověď. V takovém případě prosím otázku nahlašte pomocí tlačítka 'Nahlásit spoiler'.

-Hru dal dohromady [Jindřich Mynarz](http://mynarz.net/#jindrich) s pomocí přátel. Zdrojový kód hry je k dispozici [zde](https://github.com/jindrichmynarz/db-quiz)."
+Hru na [Vysoké škole ekonomické](http://www.vse.cz/) dali dohromady [Jindřich Mynarz](http://mynarz.net/#jindrich) a Václav Zeman s pomocí přátel. Zdrojový kód hry je k dispozici [zde](https://github.com/jindrichmynarz/db-quiz)."
                :google-spreadsheet-help* "## Jak má tabulka vypadat? ##

 Tabulka musí mít 2 sloupce, záhlaví a alespoň tolik řádků, kolik je hracích políček. Ve sloupci pojmenovaném 'Label' jsou názvy hádaných věcí, zatímco ve sloupci se jménem 'Description' jsou otázky popisující hádanou věc.
@@ -137,11 +137,11 @@

 ## How does the game work? ##

-DB-quiz generates game questions randomly from a database. The game uses the semantic form of Czech Wikipedie that is created as a part of [DBpedia](http://dbpedia.org/). Google Spreadsheet can be used as an alternative source of questions.
+DB-quiz generates game questions randomly from a database. The game uses the semantic forms of Czech and English Wikipedias that are created as part of [DBpedia](http://dbpedia.org/). Google Spreadsheet can be used as an alternative source of questions.

 Questions in the game are generated automatically, so they may inadvertently reveal the correct answers. If you encounter such question, please report it using the 'Report spoiler' button.

-The game was created by [Jindřich Mynarz](http://mynarz.net/#jindrich) with help from his friends. Source code of the game is available [here](https://github.com/jindrichmynarz/db-quiz)."
+The game was created at the [University of Economics, Prague](http://www.vse.cz/english/) by [Jindřich Mynarz](http://mynarz.net/#jindrich) and Václav Zeman with a help from friends. Source code of the game is available [here](https://github.com/jindrichmynarz/db-quiz)."
                :google-spreadsheet-help* "## How should I format the spreadsheet? ##

 A spreadsheet that can be used as a data source for DB-quiz needs to contain columns named *Label* and *Description*. *Label* provides the correct answers, while *Description* provides the questions describing the things to be guessed. A valid spreadsheet must contain a header row with the column labels and at least 28 rows, so that there is a question for each field on the game board. When the spreadsheet contains more rows, then 28 rows are selected randomly.


Add note to replace goog.require with require

--- src-cljs/frontend/devtools.clj
+++ src-cljs/frontend/devtools.clj
@@ -3,4 +3,5 @@

 (defmacro require-devtools! []
   (when (:devtools env)
+    ;; TODO: Replace this with a ClojureScript require function
     '(js/goog.require "frontend.devtools")))


standardize format for series.clj

standardize format for series.clj

--- exercises/series/src/series.clj
+++ exercises/series/src/series.clj
@@ -1,3 +1,5 @@
 (ns series)

-(defn slices [string n])
+(defn slices [string n] ;; <- arglist goes here
+  ;; your code goes here
+  )


better recursive calculation for dones

better recursive calculation for dones

--- src/todos/todo_item.clj
+++ src/todos/todo_item.clj
@@ -7,12 +7,14 @@
         notes     (atom [])
         sub-todos (atom [])
         status-done (fn [] (if (= 0 (count @sub-todos))
-                              1
-                              (apply (partial *
-                                              (/ (count (filter #((% :done?)) @sub-todos))
-                                                 (count @sub-todos)))
-                                     (for [i @sub-todos] ((i :status-done)) )
-                                     )))
+                              (if @done 1 0)
+                              (/ (apply (partial +
+                                                 (/ (count (filter #((% :done?)) @sub-todos))
+                                                    (count @sub-todos))
+                                                 (if @done 1 0))
+                                        (for [i @sub-todos] ((i :status-done)) ))
+                                 (inc (count  @sub-todos))
+                                 )))
         ]
     {:name        (fn [] @todo-name)           ; fn Get name
      :rename      (partial reset! todo-name)   ; fn Rename     [string]


Chris - print full stacktrace for unexcepted errors

--- src/nevergreen/wrap_exceptions.clj
+++ src/nevergreen/wrap_exceptions.clj
@@ -20,7 +20,7 @@
     {:status (get-status data) :body (get-body data) :headers headers}))

 (defn handle-unknown [e]
-  (log/error (str "Unexpected expection thrown with message [" (.getMessage e) "]"))
+  (.printStackTrace e)
   {:status 500 :body (.getMessage e) :headers headers})

 (defn wrap-exceptions [app]


RS & CW | #27 | fix bug with section urls for latest draft

--- src/objective8/templates/draft.clj
+++ src/objective8/templates/draft.clj
@@ -35,10 +35,11 @@

 (def section-link-snippet (first (html/select draft-template [:.draft-add-inline-comment])))

-(defn update-section-link-with-label [label {:keys [ring-request] :as context}]
-  (let [uri (:uri ring-request)]
+(defn update-section-link-with-label [label {:keys [data] :as context}]
+  (let [draft-id  (get-in data [:draft :_id])
+        objective-id (get-in data [:draft :objective-id])]
     (html/at section-link-snippet
-             [:.clj-annotation-link] (html/set-attr :href (str uri "/sections/" label)))))
+             [:.clj-annotation-link] (html/set-attr :href (utils/path-for :fe/draft-section :id objective-id :d-id draft-id :section-label label)))))

 (defn add-section-link [context node]
   (let [section-label (get-in node [:attrs :data-section-label])]


add default rule to relate grammatical {:infl :imperfect} and semantic imperfect tense

--- src/babel/english/grammar.cljc
+++ src/babel/english/grammar.cljc
@@ -579,24 +579,32 @@
                        [k filtered-v]))))}}))

 (defn default-fn [tree morph]
-  (log/debug (str "English: do-defaults on tree: " (morph tree)))
-  (-> tree
-      (apply-default
-       {:synsem {:cat :verb
-                 :sem {:tense :present
-                       :aspect :progressive}
-                 :infl :present}})
-      (apply-default
-       {:synsem {:cat :verb
-                 :sem {:tense :future}
-                 :infl :future}})
-      (apply-default
-       {:synsem {:cat :verb
-                 :sem {:tense :conditional}
-                 :infl :conditional}})
-      (apply-default
-       {:synsem {:cat :noun
-                 :sem {:number :singular}}})))
+  (log/debug (str "English: do-defaults (pre) on tree: " (morph tree)))
+  (let [result
+        (-> tree
+            (apply-default
+             {:synsem {:cat :verb
+                       :sem {:tense :present
+                             :aspect :progressive}
+                       :infl :present}})
+            (apply-default
+             {:synsem {:cat :verb
+                       :sem {:tense :future}
+                       :infl :future}})
+            (apply-default
+             {:synsem {:cat :verb
+                       :sem {:tense :conditional}
+                       :infl :conditional}})
+            (apply-default
+             {:synsem {:cat :verb
+                       :sem {:aspect :progressive
+                             :tense :past}
+                       :infl :imperfect}})
+            (apply-default
+             {:synsem {:cat :noun
+                       :sem {:number :singular}}}))]
+    (log/debug (str "English: do-defaults (post) on tree: " (morph result)))
+    result))

 (defn medium []
   (let [lexicon


cleanup: don't use this deprecated parent rule 'comp-modifies-head'

--- src/babel/english/grammar.cljc
+++ src/babel/english/grammar.cljc
@@ -10,7 +10,7 @@
    [babel.lexiconfn :refer [edn2lexicon filtered-lexicon read-lexicon]]
    [babel.parse :as parse]
    [babel.ug :as ug
-    :refer [apply-default-if comp-modifies-head
+    :refer [apply-default-if
             comp-specs-head head-semantics
             head-principle root-is-comp
             root-is-head root-is-head-root
@@ -180,7 +180,6 @@
    subcat-1-1-principle
    hc-agreement
    head-principle
-   comp-modifies-head
    head-last
    {
     :schema-symbol 'c11 ;; used by over-each-parent to know where to put children.


less constraints on complement of noun-phrase3

--- src/babel/english/grammar.cljc
+++ src/babel/english/grammar.cljc
@@ -415,9 +415,8 @@
                        :mod head-mod
                        :sem head-sem}}
        :comp {:phrasal true
-              :rule "slash-obj"
-              :synsem {:cat :verb
-                       :sem comp-sem}}})
+              :slash true
+              :synsem {:sem comp-sem}}})

     (let [head-modified-by-comp (atom :top)]
       {:comp {:synsem {:subcat {:1 head-modified-by-comp}}}
@@ -450,7 +449,8 @@
       {:synsem {:infl infl
                 :participle participle}
        :head {:synsem {:infl infl
-                       :participle participle}}}))])
+                       :participle participle}}})
+    )])

 (defn aux-is-head-feature [phrase]
   (cond (= :verb (get-in phrase '(:synsem :cat)))


essere=false by default

essere=false by default

--- src/babel/francais/lexicon.clj
+++ src/babel/francais/lexicon.clj
@@ -1,9 +1,11 @@
 (ns babel.francais.lexicon
+  (:refer-clojure :exclude [get-in])
   (:require
    [babel.lexiconfn :refer (unify)]
    [babel.francais.morphology :refer [exception-generator phonize]]
    [babel.francais.pos :refer :all]
-   [babel.lexiconfn :refer (compile-lex map-function-on-map-vals unify)]))
+   [babel.lexiconfn :refer (compile-lex map-function-on-map-vals unify)]
+   [dag-unify.core :refer [get-in]]))

 (def lexicon-source
   {
@@ -27,8 +29,7 @@
                      :sem {:pred :amare
                            :subj {:human true}}}}

-   "aller" {:français {:essere true
-                       :future-stem "ir"
+   "aller" {:français {:future-stem "ir"
                        :present {:1sing "vais"
                                  :2sing "vas"
                                  :3sing "va"
@@ -196,6 +197,7 @@
                          :sem {:pred :teach}}}]

    "entrer" {:synsem {:cat :verb
+                      :essere true
                      :sem {:pred :enter}}}

    "envoyer" {:synsem {:cat :verb
@@ -454,6 +456,22 @@
               ;; if verb does specify a [:sem :obj], then fill it in with subcat info.
               transitivize

+              ;; default: essere=false
+              (map-function-on-map-vals
+               (fn [k vals]
+                 (map (fn [val]
+                        ;; if: 1. the val's :cat is :verb
+                        ;;     2. it is not true that essere=true (either essere=false or essere is not defined)
+                        ;; then: essere=false
+                        (cond (and (= (get-in val [:synsem :cat])
+                                      :verb)
+                                   (not (= true (get-in val [:synsem :essere] false))))
+                              (unify val {:synsem {:essere false}})
+
+                              true ;; otherwise, leave the verb alone
+                              val))
+                      vals)))
+
               ;; Cleanup functions can go here. Number them for ease of reading.
               ;; 1. this filters out any verbs without an inflection:
               ;; infinitive verbs should have inflection ':infinitive',


Fix 'italic' -> 'italics' in litedocx.wpml/paragraph-style

--- src/bakyeono/litedocx/wpml.clj
+++ src/bakyeono/litedocx/wpml.clj
@@ -369,7 +369,7 @@
   [name
    & {:as options
       :keys [font font-size font-color
-             bold? italic? underline? strike?
+             bold? italics? underline? strike?
              align
              space-before space-after space-line
              indent-left indent-right indent-first-line mirror-indents?]}]


some zipper funcs

some zipper funcs

--- sass-dsl/src/sass_dsl/transform.clj
+++ sass-dsl/src/sass_dsl/transform.clj
@@ -57,3 +57,22 @@
        (common/is-element loc)
        (common/get-parent loc))
     (common/is-selector (common/get-parrent loc))))
+
+(defn parent-name
+  "Get the name of the parent at the zipper location."
+  [loc]
+  {:pre [(not (nil? loc))]}
+  (if (and
+       (common/is-element loc)
+       (common/get-parent loc))
+    (zip/node (common/get-parent loc))))
+
+(defn is-selector-and-parent-is-selector
+  "Is the element at the zipper locationa selector and does it have a
+  selector parent?"
+  [loc]
+  (and
+   (common/is-selector loc)
+   (is-parent-selector loc)))
+
+


[#118] Fix rollback for fixtures to include tenants

--- backend/test/org/akvo/dash/fixtures.clj
+++ backend/test/org/akvo/dash/fixtures.clj
@@ -24,5 +24,5 @@
                                  :title "Tenant 2"})
       (migrate/migrate conn)
       (f)
-      (migrate/rollback conn [])
+      (migrate/rollback conn [:all])
       (finally (stop)))))


Check for nil? in domain-needs-update? in case it's a new domain not yet loaded from remote.

--- src/clj/elephantdb/service.clj
+++ src/clj/elephantdb/service.clj
@@ -55,8 +55,9 @@
     ))

 (defn domain-needs-update? [local-vs remote-vs]
-  (< (.mostRecentVersion local-vs)
-     (.mostRecentVersion remote-vs)))
+  (or (nil? (.mostRecentVersion local-vs))
+      (< (.mostRecentVersion local-vs)
+         (.mostRecentVersion remote-vs))))

 (defn use-cache-or-update [domain domains-info global-config local-config]
   (let [fs (filesystem (:hdfs-conf local-config))
@@ -68,7 +69,7 @@
         local-vs (DomainStore. lfs local-domain-root (.getSpec remote-vs))]
     (if (domain-needs-update? local-vs remote-vs)
       (do
-        (doto (local-filesystem) (clear-dir local-domain-root))  ;; clear domain dir first
+        (doto lfs (clear-dir local-domain-root))  ;; clear domain dir first
         (load-domain fs
                      local-config
                      local-domain-root


working on removing namespace from keywords in entities,

but discarding this idea, as it should be considered an application
level issue.

--- src/clj/ow/factum/entities.clj
+++ src/clj/ow/factum/entities.clj
@@ -3,10 +3,12 @@
             [clojure.core.logic.pldb :as lp]
             [clojure.core.logic.fd :as lfd]
             [clojure.string :as str]
+            [clojure.set :refer [union]]
             [ow.factum.logic :as fl]))

 (defn entity [ldb eid]
-  "Retrieves entire entity."
+  "Retrieves an entity with all its attributes and values
+without altering those."
   (let [efacts (lp/with-db ldb
                  (l/run* [q]
                    (l/fresh [e a v]
@@ -15,6 +17,15 @@
                      (l/== q [a v]))))]
     (when (not-empty efacts)
       (into {:db/eid eid} efacts))))
+
+#_(defn entity [ldb eid]
+  "Retrieves an entity with all its attributes and values.
+Note that the underlying fact's namespaced attributes are
+converted to non-namespaced attributes during this process."
+  (let [e (entity* ldb eid)
+        xf (map (fn [[nkw v]]
+                  [(-> nkw name keyword) v]))]
+    (into {} xf e)))

 #_(defn get-entities [ldb attribute value]
   "Retrieves entire entities."
@@ -38,10 +49,9 @@
   (let [name (clojure.core/name name)
         recsym (-> name str/capitalize symbol)
         mapctorsym (-> (str "map->" (str/capitalize name)) symbol)
-        printfields (into #{:db/eid}
-                          (comp (map clojure.core/name)
-                                (map #(keyword name %)))
-                          fields)
+        printfields (transduce (comp (map clojure.core/name)
+                                     (map (fn [n] #{(keyword n) (keyword name n)})))
+                               union #{:eid :db/eid} fields)
         getsym (-> (str "get-" name) symbol)
         ;;;getsymm (-> (str "get-" name "s") symbol)
         transform #(if transform


parse user badge endorsements

parse user badge endorsements

--- src/clj/salava/badge/parse.clj
+++ src/clj/salava/badge/parse.clj
@@ -134,10 +134,10 @@

 (defn- email-variations [emails]
   (remove nil? (mapcat #(list %
-                 (string/upper-case %)
-                 (string/lower-case %)
-                 (string/capitalize %)
-                 (capitalize-name %)) emails)))
+                              (string/upper-case %)
+                              (string/lower-case %)
+                              (string/capitalize %)
+                              (capitalize-name %)) emails)))

 ;;;

@@ -163,72 +163,72 @@
         evidence_url (q-url (:evidence assertion))]

     (assoc initial
-           :badge {:id ""
-                   :remote_url nil
-                   :remote_id nil
-                   :remote_issuer_id nil
-                   :issuer_verified 0
-                   :default_language_code ""
-                   :content [{:id ""
-                              :language_code ""
-                              :name (:name badge)
-                              :image_file (q-url (:image badge))
-                              :description (:description badge)
-                              :alignment []
-                              :tags (get badge :tags [])}]
-                   :criteria [{:id ""
-                               :language_code ""
-                               :url (q-url (:criteria badge))
-                               :markdown_text (http/alternate-get "text/x-markdown" criteria)}]
-                   :issuer [{:id ""
-                             :language_code ""
-                             :name (str (:name issuer) ": " (:org issuer))
-                             :description (:description issuer)
-                             :url (q-url (:origin issuer))
-                             :email (:contact issuer)
-                             :endorsement []
-                             :image_file nil
-                             :revocation_list_url nil}]
-                   :creator nil
-                   :endorsement []
-                   :published 0
-                   :last_received 0
-                   :recipient_count 0}
-           :issued_on  (u/str->epoch (or (:issued_on assertion) (:issuedOn assertion)))
-           :expires_on (u/str->epoch (:expires assertion))
-           :evidence [(when-not (nil? evidence_url)
-                       {:id nil
-                         :user_badge_id nil
-                         :url evidence_url
-                         :narrative nil
-                         :name nil
-                         :description nil
-                         :genre nil
-                         :audience nil
-                         :ctime now
-                         :mtime now})])))
+      :badge {:id ""
+              :remote_url nil
+              :remote_id nil
+              :remote_issuer_id nil
+              :issuer_verified 0
+              :default_language_code ""
+              :content [{:id ""
+                         :language_code ""
+                         :name (:name badge)
+                         :image_file (q-url (:image badge))
+                         :description (:description badge)
+                         :alignment []
+                         :tags (get badge :tags [])}]
+              :criteria [{:id ""
+                          :language_code ""
+                          :url (q-url (:criteria badge))
+                          :markdown_text (http/alternate-get "text/x-markdown" criteria)}]
+              :issuer [{:id ""
+                        :language_code ""
+                        :name (str (:name issuer) ": " (:org issuer))
+                        :description (:description issuer)
+                        :url (q-url (:origin issuer))
+                        :email (:contact issuer)
+                        :endorsement []
+                        :image_file nil
+                        :revocation_list_url nil}]
+              :creator nil
+              :endorsement []
+              :published 0
+              :last_received 0
+              :recipient_count 0}
+      :issued_on  (u/str->epoch (or (:issued_on assertion) (:issuedOn assertion)))
+      :expires_on (u/str->epoch (:expires assertion))
+      :evidence [(when-not (nil? evidence_url)
+                   {:id nil
+                    :user_badge_id nil
+                    :url evidence_url
+                    :narrative nil
+                    :name nil
+                    :description nil
+                    :genre nil
+                    :audience nil
+                    :ctime now
+                    :mtime now})])))

 ; old v0.5.0 badge content
 #_{:badge_url    nil
-  :issuer_url   nil
-  :criteria_url (q-url (:criteria badge))
-  :creator_url  nil
-  :badge_content {}
-  :issuer_content {:id ""
-                   :name (str (:name issuer) ": " (:org issuer))
-                   :description (:description issuer)
-                   :url (q-url (:origin issuer))
-                   :email (:contact issuer)
-                   :image_file nil
-                   :revocation_list_url nil}
-  :criteria_content {:id ""
-                     :html_content criteria
-                     :markdown_text (http/alternate-get "text/x-markdown" criteria)}
-  :creator_content  nil
-  :issued_on  (u/str->epoch (or (:issued_on assertion) (:issuedOn assertion)))
-  :expires_on (u/str->epoch (:expires assertion))
-  :evidence_url (q-url (:evidence assertion))}
+   :issuer_url   nil
+   :criteria_url (q-url (:criteria badge))
+   :creator_url  nil
+   :badge_content {}
+   :issuer_content {:id ""
+                    :name (str (:name issuer) ": " (:org issuer))
+                    :description (:description issuer)
+                    :url (q-url (:origin issuer))
+                    :email (:contact issuer)
+                    :image_file nil
+                    :revocation_list_url nil}
+   :criteria_content {:id ""
+                      :html_content criteria
+                      :markdown_text (http/alternate-get "text/x-markdown" criteria)}
+   :creator_content  nil
+   :issued_on  (u/str->epoch (or (:issued_on assertion) (:issuedOn assertion)))
+   :expires_on (u/str->epoch (:expires assertion))
+   :evidence_url (q-url (:evidence assertion))}

 ;;

@@ -246,15 +246,15 @@
                       :content (get-in e [:claim :endorsementComment] "")
                       :issued_on (u/str->epoch (:issuedOn e))
                       :issuer (as-> (:issuer e) $
-                                (if (map? $) $ (http/json-get $))
-                                {:id (:id $)
-                                 :language_code ""
-                                 :name (:name $)
-                                 :description (:description $)
-                                 :url (:url $)
-                                 :email (:email $)
-                                 :image_file (:image $)
-                                 :revocation_list_url nil})}
+                                    (if (map? $) $ (http/json-get $))
+                                    {:id (:id $)
+                                     :language_code ""
+                                     :name (:name $)
+                                     :description (:description $)
+                                     :url (:url $)
+                                     :email (:email $)
+                                     :image_file (:image $)
+                                     :revocation_list_url nil})}
                      nil)))
             (remove nil?)
             (map (fn [e]
@@ -355,39 +355,65 @@
                    ;; list of evidences
                    (coll? (:evidence assertion)) (mapv (fn [e]
                                                          {:id nil
-                                                            :user_badge_id nil
-                                                            :url (:id e)
-                                                            :narrative (:narrative e)
-                                                            :name (:name e)
-                                                            :description (:description e)
-                                                            :genre (:genre e)
-                                                            :audience (:audience e)
-                                                            :ctime now
-                                                            :mtime now}) (:evidence assertion))
+                                                          :user_badge_id nil
+                                                          :url (:id e)
+                                                          :narrative (:narrative e)
+                                                          :name (:name e)
+                                                          :description (:description e)
+                                                          :genre (:genre e)
+                                                          :audience (:audience e)
+                                                          :ctime now
+                                                          :mtime now}) (:evidence assertion))
                    :else [])

         badge  (if (map? (:badge assertion)) (:badge assertion) (http/json-get (:badge assertion)))
         related (->> (get badge :related [])
                      (map #(http/json-get (:id %)))
                      (remove #(nil? ((keyword "@language") %))))
-        default-language (get badge (keyword "@language") "")]
+        default-language (get badge (keyword "@language") "")
+        endorsement (cond
+                      (map? (:endorsement assertion)) [{:id nil
+                                                        :external_id (get-in assertion [:endorsement :id])
+                                                        :user_badge_id nil
+                                                        :issuer_id nil
+                                                        :issuer_name (get-in assertion [:endorsement :issuer :name])
+                                                        :issuer_url (get-in assertion [:endorsement :issuer :id])
+                                                        :content (get-in assertion [:endorsement :claim :endorsementComment])
+                                                        :ctime (u/str->epoch (get-in assertion [:endorsement :issuedOn]))
+                                                        :mtime (u/str->epoch (get-in assertion [:endorsement :issuedOn]))
+                                                        }]
+
+                      (coll? (:endorsement assertion)) (mapv (fn [e]
+                                                              {:id nil
+                                                               :external_id (get-in assertion [:endorsement :id])
+                                                               :user_badge_id nil
+                                                               :issuer_id nil
+                                                               :issuer_name (get-in assertion [:endorsement :issuer :name])
+                                                               :issuer_url (get-in assertion [:endorsement :issuer :id])
+                                                               :content (get-in assertion [:endorsement :claim :endorsementComment])
+                                                               :ctime (u/str->epoch (get-in assertion [:endorsement :issuedOn]))
+                                                               :mtime (u/str->epoch (get-in assertion [:endorsement :issuedOn]))
+                                                               }) (:endorsement assertion))
+                      :else []
+                      ) ]

     (assoc initial
-           :badge (merge {:id ""
-                          :remote_url nil
-                          :remote_id nil
-                          :remote_issuer_id nil
-                          :issuer_verified 0
-                          :default_language_code default-language
-                          :published 0
-                          :last_received 0
-                          :recipient_count 0
-                          }
-                          (apply merge-with (cons concat (map parser (cons badge related)))))
-           :issued_on  (u/str->epoch (:issuedOn assertion))
-           :expires_on (u/str->epoch (:expires assertion))
-           :evidence evidence
-           )))
+      :badge (merge {:id ""
+                     :remote_url nil
+                     :remote_id nil
+                     :remote_issuer_id nil
+                     :issuer_verified 0
+                     :default_language_code default-language
+                     :published 0
+                     :last_received 0
+                     :recipient_count 0
+                     }
+                    (apply merge-with (cons concat (map parser (cons badge related)))))
+      :issued_on  (u/str->epoch (:issuedOn assertion))
+      :expires_on (u/str->epoch (:expires assertion))
+      :evidence evidence
+      :endorsement endorsement
+      )))
 ;;;

 (defmethod badge-content :default [initial assertion]
@@ -410,76 +436,76 @@
                       :json_url creator-url}]))]

     (assoc initial
-           :badge {:id ""
-                   :remote_url nil
-                   :remote_id nil
-                   :remote_issuer_id nil
-                   :issuer_verified 0
-                   :default_language_code ""
-                   :content [{:id ""
-                              :language_code ""
-                              :name (:name badge)
-                              :image_file (:image badge)
-                              :description (:description badge)
-                              :alignment (get badge :alignment [])
-                              :tags (get badge :tags [])}]
-                   :criteria [{:id ""
-                               :language_code ""
-                               :url (:criteria badge)
-                               :markdown_text (http/alternate-get "text/x-markdown" criteria)}]
-                   :issuer [{:id ""
-                             :language_code ""
-                             :name (:name issuer)
-                             :description (:description issuer)
-                             :url (:url issuer)
-                             :email (:email issuer)
-                             :image_file nil
-                             :endorsement []
-                             :revocation_list_url (:revocationList issuer)}]
-                   :creator creator
-                   :endorsement []
-                   :published 0
-                   :last_received 0
-                   :recipient_count 0}
-           :issued_on  (u/str->epoch (:issuedOn assertion))
-           :expires_on (u/str->epoch (:expires assertion))
-           :evidence [(when-not (nil? evidence_url)
-                        {:id nil
-                         :user_badge_id nil
-                         :url evidence_url
-                         :narrative nil
-                         :name nil
-                         :description nil
-                         :genre nil
-                         :audience nil
-                         :ctime now
-                         :mtime now})])))
+      :badge {:id ""
+              :remote_url nil
+              :remote_id nil
+              :remote_issuer_id nil
+              :issuer_verified 0
+              :default_language_code ""
+              :content [{:id ""
+                         :language_code ""
+                         :name (:name badge)
+                         :image_file (:image badge)
+                         :description (:description badge)
+                         :alignment (get badge :alignment [])
+                         :tags (get badge :tags [])}]
+              :criteria [{:id ""
+                          :language_code ""
+                          :url (:criteria badge)
+                          :markdown_text (http/alternate-get "text/x-markdown" criteria)}]
+              :issuer [{:id ""
+                        :language_code ""
+                        :name (:name issuer)
+                        :description (:description issuer)
+                        :url (:url issuer)
+                        :email (:email issuer)
+                        :image_file nil
+                        :endorsement []
+                        :revocation_list_url (:revocationList issuer)}]
+              :creator creator
+              :endorsement []
+              :published 0
+              :last_received 0
+              :recipient_count 0}
+      :issued_on  (u/str->epoch (:issuedOn assertion))
+      :expires_on (u/str->epoch (:expires assertion))
+      :evidence [(when-not (nil? evidence_url)
+                   {:id nil
+                    :user_badge_id nil
+                    :url evidence_url
+                    :narrative nil
+                    :name nil
+                    :description nil
+                    :genre nil
+                    :audience nil
+                    :ctime now
+                    :mtime now})])))

 ; old v1.0/v1.1 badge content
 #_{:badge_url    (:badge assertion)
-            :issuer_url   (:issuer badge)
-            :criteria_url (:criteria badge)
-            :creator_url  creator-url
-            :badge_content {:id ""
-                            :name (:name badge)
-                            :image_file (:image badge)
-                            :description (:description badge)
-                            :alignment (get badge :alignment [])
-                            :tags (get badge :tags [])}
-            :issuer_content {:id ""
-                             :name (:name issuer)
-                             :description (:description issuer)
-                             :url (:url issuer)
-                             :email (:email issuer)
-                             :image_file (:image issuer)
-                             :revocation_list_url (:revocationList issuer)}
-            :criteria_content {:id ""
-                               :html_content criteria
-                               :markdown_text (http/alternate-get "text/x-markdown" criteria)}
-            :creator_content  creator
-            :issued_on  (u/str->epoch (:issuedOn assertion))
-            :expires_on (u/str->epoch (:expires assertion))
-            :evidence_url (:evidence assertion)}
+   :issuer_url   (:issuer badge)
+   :criteria_url (:criteria badge)
+   :creator_url  creator-url
+   :badge_content {:id ""
+                   :name (:name badge)
+                   :image_file (:image badge)
+                   :description (:description badge)
+                   :alignment (get badge :alignment [])
+                   :tags (get badge :tags [])}
+   :issuer_content {:id ""
+                    :name (:name issuer)
+                    :description (:description issuer)
+                    :url (:url issuer)
+                    :email (:email issuer)
+                    :image_file (:image issuer)
+                    :revocation_list_url (:revocationList issuer)}
+   :criteria_content {:id ""
+                      :html_content criteria
+                      :markdown_text (http/alternate-get "text/x-markdown" criteria)}
+   :creator_content  creator
+   :issued_on  (u/str->epoch (:issuedOn assertion))
+   :expires_on (u/str->epoch (:expires assertion))
+   :evidence_url (:evidence assertion)}
 ;;;

 (defmulti recipient (fn [_ asr] (class (:recipient asr))))
@@ -538,20 +564,20 @@
      (clj-http/with-connection-pool {:timeout 10 :threads 4 :insecure? false :default-per-route 10}
        (-> initial
            (assoc :id nil
-                  :user_id (:id user)
-                  :email   (recipient (:emails user) assertion)
-                  :status "pending"
-                  :visibility "private"
-                  :show_recipient_name 0
-                  :rating nil
-                  :ctime now
-                  :mtime now
-                  :deleted 0
-                  :revoked 0
-                  :issuer_verified 0
-                  :show_evidence 0
-                  :last_checked nil
-                  :old_id nil)
+             :user_id (:id user)
+             :email   (recipient (:emails user) assertion)
+             :status "pending"
+             :visibility "private"
+             :show_recipient_name 0
+             :rating nil
+             :ctime now
+             :mtime now
+             :deleted 0
+             :revoked 0
+             :issuer_verified 0
+             :show_evidence 0
+             :last_checked nil
+             :old_id nil)
            (badge-content assertion)
            valid-badge)))))


Add possibility to stop simulation by giving end predicate.

--- src/clj_gatling/simulation.clj
+++ src/clj_gatling/simulation.clj
@@ -27,12 +27,12 @@
     (go (>! c (run)))
     ret))

-(defn- run-scenarios-in-parallel [scenario-runners parallel-count]
+(defn- run-scenarios-in-parallel [scenario-runners parallel-count end-fn]
   (with-channels [cs parallel-count]
     (let [ps (map vector (iterate inc 0) cs)]
       (doseq [[i c] ps]
         (go (>! c ((nth scenario-runners i)))))
-      (let [results-with-new-run (map (partial collect-result-and-run-next cs) (drop parallel-count scenario-runners))
+      (let [results-with-new-run (take-while end-fn (map (partial collect-result-and-run-next cs) (drop parallel-count scenario-runners)))
             results-rest (repeatedly parallel-count (partial collect-result cs))]
         (concat results-with-new-run results-rest)))))

@@ -63,7 +63,7 @@
         scenario (nth scenarios i)
         scenario-runs (map (partial run-scenario-async scenario) (range (* users rounds)))]
      (println (str "Running scenario " (:name scenario) " with " users " users and " rounds " rounds."))
-     (deliver result (run-scenarios-in-parallel scenario-runs users))
+     (deliver result (run-scenarios-in-parallel scenario-runs users (fn [{:keys [id]}] (<= id (* users rounds)))))
     result))

 (defn run-simulation [scenarios users & [options]]


added a goto stackoverflow help menu item that uses the pattern: http://stackoverflow.com/search?q=clojure+reduce to narrow the search not very fine-grained, but it's a start

--- src/clj_ns_browser/browser.clj
+++ src/clj_ns_browser/browser.clj
@@ -353,6 +353,16 @@
   (action :name "JIRA..."
           :handler (fn [a] (future (clojure.java.browse/browse-url
             "http://dev.clojure.org/jira/browse/CLJ")))))
+(add-app-action :go-stackoverflow-action
+  (action :name "Stackoverflow..."
+          :handler (fn [e]
+            (let [id (partial select-id (to-root e))]
+              (let [fqn (config (id :doc-tf) :text)]
+              (if-let [fqn-name (fqname fqn)]
+                (let [ns-n-class (ns-name-class-str fqn-name)
+                      sname (if (nil? (second ns-n-class)) (first ns-n-class)(second ns-n-class))]
+                  (future (clojure.java.browse/browse-url
+                    (str "http://stackoverflow.com/search?q=clojure+" sname))))))))))
 (add-app-action :go-about-action
   (action :name "About..."
           :handler (fn [a] (invoke-later (alert (str "Clojure Namespace Browser (" clj-ns-browser-version ")" \newline
@@ -1079,7 +1089,7 @@
         (id :manual-refresh-browser-action) auto-refresh-browser-cb :separator (id :bring-all-windows-to-front-action)
         (id :cycle-through-windows-action)])

-      (config! help-menu :items [(id :go-github-action) (id :go-clojure.org-action) (id :go-clojuredocs-action) (id :go-cheatsheet-action) (id :go-jira-action) (id :go-about-action)])
+      (config! help-menu :items [(id :go-github-action) (id :go-clojure.org-action) (id :go-clojuredocs-action) (id :go-cheatsheet-action) (id :go-stackoverflow-action) (id :go-jira-action) (id :go-about-action)])
       (config! docs-menu :items [update-clojuredocs :separator
                                  clojuredocs-online-rb clojuredocs-offline-rb
                                  :separator])


Comment out demo client core - need to move this to a separate repo eventually

--- src/cljs/dato/client/core.cljs
+++ src/cljs/dato/client/core.cljs
@@ -62,14 +62,14 @@

 ;; (-main (js/document.getElementById "dato-app") app-state)

-(defonce connected?
-  (do
-    (figwheel/watch-and-reload
-     :websocket-url "ws://localhost:3449/figwheel-ws"
-     :jsload-callback (fn []
-                        (js/console.log "Reloading from figwheel..")))
-    (weasel/connect "ws://localhost:9001" :verbose true :print #{:repl :console})
-    true))
+;; (defonce connected?
+;;   (do
+;;     (figwheel/watch-and-reload
+;;      :websocket-url "ws://localhost:3449/figwheel-ws"
+;;      :jsload-callback (fn []
+;;                         (js/console.log "Reloading from figwheel..")))
+;;     (weasel/connect "ws://localhost:9001" :verbose true :print #{:repl :console})
+;;     true))

-(defn ^:export inspect-state []
-  (clj->js @app-state))
+;; (defn ^:export inspect-state []
+;;   (clj->js @app-state))


Polymorphic state monad functions

Polymorphic state monad functions

--- src/cljx/cats/monad/state.cljx
+++ src/cljx/cats/monad/state.cljx
@@ -30,7 +30,8 @@
   #+cljs
   (:require-macros [cats.core :refer (with-context)])
   (:require [cats.protocols :as proto]
-            [cats.data :as d]))
+            [cats.data :as d]
+            [cats.core :as m]))

 (declare state-monad)

@@ -118,19 +119,19 @@
   "Return a State instance with computation that returns
   the current state."
   []
-  (proto/get-state state-monad))
+  (proto/get-state (m/get-current-context-or state-monad)))

 (defn put-state
   "Return a State instance with computation that replaces
   the current state with specified new state."
   [newstate]
-  (proto/put-state state-monad newstate))
+  (proto/put-state (m/get-current-context-or state-monad) newstate))

 (defn swap-state
   "Return a State instance with computation that applies the
   specified function to state and returns the old state."
   [f]
-  (proto/swap-state state-monad f))
+  (proto/swap-state (m/get-current-context-or state-monad) f))

 (defn run-state
   "Given a State instance, execute the
@@ -146,7 +147,7 @@

   This should be return something to: #<Pair [1 2]>"
   [state seed]
-  (with-context state-monad
+  (with-context (m/get-current-context-or state-monad)
     (state seed)))

 (defn eval-state