Boolean inputs, and drop floats.

Boolean inputs, and drop floats.

--- src/clojush/problems/classification/penn.clj
+++ src/clojush/problems/classification/penn.clj
@@ -25,15 +25,15 @@
   (let [f (slurp* (str "src/clojush/problems/classification/data/"  ;; todo?: allow command-line arg
                        ;"GAMETES_Epistasis_2-Way_20atts_0.4H_EDM-1_1.txt"
                        ;"a_5000s_2000her_0.1__maf_0.2_EDM-1_01.txt"
-                       ;"xor_2_a_20s_1600_EDM-1_01.txt"
+                       "xor_2_a_20s_1600_EDM-1_01.txt"
                        ;"xor_3_a_20s_1600_EDM-1_01.txt"
-                       "xor_4_a_20s_1600_EDM-1_01.txt"
+                       ;"xor_4_a_20s_1600_EDM-1_01.txt"
                        ))
         lines (csv/parse-csv f :delimiter \tab)]
     (println "Total number of data lines:" (count lines))
     (mapv #(mapv read-string %) lines)))

-(def training-proportion 0.5) ;; proportion of training cases to use each generation
+(def training-proportion 0.1) ;; proportion of training cases to use each generation

 (def resampling false)

@@ -45,9 +45,12 @@
   (let [raw-data (read-data)
         target-column (.indexOf (mapv clojure.string/upper-case (mapv name (first raw-data)))
                                 "CLASS")
+        vocabulary (sort (distinct (flatten (rest raw-data))))
         inputs (fn [row]
-                 (vec (concat (take target-column row)
-                              (drop (inc target-column) row))))
+                 (let [raw-inputs (concat (take target-column row)
+                                          (drop (inc target-column) row))]
+                   (vec (flatten (for [i raw-inputs]
+                                   (map #(= i %) vocabulary)))))) ;; inputs are boolean
         target (fn [row] (str (nth row target-column))) ;; target classes are strings
         fitness-cases-shuffled (lshuffle (mapv (fn [row]
                                                  {:inputs (inputs row)
@@ -126,14 +129,13 @@

 (def penn-atom-generators
   (cycle-to-longest (concat (distinct (mapv :target (:all-train @penn-fitness-cases))) ;; classes, for output
-                            (list (tag-instruction-erc [:exec :integer :float :boolean :string] 1000)
+                            (list (tag-instruction-erc [:exec :integer :boolean :string] 1000)
                                   (tagged-instruction-erc 1000)
-                                  (fn [] (lrand-int 1000))
-                                  (fn [] (lrand 1))))
+                                  (fn [] (lrand-int 1000))))
                     (for [n (map inc
                                  (range (count (:inputs (first (:train @penn-fitness-cases))))))]
                       (symbol (str "in" n)))
-                    (concat (registered-for-stacks [:exec :integer :float :boolean])
+                    (concat (registered-for-stacks [:exec :integer :boolean])
                             '(string_pop string_dup string_dup_times string_dup_items
                                          string_swap string_rot string_flush string_eq string_stackdepth
                                          string_yank string_yankdup string_shove string_empty))))
@@ -181,3 +183,4 @@
    ;:autoconstructive-entropy 0.1
    })

+


Use log for alias

Use log for alias

--- app/src/edge/httpd.clj
+++ app/src/edge/httpd.clj
@@ -5,7 +5,7 @@
    [bidi.bidi :refer [tag]]
    [bidi.vhosts :refer [make-handler vhosts-model]]
    [clojure.java.io :as io]
-   [clojure.tools.logging :refer :all]
+   [clojure.tools.logging :as log]
    edge.graphql
    edge.yada.lacinia
    [edge.examples :refer [authentication-example-routes]]
@@ -139,7 +139,7 @@
   [_ {:edge.httpd/keys [host port] :as config}]
   (let [vhosts-model (vhosts-model [{:scheme :http :host host} (routes config)])
         listener (yada/listener vhosts-model {:port port})]
-    (infof "Started http server on port %s" (:port listener))
+    (log/infof "Started http server on port %s" (:port listener))
     {:listener listener
      ;; host is used for announcement in dev
      :host host}))


add get-config! and set-config! fns

add get-config! and set-config! fns

--- src/aspire/util.clj
+++ src/aspire/util.clj
@@ -1,4 +1,5 @@
-(ns aspire.util)
+(ns aspire.util
+  (:require [aspire.sqldb :as a-sql]))

 (defn output!
   "Call output! instead of using prn. Respects --verbose. Returns nil."
@@ -13,3 +14,18 @@
   (let [transform-fn (partial keyword-in-ns target-ns)]
     (map transform-fn (flatten keywords))))

+(defn get-config!
+  "Get the specified config key from the DB."
+  [key]
+  (:value
+   (first
+    (a-sql/select! {:select [:value]
+                    :from [:config]
+                    :where [:= :key key]}))))
+
+(defn set-config!
+  "Set the value of the specified config.key in the DB, inserting a new row or updating as appropriate."
+  [key value]
+  (if-let [_ (get-config! key)]
+    (a-sql/update! "UPDATE config SET value = ? WHERE key = ?" [value key])
+    (a-sql/update! "INSERT INTO config (value, key) VALUES (?, ?)" [value key])))


Add trips loading

Add trips loading

--- env/dev/clj/gtfve/datomic.clj
+++ env/dev/clj/gtfve/datomic.clj
@@ -203,6 +203,36 @@
                [])
        (d/transact conn)))

+;; Trips ;;
+;;;;;;;;;;;
+
+(def trips-header-keys
+  {"route_id" :trip/route
+   "service_id" :trip/service
+   "trip_short_name" :trip/short-name
+   "trip_headsign" :trip/headsign
+   "direction_id" :trip/direction
+   "block_id" :trip/block
+   "shape_id" :trip/shape
+   "trip_id" :trip/id})
+
+(def trips-val-transforms
+  {:trip/route #(vector :route/id %)
+   :trip/service #(vector :service/id %)
+   :trip/shape #(if (not (empty? %))
+                  (vector :shape/id %)
+                  nil)
+   :trip/direction #(if (not (empty? %))
+                      (->> % read-string zero? not)
+                      nil)
+   :trip/wheelchair-accessible? read-string})
+
+(defn load-trips! [path conn]
+  (->> path
+       (csv-tx trips-header-keys trips-val-transforms)
+       (map assoc-temp-id)
+       (d/transact conn)))
+
 ;; Frequencies ;;
 ;;;;;;;;;;;;;;;;;

@@ -232,4 +262,5 @@
   (load-stops! (str path "stops.txt") conn)
   (load-calendar! (str path "calendar.txt") conn)
   (load-shapes! (str path "shapes.txt") conn)
+  (load-trips! (str path "trips.txt") conn)
   (load-frequencies! (str path "frequencies.txt") conn))


session test cases

session test cases

--- cloc-web/test/cloc_web/core_test.clj
+++ cloc-web/test/cloc_web/core_test.clj
@@ -36,8 +36,16 @@
 (use-fixtures :each setup-each)

 (deftest register-with-unauthorized-user
-  (is 401 (:status (client/post (str url "/user/repo/register") {:accept :json
-                                                                 :throw-exceptions false}))))
+  (testing "no session"
+    (is 401 (:status (client/post (str url "/user/repo/register") {:accept :json
+                                                                   :throw-exceptions false}))))
+
+  (testing "invalid session id"
+    (with-redefs [clj-http.client/get (fn [& param] {:status 400
+                                                     :body {:error ""}})]
+      (is 401 (:status (client/post (str url "/user/repo/register") {:accept :json
+                                                                     :throw-exceptions false
+                                                                     :cookies {"session_id" {:discard true :value (jwt-token "debug_token" {:expires (-> 28 days)})}}}))))))

 (deftest register-with-authorized-user
   (with-redefs [clj-http.client/get (fn [& param] {:status 200
@@ -45,3 +53,4 @@
     (is 200 (:status (client/post (str url "/user/repo/register") {:accept :json
                                                                    :throw-exceptions false
                                                                    :cookies {"session_id" {:discard true :value (jwt-token "debug_token" {:expires (-> 28 days)})}}})))))
+


add [:synsem :essere] to head-pre-checks

--- src/babel/over.cljc
+++ src/babel/over.cljc
@@ -44,6 +44,7 @@
 (defn head-pre-checks [parent child]
   (or
    (check-vals parent child [:head :synsem :cat]            [:synsem :cat])
+   (check-vals parent child [:head :synsem :essere]         [:synsem :essere])
    (check-vals parent child [:head :synsem :subcat :1 :cat] [:synsem :subcat :1 :cat])
    (check-vals parent child [:head :synsem :subcat :2 :cat] [:synsem :subcat :2 :cat])
    (check-vals parent child [:head :synsem :infl]           [:synsem :infl])


No need to pass :value to utils/edit-input

--- frontend/components/org_settings.cljs
+++ frontend/components/org_settings.cljs
@@ -517,8 +517,7 @@
                    ;; FIXME These edits are painfully slow with the whitespace compiled Javascript
                    :on-change #(utils/edit-input controls-ch
                                                  (conj state/org-plan-path :billing_email)
-                                                 %
-                                                 :value (.. % -target -value))}]]]
+                                                 %)}]]]
                [:div.control-group
                 [:label.control-label {:for "billing_name"} "Billing name"]
                 [:div.controls
@@ -529,8 +528,7 @@
                    ;; FIXME These edits are painfully slow with the whitespace compiled Javascript
                    :on-change #(utils/edit-input controls-ch
                                                  (conj state/org-plan-path :billing_name)
-                                                 %
-                                                 :value (.. % -target -value))}]]]
+                                                 %)}]]]
                [:div.control-group
                 [:label.control-label
                  {:for "extra_billing_data"}
@@ -545,8 +543,7 @@
                    ;; FIXME These edits are painfully slow with the whitespace compiled Javascript
                    :on-change #(utils/edit-input controls-ch
                                                  (conj state/org-plan-path :extra_billing_data)
-                                                 %
-                                                 :value (.. % -target -value))}]]]
+                                                 %)}]]]
                [:div.control-group
                 [:div.controls
                  (forms/managed-button


Refactor

Refactor

--- src/braid/client/dispatcher.cljs
+++ src/braid/client/dispatcher.cljs
@@ -67,7 +67,7 @@
   (helpers/set-new-message state thread-id content))

 (defmethod handler :display-error [state [_ args]]
-  (apply helpers/display-error (concat [state] args)))
+  (apply helpers/display-error state args))

 (defmethod handler :set-message-failed [state [_ message]]
   (helpers/set-message-failed! state message))


CMR-8376: update docstring for approved-pipeline-documents

--- common-lib/src/cmr/common/config.clj
+++ common-lib/src/cmr/common/config.clj
@@ -220,8 +220,12 @@
   "This is the feature toggle for the new document pipeline prototype, as well as serving as
    the base truth list of approved document types.
    This string should contain JSON that looks like:
-   {'grid': ['0.0.1'],
-    'variable': ['1.8.0']}"
+   {\"grid\": [\"0.0.1\"],
+    \"variable\": [\"1.8.0\"],
+    \"dataqualitysummary\": [\"1.0.0\"],
+    \"orderoption\": [\"1.0.0\"],
+    \"serviceentry\": [\"1.0.0\"],
+    \"serviceoption\": [\"1.0.0\"]}"
   {:default ""
    :parser #(json/parse-string % true)})


feature: Add delete-datastore-raw to datastore features

--- src/clj/datasplash/datastore.clj
+++ src/clj/datasplash/datastore.clj
@@ -28,6 +28,15 @@
                    (cond-> query (.withQuery query))
                    (cond-> namespace (.withNamespace namespace))
                    (cond-> num-query-split (.withNumQuerySplits num-query-split)))]
+    (apply-transform pcoll ptrans named-schema opts)))
+
+(defn delete-datastore-raw
+  "delete a pcoll of already generated datastore entity from datastore"
+  [{:keys [project-id] :as options} pcoll]
+  (let [opts (assoc options :label :delete-datastore-raw)
+        ptrans (-> (DatastoreIO/v1)
+                   (.deleteEntity)
+                   (.withProjectId project-id))]
     (apply-transform pcoll ptrans named-schema opts)))

 (declare value->clj)


Add a field for the suggested hyphenation

--- src/cljs/hyphen_keeper/core.cljs
+++ src/cljs/hyphen_keeper/core.cljs
@@ -12,12 +12,12 @@
     :spelling 1
     :word ""
     :hyphenation ""
-    :official-hyphenation ""}))
+    :suggested-hyphenation ""}))

 (def spelling (reagent/cursor app-state [:spelling]))
 (def word (reagent/cursor app-state [:word]))
 (def hyphenation (reagent/cursor app-state [:hyphenation]))
-(def official-hyphenation (reagent/cursor app-state [:official-hyphenation]))
+(def suggested-hyphenation (reagent/cursor app-state [:suggested-hyphenation]))

 (defn update-hyphenations! [f & args]
   (apply swap! app-state update-in [:hyphenations] f args))
@@ -64,7 +64,7 @@
   (ajax/GET "/api/hyphenate"
             :params {:word word :spelling spelling}
             :handler (fn [hyphenated] (do
-                                        (swap! app-state assoc :official-hyphenation hyphenated)
+                                        (swap! app-state assoc :suggested-hyphenation hyphenated)
                                         (swap! app-state assoc :hyphenation hyphenated)))
             :error-handler (fn [details]
                              (.warn js/console
@@ -120,7 +120,7 @@
                  (reset! hyphenation ""))
     :disabled (when (or (string/blank? @word)
                         (not (hyphenation-valid? @hyphenation))
-                        (= @hyphenation @official-hyphenation))
+                        (= @hyphenation @suggested-hyphenation))
                 "disabled")}
    "Add"])

@@ -134,10 +134,23 @@
     [:option {:value 0} "Old Spelling"]
     [:option {:value 1} "New Spelling"]]])

+(defn suggested-hyphenation-field []
+  (let [id "suggestedHyphenation"
+        label "Suggested Hyphenation"]
+    [:div.form-group
+     [:label {:for id} label]
+     [:input.form-control
+      {:id id
+       :type "text"
+       :placeholder label
+       :disabled "disabled"
+       :value @suggested-hyphenation}]]))
+
 (defn new-hyphenation []
   [:div.form
    [spelling-filter]
    [word-field]
+   [suggested-hyphenation-field]
    [hyphenation-field]
    [hyphenation-add-button]])


ClojureScript compatible last-move-to-san.

--- src/clojure/clj_chess/board.cljc
+++ src/clojure/clj_chess/board.cljc
@@ -161,7 +161,8 @@
   "Translate the last move played to reach this board position to short
   algebraic notation."
   [board]
-  (.lastMoveToSAN board))
+  #?(:clj (.lastMoveToSAN board)
+     :cljs (move-to-san (.-parent board) (last-move board))))

 (defn do-move
   "Do a move (encoded as an integer) from the current board, and returns the


[n.d.sqlite] Add entity-from-cursor function

--- src/clojure/neko/data/sqlite.clj
+++ src/clojure/neko/data/sqlite.clj
@@ -210,6 +210,16 @@

 (def db-query query)

+(defn entity-from-cursor
+  "Reads a single row from Cursor object. Columns should be a vector of pairs
+  where first value is column name and the second is its type."
+  [cursor columns]
+  (reduce-kv
+   (fn [data i [column-name type]]
+     (assoc data column-name
+            (get-value-from-cursor cursor i type)))
+   {} columns))
+
 (defn seq-cursor
   "Turns data from Cursor object into a lazy sequence. Takes database
   argument in order to get schema from it."
@@ -236,11 +246,7 @@
                   (lazy-seq
                    (if (.isAfterLast cursor)
                      (.close cursor)
-                     (let [v (reduce-kv
-                              (fn [data i [column-name type]]
-                                (assoc data column-name
-                                       (get-value-from-cursor cursor i type)))
-                              {} columns)]
+                     (let [v (entity-from-cursor cursor columns)]
                        (.moveToNext cursor)
                        (cons v (seq-fn))))))]
      (seq-fn))))
@@ -259,7 +265,7 @@
   "Executes a SELECT statement against the database on a column and returns a
   scalar value. `column` can be either a keyword or string-keyword pair where
   string denotes the aggregation function."
-  [^TaggedDatabase tagged-db table-name column where]
+  [^TaggedDatabase tagged-db column table-name where]
   (let [[aggregator column] (if (vector? column)
                               column [nil column])
         type (get-in (.schema tagged-db)


do not wrap API calls into site-defaults, but use secure-api-defaults.

--- core/src/gorillalabs/tesla/component/handler.clj
+++ core/src/gorillalabs/tesla/component/handler.clj
@@ -76,11 +76,10 @@
   (-> handler
       (wrap-exception-handling)
       (wrap-enforce-json-content-type)
-      (ring-defaults/wrap-defaults ring-defaults/site-defaults)
+      (ring-defaults/wrap-defaults ring-defaults/secure-api-defaults)
       (wrap-json-body)
       (wrap-json-params)
-      (wrap-json-response)
-      ))
+      (wrap-json-response)))

 (defn wrap-secure-api [handler authorization]
   (-> handler
@@ -106,7 +105,7 @@
           :cookies false
           :static false
           :proxy true)
-        (assoc-in [:security :hsts] false)
-        (assoc-in [:security :ssl-redirect] false)
+        (assoc-in [:security :hsts] false)        ;; TODO: YES!
+        (assoc-in [:security :ssl-redirect] false) ;; TODO: YES!
         )))


Refactor new completion functionality.

Refactor new completion functionality.

--- src/cli4clj/cli.clj
+++ src/cli4clj/cli.clj
@@ -70,13 +70,15 @@
                  (.setPrompt prompt-string))
         arg-completers (reduce
                          (fn [v k]
-                           (if (or (not (nil? (get-in cmds [k :fn-args])))
-                                   (not (nil? (get-in cmds [k :completion-hint]))))
-                             (conj v
-                                   (ArgumentCompleter.
-                                     [(StringsCompleter. (conj (vec (map name (cmd-aliases k))) (name k)))
-                                      (StringsCompleter. [(str "Arguments: " (get-in cmds [k :fn-args]) "\n")
-                                                          (str "Hint: " (get-in cmds [k :completion-hint]))])]))))
+                           (let [fn-args (get-in cmds [k :fn-args])
+                                 completion-hint (get-in cmds [k :completion-hint])]
+                             (if (or (not (nil? fn-args))
+                                     (not (nil? completion-hint)))
+                               (conj v
+                                     (ArgumentCompleter.
+                                       [(StringsCompleter. (conj (vec (map name (cmd-aliases k))) (name k)))
+                                        (StringsCompleter. [(str "Arguments: " fn-args "\n")
+                                                            (str "Hint: " completion-hint)])])))))
                          []
                          (keys cmd-aliases))
         _ (doseq [arg-compl arg-completers]


Complete the examples for chapter 7

Complete the examples for chapter 7

--- src/clojure/clojure_walkthrough/cjia/ch07_xx.clj
+++ src/clojure/clojure_walkthrough/cjia/ch07_xx.clj
@@ -235,3 +235,23 @@
 (assert-true (< (* 4 5) (* 2 5))) ;; java.lang.RuntimeException
                                   ;; (* 4 5) is not < 10
 (macroexpand-1 '(assert-true (>= (* 2 4) (/ 18 2)))) ;; (clojure.core/let [rhsv__20666__auto__ (/ 18 2) ret__20667__auto__ (>= (* 2 4) (/ 18 2))] (clojure.core/if-not ret__20667__auto__ (throw (java.lang.RuntimeException. (clojure.core/str (quote (* 2 4)) " is not " (quote >=) " " rhsv__20666__auto__))) true))
+
+;; What if invalid expression are passed in
+(defmacro assert-true [test-expr]
+  (if-not (= 3 (count test-expr))
+    (throw (RuntimeException.
+            "Argument must be of the form (operator test-expr expected-expr)")))
+  (if-not (some #{(first test-expr)} '(< > <= >= = not=))
+    (throw (RuntimeException.
+            "Operator must be one of < > <= >= = not=")))
+  (let [[operator lhs rhs] test-expr]
+    `(let [rhsv# ~rhs ret# ~test-expr]
+       (if-not ret#
+         (throw (RuntimeException.
+                 (str '~lhs " is not " '~operator " " rhsv#)))
+         true))))
+
+;; (assert-true (<> (* 2 4) (/ 18 2) (+ 2 5))) ;; => Argument must be of the form (operator test-expr expected-expr)
+
+;; (assert-true (<> (* 2 4) (/ 16 2))) ;; => Operator must be one of < > <= >= = not=
+


Transform to string repr the params dict on resolve func.

And improve its performance.

--- src/bide/core.cljs
+++ src/bide/core.cljs
@@ -28,6 +28,19 @@
             [clojure.string :as str]
             [goog.events :as e])
   (:import goog.History))
+
+;; --- Protocols
+
+(defprotocol IRouter
+  (-navigare [_ loc params])
+  (-replace-location [_ loc params]))
+
+(defprotocol IPathRepr
+  (-repr [_] "Return a representation of object in path."))
+
+(extend-protocol IPathRepr
+  object (-repr [it] (str it))
+  number (-repr [it] it))

 ;; --- Low Level Routes API

@@ -70,14 +83,14 @@
    (resolve router name {}))
   ([router name params]
    {:pre [(router? router)]}
-   (let [params (clj->js params)]
+   (let [params (reduce-kv (fn [m k v]
+                             (aset m (key->js k) (-repr v))
+                             m)
+                           (js-obj)
+                           params)]
      (rtr/resolve router name params))))

 ;; --- Browser History Binding API
-
-(defprotocol IRouter
-  (-navigare [_ loc params])
-  (-replace-location [_ loc params]))

 (defn start!
   "Starts the bide routing handling using the goog.History


Added automatic preconditioning for all-closed-sets{,-in-family}

if a set as base set is given.

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/base.clj
+++ src/conexp/base.clj
@@ -128,10 +128,13 @@
   ([G clop]
      (all-closed-sets G clop #{}))
   ([G clop initial]
-     (binding [subelts (memoize subelts)]
-       (take-while identity
-		   (iterate (partial next-closed-set G clop)
-			    (clop initial))))))
+     (let [G (if (set? G)
+	       (improve-basic-order G clop)
+	       G)]
+       (binding [subelts (memoize subelts)]
+	 (take-while identity
+		     (iterate (partial next-closed-set G clop)
+			      (clop initial)))))))

 (defn all-closed-sets-in-family
   "Computes all closed sets of a given closure operator on a given set
@@ -141,11 +144,14 @@
   ([predicate G clop]
      (all-closed-sets-in-family predicate G clop #{}))
   ([predicate G clop initial]
-     (binding [subelts (memoize subelts)]
-       (let [start (first (filter predicate (all-closed-sets G clop initial)))]
-	 (take-while identity
-		     (iterate (partial next-closed-set-in-family predicate G clop)
-			      start))))))
+     (let [G (if (set? G)
+	       (improve-basic-order G clop)
+	       G)]
+       (binding [subelts (memoize subelts)]
+	 (let [start (first (filter predicate (all-closed-sets G clop initial)))]
+	   (take-while identity
+		       (iterate (partial next-closed-set-in-family predicate G clop)
+				start)))))))

 ;;; Common Math Algorithms


Improved implementation of Next Closure

Improved implementation of Next Closure

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/base.clj
+++ src/conexp/base.clj
@@ -108,17 +108,18 @@
      \\mathrm{clop}(A \\cap \\set{1, \\ldots, i-1}) \\in \\mathcal{F}.
   \\]"
   [predicate G clop A]
-  (loop [i-s (reverse G)]
+  (loop [i-s (reverse G),
+         A   (set A)]
     (if (empty? i-s)
       nil
       (let [i (first i-s)]
         (if (contains? A i)
-          (recur (rest i-s))
-          (let [oplus-A (oplus G clop A i)]
-            (if (and (lectic-<_i G i A oplus-A)
-                     (predicate oplus-A))
-              oplus-A
-              (recur (rest i-s)))))))))
+          (recur (rest i-s) (disj A i))
+          (let [clop-A (clop (conj A i))]
+            (if (and (lectic-<_i G i A clop-A)
+                     (predicate clop-A))
+              clop-A
+              (recur (rest i-s) A))))))))

 (defn improve-basic-order
   "Improves basic order on the sequence base, where the closure operator


cleanup

cleanup

--- docker/user_profile/profiles.clj
+++ docker/user_profile/profiles.clj
@@ -1,35 +0,0 @@
-{:user
- {:plugins [[cider/cider-nrepl "0.11.0-SNAPSHOT"]
-                  [refactor-nrepl "2.0.0-SNAPSHOT"]]
-
-  :dependencies [[org.clojure/tools.nrepl "0.2.12"]
-                 [org.clojure/tools.namespace "0.2.11"]
-                 [spyscope "0.1.5"]
-                 [leiningen #=(leiningen.core.main/leiningen-version)]
-                 [alembic "0.3.2"]
-                 [im.chit/vinyasa "0.4.2"]
-                 [io.aviso/pretty "0.1.24"]]
-
-  :injections [(require 'spyscope.core)
-               (require '[vinyasa.inject :as inject])
-               (require 'io.aviso.repl)
-               (inject/in ;; default injected namespace is '.'
-                [vinyasa.inject :refer [inject [in inject-in]]]
-                [vinyasa.lein :exclude [*project*]]
-
-                ;; imports all functions in vinyasa.pull
-                [alembic.still [distill pull]]
-
-                ;; inject into clojure.core
-                clojure.core
-                [vinyasa.reflection .> .? .* .% .%> .& .>ns .>var]
-
-                ;; inject into clojure.core with prefix
-                clojure.core >
-                [clojure.pprint pprint]
-                [clojure.java.shell sh])]
-
-  :repl-options {:nrepl-middleware [cider.nrepl.middleware.pprint/wrap-pprint
-                                    cider.nrepl.middleware.pprint/wrap-pprint-fn]
-                 :host "0.0.0.0"}
-  }}


args -> params in utils

args -> params in utils

--- src/cake/utils.clj
+++ src/cake/utils.clj
@@ -41,12 +41,12 @@
       (ant ExecTask (assoc opts :executable "sudo")
 	   (args (apply vector "-S" arglist))))))

-(defn cake-exec [& args]
+(defn cake-exec [& params]
   (ant ExecTask {:executable "ruby" :dir *root* :failonerror true}
-       (args *script* args (str "--project=" *root*))))
+       (args *script* params (str "--project=" *root*))))

-(defn git [& my-args]
+(defn git [& params]
   (if (.exists (file ".git"))
     (ant ExecTask {:executable "git" :dir *root* :failonerror true}
-      (args my-args))
+      (args params))
     (println "warning:" *root* "is not a git repository")))


Alternative pretty printed output

Alternative pretty printed output

--- src/emender_jenkins/rest_api.clj
+++ src/emender_jenkins/rest_api.clj
@@ -48,6 +48,7 @@
     [response]
     (-> (http-response/response (json/write-str response))
         (http-response/content-type "application/json")))
+   ;(-> (http-response/response (with-out-str (json/pprint response)))

 (defn send-plain-response
     [response]


allow uppercase letters in jar names

allow uppercase letters in jar names

--- src/clojars/db.clj
+++ src/clojars/db.clj
@@ -208,8 +208,8 @@
                   :version    version})))

 (defn add-jar [account jarmap & [check-only]]
-  (when-not (re-matches #"^[a-z0-9-_.]+$" (:name jarmap))
-    (throw (Exception. (str "Jar names must consist solely of lowercase "
+  (when-not (re-matches #"^[a-zA-Z0-9-_.]+$" (:name jarmap))
+    (throw (Exception. (str "Jar names must consist solely of "
                             "letters, numbers, hyphens and underscores."))))
   (transaction
    (if check-only
@@ -234,4 +234,4 @@
                       (or offset 0)]]
                     :results)]
     ;; TODO: do something less stupidly slow
-    (vec (map #(find-jar (:group_name %) (:jar_name %)) r))))+    (vec (map #(find-jar (:group_name %) (:jar_name %)) r))))


The docstring on hellhound.message ns has been improved

--- core/src/cljc/hellhound/message.cljc
+++ core/src/cljc/hellhound/message.cljc
@@ -1,7 +1,43 @@
 (ns hellhound.message
+  "HellHound components communicate with each other via their input and
+  output streams by passing values to each other that satisfy `Message`
+  protocol (checkout `hellhound.message.protocols` for more information).
+
+  By default HellHound extends only IPersistentMap with the protocol
+  mentioned above. So by default each message is a hashmap which has
+  a unique **ID** attached to it. Also, Each message has a stack that
+  is dedicated to store a set of functions known as **resolvers**.
+  A resolver is a function which is going to get called in order (FILO)
+  when the workflow of the message has ended. The purpose of resolvers
+  are to provide a simple solution for async calls on several components.
+
+  For example imaging a web server component which wants to send the
+  response to the client. It need to send the request to the output
+  stream and based on the system workflow the request would go through
+  several components and gather the necessary data for the response.
+  But the webserver component should be able to wait for the response
+  data to be available to it. There is two solution for this problem.
+
+  The first solution is to use a `hellhound.async/deferred` as the
+  response and put it along side of the request in the message.
+  and resolve all deferred values in the incomming messages with
+  the response data in the incoming message. So in this case
+  we would have loop in our workflow which is quite fine.
+
+  The other solution is to return a `hellhound.async/deferred` again
+  but instead of resolving it later based on incoming messages of
+  the component it can set a resolver for that deferred value in the
+  message itself. So when the workflow ends the resolver will automatically
+  resolve the deferred value with the message as the argument.
+
+  For source component which is the entry point of a workflow the first
+  solution seems like a better idea but for a component which is
+  in the middle of a workflow second solution is much simpler and nicer.
+  "
   (:require
    [hellhound.message.protocols :as impl]
    [hellhound.message.impl.message]))
+

 (def id impl/id)
 (def resolvers impl/resolvers)
@@ -15,6 +51,7 @@
   ([initial-value]
    (impl/init initial-value)))

+
 (comment
   (impl/resolvers (enqueue-resolver (create) #(println %)))


Add "-client" to JVM opts for quickstart projects.

--- streamparse/bootstrap/project/project.jinja2.clj
+++ streamparse/bootstrap/project/project.jinja2.clj
@@ -4,10 +4,10 @@
   :aot :all
   :target-path "_build"
   :min-lein-version "2.0.0"
+  :jvm-opts ["-client"]
   :dependencies [[org.apache.storm/storm-core "0.9.1-incubating"]
                  [com.parsely/streamparse "0.0.1-SNAPSHOT"]
                  [org.clojure/clojure "1.5.1"]
                  [org.clojure/data.json "0.2.4"]
-                 [org.clojure/tools.cli "0.3.1"]
-                 ]
+                 [org.clojure/tools.cli "0.3.1"]]
   )


Docstring about docstrings.

Docstring about docstrings.

--- src/active/clojure/condition.cljc
+++ src/active/clojure/condition.cljc
@@ -257,7 +257,10 @@
   type `<condition-type>` or any of its subtypes.

   Each `<accessor>` is bound to a function that extracts the
-  corresponding field from a condition of type `<condition-type>`."
+  corresponding field from a condition of type `<condition-type>`.
+
+  `:doc` properties attached to the metadata of `<condition-type>` and
+  `the <field>s will yield proper docstrings for the names defined by this form."
   [?condition-type ?supertype ?constructor ?predicate & ?field-specs]
   (let [?field-pairs (if (and (= 1 (count ?field-specs))
                               (vector? (first ?field-specs)))


added creating of exchanges of around world amqp services.

--- test/edeposit/amqp/kramerius/components_test.clj
+++ test/edeposit/amqp/kramerius/components_test.clj
@@ -36,7 +36,12 @@
               ]
           (let [ch (-> :marcxml2mods connection :ch)]
             (lq/declare ch "converter" {:durable true :auto-delete false})
+            (le/topic ch "convert-to-mods" {:durable true})
             (lq/bind ch "converter"  "convert-to-mods" {:routing-key "request" :durable true}))
+          (let [ch (-> :storage connection :ch)]
+            (lq/declare ch "daemon" {:durable true :auto-delete false})
+            (le/topic ch "export" {:durable true})
+            (lq/bind ch "daemon" "export" {:routing-key "request" :durable true}))
           (let [
                 marcxml2mods (-> (c/amqp-middleware
                                   {:exchanges [:convert-to-mods]


s/debug/trace/

s/debug/trace/

--- src/babel/english/morphology.cljc
+++ src/babel/english/morphology.cljc
@@ -813,7 +813,7 @@
                                    merge-fn (:merge-fn path-and-merge-fn)]
                                ;; a lexeme-kv is a pair of a key and value. The key is a string (the word's surface form)
                                ;; and the value is a list of lexemes for that string.
-                               (log/debug (str "'" (first lexeme-kv) "' looking at path: " path))
+                               (log/trace (str "'" (first lexeme-kv) "' looking at path: " path))
                                (mapcat (fn [lexeme]
                                          ;; this is where a unify/dissoc that supported
                                          ;; non-maps like :top and :fail, would be useful:
@@ -907,7 +907,6 @@
                                 :english {:infl :past
                                           :english (get-in val [:english :past :3plur])}})}

-
                             {:path [:english :past]
                              :merge-fn
                              (fn [val]


fix namespace for generate-all

fix namespace for generate-all

--- src/babel/italiano/benchmark.cljc
+++ src/babel/italiano/benchmark.cljc
@@ -5,7 +5,7 @@
             [babel.italiano.morphology :as morph :refer [analyze-regular fo replace-patterns]]
             [babel.italiano.morphology.nouns :as nouns]
             [babel.italiano.morphology.verbs :as verbs]
-            [babel.italiano.workbook :refer [analyze generate generate-all parse]]
+            [babel.italiano.workbook :refer [analyze generate parse]]
             [babel.parse :as parse]
             #?(:cljs [cljs.test :refer-macros [deftest is]])
             #?(:clj [clojure.tools.logging :as log])


Adjust indentation.

Adjust indentation.

--- src/dsbdp/main.clj
+++ src/dsbdp/main.clj
@@ -154,6 +154,7 @@
                        "self-adaptive-high-throughput" (utils/combine-proc-fns-vec
                                                          @fn-mapping
                                                          synthetic-high-throughput-self-adaptivity-processing-fns)))
+          _ (println "Proc-fns:" @proc-fns)
           pipeline (if (and
                          (not (nil? in-data))
                          (not (.endsWith scenario "-direct")))
@@ -183,11 +184,11 @@
                         in-data
                         (> batch-delay 0)
                         (> batch-size 0)) (let [in-fn (get-in-fn pipeline)]
-                                           (fn []
-                                             (doseq [i (repeat batch-size 0)]
-                                               (in-fn in-data)
-                                               (.inc in-cntr))
-                                             (sleep batch-delay)))
+                                            (fn []
+                                              (doseq [i (repeat batch-size 0)]
+                                                (in-fn in-data)
+                                                (.inc in-cntr))
+                                              (sleep batch-delay)))
                       in-data (let [in-fn (get-in-fn pipeline)]
                                 (fn []
                                   (in-fn in-data)


Add commit history and dates to get-file-by-path

--- src/extremo/db.cljs
+++ src/extremo/db.cljs
@@ -10,20 +10,10 @@
       (nodegit.Repository.open)
       (.catch #(js/console.error "Something went wrong opening repo: " %))))

-(defn get-file-by-path [filepath]
-  (let [rv (transient {})]
-    (-> (open-repo)
-        (.then #(.getMasterCommit % "d909ade91aae7970a34ba91e800493f9bac7d473"))
-        (.then #(do (assoc! rv :date (.date %))
-                    (.getEntry % filepath)))
-        (.then #(do (assoc! rv :name (.name %) :sha (.sha %))
-                    (.getBlob %)))
-        (.then #(persistent! ( assoc! rv :rawsize (.rawsize %)
-                                         :blob (.toString %)))))))
-
-(-> (get-file-by-path "test.md")
-    (.then #(js/console.log (clj->js %)))
-    (.catch #(js/console.error %)))
+(defn get-entry-by-path [repo filepath]
+  (-> repo
+      (.then #(.getMasterCommit %))
+      (.then #(.getEntry % filepath))))

 (defn get-file-history
   [filepath]
@@ -44,9 +34,26 @@
                             (mapv #(assoc
                                      {}
                                      :sha (.sha (.-commit %))
-                                     :date (.date (.-commit %))
-                                     :commit (.-commit %)) commits)))
+                                     :date (.date (.-commit %))) commits)))
                    (.catch #(js/console.error %)))))))
+
+(defn build-entry-data [entry]
+  (let [rv (transient {})]
+    (assoc! rv :name (.name entry) :sha (.sha entry))
+    (-> (js/Promise.all [(.getBlob entry) (get-file-history (.path entry))])
+        (.then (fn [[blob file-history]]
+                 (persistent! (assoc! rv :rawsize (.rawsize blob)
+                                         :blob (.toString blob)
+                                         :updated_at (:date (first file-history))
+                                         :created_at (:date (last file-history))
+                                         :history file-history)))))))
+
+(defn get-file-by-path [filepath]
+  (let [rv (transient {})]
+    (-> (open-repo)
+        (.then #(.getMasterCommit %))
+        (.then #(.getEntry % filepath))
+        (.then #(build-entry-data %)))))

 ;; (-> (open-repo)
 ;;     (.then #(.getMasterCommit %))
@@ -55,3 +62,9 @@
 ;;              (-> (.walk tree)
 ;;                  (.on "entry" #(js/console.log (.path %)))
 ;;                  (.start)))))
+
+;; (-> (get-file-history "test.md")
+;;     (.then #(js/console.log (clj->js %))))
+
+(-> (get-file-by-path "test.md")
+    (.then #(js/console.log (clj->js %))))


specify bytecode version maximum bound

specify bytecode version maximum bound

--- dev-resources/insn/test.clj
+++ dev-resources/insn/test.clj
@@ -15,6 +15,8 @@
   (->> (.split (System/getProperty "java.specification.version")
                "\\.")
        last Long/valueOf))
+
+(def max-version 12)

 (when (>= jvm 9)
   (require 'insn.v9-bytecode-test))
@@ -38,7 +40,7 @@
 (defn -main []
   (let [test-ns? #(re-find #"^insn\..+-test$" (str (ns-name %)))
         nses (filter test-ns? (all-ns))
-        versions (vec (range 5 (inc jvm)))]
+        versions (vec (range 5 (min (inc max-version) (inc jvm))))]
     (test/with-test-out
       (print "{")
       (pr :jvm jvm, :clj clj, :bytecode versions)


Fix scheduler? predicate on cljs.

Fix scheduler? predicate on cljs.

--- src/beicon/core.cljc
+++ src/beicon/core.cljc
@@ -122,7 +122,8 @@
 (defn scheduler?
   "Check if the provided value is Scheduler instance."
   [v]
-  (instance? Scheduler v))
+  #?(:clj (instance? Scheduler v)
+     :cljs (and v (fn? (.-schedule v)))))

 (defn subject?
   "Check if the provided value is Subject instance."


Add pr-log and log functions

Add pr-log and log functions

--- src/beicon/core.cljs
+++ src/beicon/core.cljs
@@ -422,6 +422,18 @@
    (.bufferWithCount ob n))
   ([n skip ob]
    (.bufferWithCount ob n skip)))
+
+(defn pr-log
+  ([ob]
+   (on-value ob #(println (pr-str %))))
+  ([prefix ob]
+   (on-value ob #(println (str prefix (pr-str %))))))
+
+(defn log
+  ([ob]
+   (on-value ob #(println %)))
+  ([prefix ob]
+   (on-value ob #(println (str prefix %)))))

 (defn to-atom
   "Materialize the observable sequence into an atom."


Add props

Add props

--- src/fugue/ide.cljs
+++ src/fugue/ide.cljs
@@ -55,11 +55,11 @@
       (assoc :buffer (get-in state [:files name]))
       (assoc :curr-tab name)))

-(defn counter []
+(defn counter [name]
   (let [state (r/atom 0)]
     (fn []
       [:button {:on-click #(swap! state inc)}
-       (str "Clicked " @state " times!")])))
+       (str "Clicked " @state " times by " name)])))

 (defn ide [eval-fn]
   (let [state (r/atom init-state)]


Add accessor functions for subject, predicate, object - to reduce dependencies on grafter.rdf.protocols - which should be more for internal use an implementers.

--- src/grafter/rdf.clj
+++ src/grafter/rdf.clj
@@ -161,6 +161,23 @@
   [this & {:keys [format] :as options}]
   (pr/to-statements this options))

+(defn subject
+  "Return the RDF subject from a statement."
+  [statement]
+  (pr/subject statement))
+
+(defn predicate [statement]
+  "Return the RDF predicate from a statement."
+  (pr/predicate statement))
+
+(defn object [statement]
+  "Return the RDF object from a statement."
+  (pr/object statement))
+
+(defn context [statement]
+  "Return the RDF context from a statement."
+  (pr/context statement))
+
 (defn dataset [dataset-uri data-graph date title label comment description email]
   (let [metadata-graph (str data-graph "/metadata")]


Recruiting Trip has to shuffle R&D

Recruiting Trip has to shuffle R&D

--- src/clj/game/cards-operations.clj
+++ src/clj/game/cards-operations.clj
@@ -237,7 +237,8 @@
                                     state side
                                     (rt total (dec left) (cons (:title target) selected))
                                     card nil))}
-                    {}))]
+                    {:effect (req (shuffle! state :corp :deck))
+                     :msg (msg "shuffle R&D")}))]
    {:prompt "How many sysops?" :choices :credit :msg (msg "search for " target " sysops")
     :effect (effect (resolve-ability (rthelp target target []) card nil))})


Fix another problem with the missing products calculation

--- src/clj/ikea_clojure_cup/pack.clj
+++ src/clj/ikea_clojure_cup/pack.clj
@@ -35,15 +35,10 @@
                      product-id)]
     (- product-id (mod product-id 100))))

-(defn get-missing-products [requested-packages packing-details]
-  (let [all (set (map #(-> % :id extract-product-id-from-package-id str) requested-packages))
-        packed (set (map (comp str extract-product-id-from-package-id :id) (-> packing-details first :items)))
-        missing (clojure.set/difference all packed)
-        id-package-map (reduce (fn [m {:keys [id] :as p}]
-                                 (assoc m (str id) p))
-                               {}
-                               requested-packages)]
-    (vals (filter (fn [[k v]] (missing k)) id-package-map))))
+(defn get-missing-products [missing-packages]
+  (->> (group-by (comp extract-product-id-from-package-id :id) missing-packages)
+       (map (comp first val))
+       (set)))

 (defn get-missing-packages [requested-packages packing-details]
   (let [all (set (map #(-> % :id str) requested-packages))
@@ -75,8 +70,9 @@
     (merge {:result result
             :details packing-details}
            (when (= :partial result)
-             {:missing (get-missing-products packages packing-details)
-              :packages-missing (get-missing-packages packages packing-details)})
+             (let [pkgs (get-missing-packages packages packing-details)]
+               {:missing (get-missing-products pkgs)
+                :packages-missing pkgs}))
            (when-not (= :no result)
              {:preview {:bins bins :items items}}))))


valid-creditcard?

valid-creditcard?

--- src/clojure/nossal/shop/spec.cljc
+++ src/clojure/nossal/shop/spec.cljc
@@ -2,6 +2,7 @@
   (:require [clojure.spec.alpha :as s]))

 (defn valid-luhn? [pan]
+  "https://en.wikipedia.org/wiki/Luhn_algorithm#Clojure"
   (letfn [(char->int [c] (- (int c) (int \0)))
           (mod-10? [n] (zero? (mod n 10)))
           (sum-luhn-pair [[m n]]
@@ -15,6 +16,8 @@
          (apply +)
          mod-10?)))

+(defn valid-creditcard? [number]
+  (and (= 16 (count number)) (valid-luhn? number)))

 (def email-regex #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$")
 (def phone-regex #"^(?:(?:\+|00)?(55)\s?)?(?:\(?([1-9][0-9])\)?\s?)?(?:((?:9\d|[2-9])\d{3})\-?(\d{4}))$")
@@ -92,7 +95,7 @@
                                 ::shipping-tracking
                                 ::address
                                 ::creation-time]))
-(s/def ::card-number (s/and string? valid-luhn?))
+(s/def ::card-number (s/and string? valid-creditcard?))
 (s/def ::creadit-card (s/keys :req [::card-number
                                     ::holder
                                     ::expiration-date


resources.clj edited online with Bitbucket

--- resources/resources.clj
+++ resources/resources.clj
@@ -1,6 +1,6 @@
-{:detrit {:size 0.0
+{:detrit {:size 31
           :max-size 1e4}
  :soil {:size 0.0
-        :max-size 1e4}
+        :max-size 100}
  :oxygen {:size 0.0
-          :max-size 1e5}}
+          :max-size 1e5}}


Add docstrings to chapter 5 stubs.

Add docstrings to chapter 5 stubs.

--- src/little_clojurer/chapter5.clj
+++ src/little_clojurer/chapter5.clj
@@ -3,35 +3,36 @@

 (defn rember*
+  "find all occurrances of a in l deeply recursively and remove them"
   [a l]
   nil)

 (defn insertR*
+  "find all occurrances of old in l deeply recursively and append new to the right of the occurrances"
   [new old l]
   nil)

 (defn occur*
+  "count the number of times a occurs in l deeply recursively"
   [a l]
   nil)

 (defn subst*
-  [new old l]
-  nil)
-
-
-(defn insertL*
+  "find all occurrances of a in l deeply recursively and replace them with new"
   [new old l]
   nil)

 (defn member*
+  "check if a occurs in l deeply recursively"
   [a l]
   nil)

 (defn leftmost
+  "finds the leftmost atom in l deeply recursively. l cannot be empty and cannot contain empty lists."
   [l]
   nil)


fixed some minor bugs

fixed some minor bugs

--- src/crawler/main.clj
+++ src/crawler/main.clj
@@ -43,10 +43,11 @@

 (defn dump-corpus
   ([corpus]
-     (dump-model a-model "crawler"))
+     (dump-corpus corpus "crawler"))

   ([corpus prefix]
      (let [date-file-prefix (utils/dated-filename prefix "")
+           create #(str date-file-prefix %)
            model-file  (create date-file-prefix ".corpus")]
        (with-open [corpus-wrtr (io/writer)]
          (pprint corpus corpus-wrtr)))))


Require backend and util instead of using them

--- src/de/kotka/vimclojure/nails.clj
+++ src/de/kotka/vimclojure/nails.clj
@@ -22,19 +22,11 @@

 (clojure.core/ns de.kotka.vimclojure.nails
   (:use
-     (de.kotka.vimclojure [util :only (with-command-line
-                                       clj->vim
-                                       safe-var-get
-                                       decide-completion-in
-                                       pretty-print
-                                       pretty-print-code
-                                       make-completion-item
-                                       resolve-and-load-namespace
-                                       stream->seq)]
-                          backend)
      [clojure.contrib.def :only (defvar)])
   (:require
-     [de.kotka.vimclojure.repl :as repl])
+     (de.kotka.vimclojure [repl :as repl]
+                          [util :as util]
+                          [backend :as backend]))
   (:import
      com.martiansoftware.nailgun.NGContext
      clojure.lang.LineNumberingPushbackReader
@@ -65,7 +57,7 @@
                            LineNumberingPushbackReader.)
                  ~'*out* (-> ~'nailContext .out OutputStreamWriter.)
                  ~'*err* (-> ~'nailContext .err PrintWriter.)]
-         (with-command-line (.getArgs ~'nailContext)
+         (util/with-command-line (.getArgs ~'nailContext)
            ~usage
            ~arguments
            ~@body)
@@ -75,9 +67,9 @@
 (defnail DocLookup
   "Usage: ng de.kotka.vimclojure.nails.DocString [options]"
   [[nspace n "Lookup the symbols in the given namespace." "user"]]
-  (let [nspace  (resolve-and-load-namespace nspace)
+  (let [nspace  (util/resolve-and-load-namespace nspace)
         symbols (map symbol (line-seq (BufferedReader. *in*)))]
-    (print (doc-lookup nspace symbols))
+    (print (backend/doc-lookup nspace symbols))
     (flush)))

 (defnail FindDoc
@@ -90,27 +82,30 @@
 (defnail JavadocPath
   "Usage: ng de.kotka.vimclojure.nails.JavadocPath [options]"
   [[nspace n "Lookup the symbols in the given namespace." "user"]]
-  (let [nspace         (resolve-and-load-namespace nspace)
+  (let [nspace         (util/resolve-and-load-namespace nspace)
         our-ns-resolve #(ns-resolve nspace %)]
-    (doseq [path (map #(-> % symbol our-ns-resolve javadoc-path-for-class)
-                      (stream->seq *in*))]
+    (doseq [path (map #(-> %
+                         symbol
+                         our-ns-resolve
+                         backend/javadoc-path-for-class)
+                      (util/stream->seq *in*))]
       (println path))))

 (defnail MetaLookup
   "Usage: ng de.kotka.vimclojure.nails.MetaLookup [options]"
   [[nspace n "Lookup the symbols in the given namespace." "user"]]
-  (let [nspace         (resolve-and-load-namespace nspace)
+  (let [nspace         (util/resolve-and-load-namespace nspace)
         our-ns-resolve #(ns-resolve nspace %)]
     (doseq [metainfo (map #(-> % symbol our-ns-resolve meta)
-                     (stream->seq *in*))]
-      (pretty-print metainfo))))
+                     (util/stream->seq *in*))]
+      (util/pretty-print metainfo))))

 (defnail DynamicHighlighting
   "Usage: ng de.kotka.vimclojure.nails.DynamicHighlighting"
   []
   (let [nspace    (read)
         c-c       (the-ns 'clojure.core)
-        the-space (resolve-and-load-namespace nspace)
+        the-space (util/resolve-and-load-namespace nspace)
         refers    (remove #(= c-c (-> % second meta :ns)) (ns-refers the-space))
         aliases   (mapcat (fn [[the-alias the-alias-space]]
                             (map #(vector (symbol (name the-alias)
@@ -128,7 +123,7 @@
         vars      (set (concat refers aliases namespaces))
         macros    (set (filter #(-> % second meta :macro) vars))
         vars      (clojure.set/difference vars macros)
-        fns       (set (filter #(let [v (safe-var-get (second %))]
+        fns       (set (filter #(let [v (util/safe-var-get (second %))]
                                   (or (fn? v)
                                       (instance? clojure.lang.MultiFn v)))
                                vars))
@@ -136,14 +131,14 @@
     (-> (hash-map "Func"     (map first fns)
                   "Macro"    (map first macros)
                   "Variable" (map first vars))
-      clj->vim
+      util/clj->vim
       println)))

 (defnail NamespaceOfFile
   "Usage: ng de.kotka.vimclojure.nails.NamespaceOfFile"
   []
   (let [of-interest '#{in-ns ns clojure.core/in-ns clojure.core/ns}
-        in-seq      (stream->seq *in*)
+        in-seq      (util/stream->seq *in*)
         candidate   (first
                       (drop-while #(or (not (instance? clojure.lang.ISeq %))
                                        (not (contains? of-interest (first %))))
@@ -159,20 +154,20 @@
 (defnail NamespaceInfo
   "Usage: ng de.kotka.vimclojure.nails.NamespaceInfo"
   []
-  (println (clj->vim (map #(-> % symbol find-ns ns-info)
-                          (line-seq (BufferedReader. *in*))))))
+  (println (util/clj->vim (map #(-> % symbol find-ns backend/ns-info)
+                               (line-seq (BufferedReader. *in*))))))

 (defnail MacroExpand
   "Usage: ng de.kotka.vimclojure.nails.MacroExpand [options]"
   [[nspace n "Lookup the symbols in the given namespace." "user"]
    [one?   o "Expand only the first macro."]]
-  (let [nspace (resolve-and-load-namespace nspace)
+  (let [nspace (util/resolve-and-load-namespace nspace)
         expand (if one
                  #(macroexpand-1 %)
                  #(macroexpand %))]
     (binding [*ns* nspace]
-      (doseq [expr (stream->seq *in*)]
-        (-> expr expand pretty-print-code)))))
+      (doseq [expr (util/stream->seq *in*)]
+        (-> expr expand util/pretty-print-code)))))

 (defnail Repl
   "Usage: ng de.kotka.vimclojure.nails.Repl [options]"
@@ -186,7 +181,7 @@
   (let [id     (Integer/parseInt id)
         line   (Integer/parseInt line)
         nspace (when (not= nspace "")
-                 (resolve-and-load-namespace nspace))]
+                 (util/resolve-and-load-namespace nspace))]
     (cond
       start (println (repl/start))
       stop  (repl/stop id)
@@ -196,7 +191,7 @@
   "Usage: ng de.kotka.vimclojure.nails.CheckSyntax"
   []
   (try
-    (dorun (stream->seq *in*))
+    (dorun (util/stream->seq *in*))
     (println true)
     (catch Exception e
       (println false))))
@@ -206,11 +201,12 @@
   [[nspace n "Start completion in this namespace." "user"]
    [prefix p "Prefix used for the match, ie. the part before /." ""]
    [base   b "Base pattern to be matched."]]
-  (let [nspace (resolve-and-load-namespace nspace)
+  (let [nspace (util/resolve-and-load-namespace nspace)
         prefix (symbol prefix)]
     (if-not (and (= base "") (= prefix ""))
-      (let [to-complete (decide-completion-in nspace prefix base)
-            completions (mapcat #(complete % nspace prefix base) to-complete)
-            completions (map #(apply make-completion-item %) completions)]
-        (println (clj->vim completions)))
+      (let [to-complete (util/decide-completion-in nspace prefix base)
+            completions (mapcat #(backend/complete % nspace prefix base)
+                                to-complete)
+            completions (map #(apply util/make-completion-item %) completions)]
+        (println (util/clj->vim completions)))
       (println "[]"))))


Maybe this

Maybe this

--- src/korhal/core.clj
+++ src/korhal/core.clj
@@ -17,7 +17,7 @@

 (defn korhal-main [& args]
   (let [ai (korhal.core.)]
-    (.start (:api @ai))))
+    (.start (:api @(.state ai)))))

 (defn korhal-init [this]
   [[] (atom {:api (jnibwapi.JNIBWAPI. this)})])


Update fetch-facts documentation to new scheme

--- src/midje/repl.clj
+++ src/midje/repl.clj
@@ -122,10 +122,10 @@
   "Fetch facts that have already been defined, whether by loading
    them from a file or via the repl.

-   (fetch-facts)                  -- defined in the current namespace
-   (fetch-facts *ns* midje.t-repl -- defined in named namespaces
-                                     (Names need not be quoted.)
-   (fetch-facts :all)             -- defined anywhere
+   (fetch-facts *ns* 'midje.t-repl)  -- facts defined in these namespaces
+   (fetch-facts :all)                -- all known facts
+   (fetch-facts)                     -- facts in the working set
+                                        `(doc midje-repl-working-set)`

    You can further filter the facts by giving more arguments. Facts matching
    any of the arguments are included in the result. The arguments are:


new name for protocol-type

new name for protocol-type

--- main/src/dda/pallet/dda_managed_ide/domain/git.clj
+++ main/src/dda/pallet/dda_managed_ide/domain/git.clj
@@ -41,7 +41,7 @@
   desktop-wiki :- Repositories
   credential-store :- Repositories]
  (let [email (if (some? email) email (str name "@mydomain"))
-       protocol-type (git-repo/protocol-type git-credentials)]
+       protocol-type (git-repo/github-protocol-type git-credentials)]
    {(keyword name)
     (merge
       {:user-email email}


[#943] Sort permissions list

[#943] Sort permissions list

--- Dashboard/app/cljs/src/org/akvo/flow/dashboard/users/role_details.cljs
+++ Dashboard/app/cljs/src/org/akvo/flow/dashboard/users/role_details.cljs
@@ -76,7 +76,7 @@
           [:input.form-control {:name "userRoleName" :value name
                                 :on-change #(om/set-state! owner "name" (-> % .-target .-value))}]]
          [:div.topMargin.permissionList
-          (for [[value caption] all-permissions]
+          (for [[value caption] (sort-by first all-permissions)]
             (checkbox owner value caption (contains? (set permissions) value)))]
          [:div.form-group
           (b/btn-primary {:class (if (empty? name) "disabled")


Find another place that needs sort-by rather than sort Create a Clojure persistent map from a java.util.Map, when streaming markup

--- src/io/aviso/twixt/exceptions.clj
+++ src/io/aviso/twixt/exceptions.clj
@@ -3,7 +3,7 @@
   (:use hiccup.core
         hiccup.page
         ring.util.response)
-  (:import [clojure.lang APersistentMap Sequential]
+  (:import [clojure.lang APersistentMap Sequential PersistentHashMap$ArrayNode$Seq PersistentHashMap]
            [java.util Map])
   (:require [clojure.string :as s]
             [io.aviso
@@ -43,8 +43,8 @@
         [:em "empty map"]
         [:dl
          (apply concat
-                (for [k (-> m keys sort)]
-                  [[:dt (to-markup k)] [:dd (-> (get m k) to-markup)]]
+                (for [[k v] (sort-by str m)]
+                  [[:dt (to-markup k)] [:dd (to-markup v)]]
                   ))
          ]))))

@@ -72,16 +72,8 @@
 (extend-type Map
   MarkupGeneration
   (to-markup
-    [m]
-    (html
-      (if (.isEmpty m)
-        [:em "empty map"]
-        [:dl
-         (apply concat
-                (for [k (-> m .keySet sort)]
-                  [[:dt (to-markup k)] [:dd (-> (.get m k) to-markup)]]
-                  ))
-         ]))))
+    [^Map m]
+    (to-markup (PersistentHashMap/create m))))

 (defn- element->clojure-name [element]
   (let [names (:names element)]


Correct typo

Correct typo

--- src/io/aviso/twixt/exceptions.clj
+++ src/io/aviso/twixt/exceptions.clj
@@ -135,7 +135,7 @@
      [:div.container
       [:div.panel.panel-danger
        [:div.panel-heading
-        [:h3.panel-title "An unexpected exception has occured."]]
+        [:h3.panel-title "An unexpected exception has occurred."]]
        [:div.panel-body
         [:div.alert.alert-danger (h (exception-message exception))]
         ]


add default config

add default config

--- modules/src/samsara_builtin_modules/sessionize.clj
+++ modules/src/samsara_builtin_modules/sessionize.clj
@@ -5,25 +5,47 @@
   (:require [samsara-builtin-modules.session-boundaries
              :refer [session-boundaries-correlation]]))

-;; TODO: which event? and which key?
-;; TODO: add sessionId on every requests
-;; TODO: add dwell time
-;; TODO: generate session.started/stopped
-;; TODO: cutoff line for unfinished sessions (start without a stop)

+(def DEFAULT-CONFIG
+  {;; :max-idle-time is max time in milliseconds which can elapse
+   ;; between two web calls from the same user to consider them part
+   ;; of the same web session.
+   ;;
+   ;; (default): 20 min
+   :max-idle-time  (* 20 60 1000) ;; 20 minutes

+   ;; :attribute is the name of the event attribute which together
+   ;; with the :sourceId form the guid (general user identifier). This
+   ;; is typically a value of a cookie which is assigned at the first
+   ;; access by the LB or server and used to keep track of new or
+   ;; returning users.  By default it uses only the sourceId, it
+   ;; doesn't use any additional attribute (`nil`). Remember that if
+   ;; you specify another attribute this will be used as composition
+   ;; with the sourceId and not as a replacement. This is due to the
+   ;; fact that the sourceId is the partition key, and the only way to
+   ;; define how data is distributed across processing machines. So if
+   ;; your identifier is in another field then you won't be guaranteed
+   ;; that all events from that specific user will be processed
+   ;; by the same processor thread. In that case you have to switch the
+   ;; attributes and put your GUID into sourceId.
+   ;; (default): nil
+   :attribute      nil

-;; TODO: what's the cleanest way to handle processors' config?
-;;       a param? a closure?, a var?
-;; (def *max-idle-time* 20)
-;; (def *attribute* nil)
-;; (def *web-event-name* "web.page.viewed")
-;; (def *session-event-basename* "web.session")
+   ;; :web-event-name name of the event which contains the page views.
+   ;; only these events will be considered for the processing
+   ;;
+   ;; (default): "web.page.viewed"
+   :web-event-name "web.page.viewed"

-(def cfg
-  {:max-idle-time  20
-   :attribute      nil
-   :web-event-name "web.page.viewed"
+   ;; :session-event-basename is the base name for the session events.
+   ;; When a session start a new event will be generated with the
+   ;; following name `${session-event-basename}.started`, similarly
+   ;; when the session ends a event called
+   ;; `${session-event-basename}.stopped` is generated.  This
+   ;; parameter enables you to customise the name of the generated
+   ;; event.
+   ;;
+   ;; (default): "web.session"
    :session-event-basename "web.session"})

@@ -96,17 +118,27 @@

-(defn sessionize-web-requests [cfg]
-  (pipeline
-   (add-sessionId cfg)
-   (identify-session-start cfg)
-   (emit-session-start-and-stop cfg)
-   calculate-dwell-time
-   cleanup-prev-event
-   session-boundaries-correlation))
+(defn sessionize-web-requests
+  ([cfg]
+   (pipeline
+    (add-sessionId cfg)
+    (identify-session-start cfg)
+    (emit-session-start-and-stop cfg)
+    calculate-dwell-time
+    cleanup-prev-event
+    session-boundaries-correlation))
+  ([]
+   (sessionize-web-requests DEFAULT-CONFIG)))

 (comment
+
+  (def cfg {:max-idle-time 20,
+            :attribute nil,
+            :web-event-name "web.page.viewed",
+            :session-event-basename "web.session"})
+
+
   (def events [{:eventName "web.page.viewed" :timestamp 1  :sourceId "cookie1"}
                {:eventName "web.page.viewed" :timestamp 10 :sourceId "cookie1"}
                #_{:eventName "web.page.viewed" :timestamp 50 :sourceId "cookie1"}])


Don't actually know how that was working :/

--- src/doctopus/web.clj
+++ src/doctopus/web.clj
@@ -14,9 +14,10 @@
             [clojure.walk :refer [keywordize-keys]])
   (:import [doctopus.doctopus Doctopus]))

-(defn wrap-error-page [handler]
+(defn wrap-error-page
   "Utility ring handler for when Stuff goes Sideways; returns a 500 and an error
   page"
+  [handler]
   (fn [req]
     (try (handler req)
          (catch Exception e


lein kibit fixes

lein kibit fixes

--- src/euler/helper.clj
+++ src/euler/helper.clj
@@ -212,7 +212,7 @@

 (def phi
   "The Golden Ratio - (1+sqrt5)/2."
-  (/ (+ 1 (Math/sqrt 5)) 2))
+  (/ (inc (Math/sqrt 5)) 2))

 (defn digits
   "Converts a number n into a list of its digits."
@@ -251,7 +251,7 @@

 (defn combinations [amount [car & cdr :as coins]]
   (cond
-   (= amount 0) 1
-   (or (< amount 0) (= 0 (count coins))) 0
+   (zero? amount) 1
+   (or (neg? amount) (empty? coins)) 0
    :else (+ (combinations amount cdr)
             (combinations (- amount car) coins))))


fix duplicate route

fix duplicate route

--- src-cljs/frontend/routes.cljs
+++ src-cljs/frontend/routes.cljs
@@ -25,7 +25,7 @@
     (put! nav-ch [:landing {:query-params query-params
                             :utm-campaign "product-hunt"}]))

-  (defroute product-hunt "/designer-news" {:keys [query-params]}
+  (defroute designer-news "/designer-news" {:keys [query-params]}
     (put! nav-ch [:landing {:query-params query-params
                             :utm-campaign "designer-news"}]))


elevio Use feature/enabled? to check feature flag

Use frontend.models.feature/enabled? instead of
frontend.utils.launchdarkly/feature-on? to check feature flag

--- src-cljs/frontend/config.cljs
+++ src-cljs/frontend/config.cljs
@@ -1,6 +1,5 @@
 (ns frontend.config
-  (:require [frontend.models.feature :as feature]
-            [frontend.utils.launchdarkly :as ld]))
+  (:require [frontend.models.feature :as feature]))

 (defn env
   "The name of the server configuration environment.
@@ -79,7 +78,7 @@

 (defn elevio-enabled?
   []
-  (and (aget js/window "_elev") (ld/feature-on? "elevio" false)))
+  (and (aget js/window "_elev") (feature/enabled? "elevio")))

 (defn statuspage-header-enabled?
   "If true, we should show statuspage alerts with incidents activated"


Updating schema for listeners

Updating schema for listeners

--- src/helda/schema.clj
+++ src/helda/schema.clj
@@ -3,13 +3,6 @@
     [schema.core :as s]
     )
   )
-
-(s/defschema Relation {
-    :relation-type s/Keyword
-    :src-attr s/Keyword
-    :dst-model s/Keyword
-    :dst-attr s/Keyword
-  })

 (s/defschema Model {
     :full-name s/Keyword
@@ -17,16 +10,8 @@
     :name s/Keyword
     (s/optional-key :description) s/Str
     :extends [s/Keyword]
-    :relaions [Relation]
-    :attrs {s/Keyword s/Keyword}
-  })
-
-(s/defschema Listener {
-    :id s/Str
-    :action-url s/Str
-    :world s/Keyword
-    :type s/Keyword
-    :obj-id s/Str
+    :attrs {s/Keyword s/Str} ;{attr schema}
+    :actions {s/Keyword s/Keyword} ;{action model}
   })

 (s/defschema World {
@@ -40,12 +25,20 @@
     :model s/Keyword
     :tags [s/Keyword]
     :attrs {s/Keyword s/Any}
+    :parent-id s/Str
+  })
+
+(s/defschema EntityListener {
+    :action-url s/Str
+    :world s/Keyword
+    :action s/Keyword
+    :entity-id s/Str
   })

 (s/defschema Event {
     :id s/Str
-    :listener-type s/Keyword
-    :world s/Keyword
-    :model s/Str
-    :instance Object
+    :action s/Keyword
+    :action-entity-id s/Str
+    :listener-id s/Str
+    :instance Entity
   })


Fix reframe flag for main.cljs

Fix reframe flag for main.cljs

--- edge-app-template/src/clj/new/edge_app_template.clj
+++ edge-app-template/src/clj/new/edge_app_template.clj
@@ -59,8 +59,8 @@
           (->files data
                    ["src/{{sanitized}}/frontend/main.cljs"
                     (render (cond
-                              cljs? "main.cljs"
-                              reframe? "reframe/main.cljs")
+                              reframe? "reframe/main.cljs"
+                              cljs? "main.cljs")
                             data)]))
         (when (:reframe data)
           (->files data


finish with applicative functor

finish with applicative functor

--- src/monad/applicativefunctor.clj
+++ src/monad/applicativefunctor.clj
@@ -20,6 +20,65 @@
 ;;<$> :: (Functor f) => (a -> b) -> f a -> f b
 ;;f <$> x = fmap f x

-(defmulti <$> (fn [f _] f))
-(defmethod <$> List [f x]
-  (fmap x s))+(defmulti <$> (fn [_ xs] (class xs)))
+(defmethod <$> List [f xs]
+  (fmap xs f))
+
+(:value (let [fs (List. [#(* 2 %) #(+ 10 %)])
+              xs (List. [1 2 3])]
+          (<*> fs xs)))
+
+(:value (let [g (pure List #(* 50 %))
+              xs (List. [1 2 3])]
+          (<*> g xs)))
+
+(let [f #(* 50 %)
+      xs (List. [1 2 3])]
+  (<$> f xs))
+
+;;applicative functor law
+
+;;Identity
+;;Feeding a function f to pure and applying the resulting Applicative to the Functor v should be the same as directly mapping f over the Functor v
+
+(let [f #(+ 2 %)
+      v (List. [10])]
+  (= (<*> (pure List f) v)
+     (fmap v f)))
+
+;;Composition
+;;The result of applying an Applicative Functor that yields the function composition operator to the Applicative u, then apply the resulting Functor to v and finally applying that result to the final Applicative w should be the same as applying v to w and then applying u to the resulting Applicative
+
+(let [u (List. [#(* 2 %)])
+      v (List. [#(+ 10 %)])
+      w (List. [1 2 3])]
+  (= (-> (pure List (fn [x] (partial comp x)))
+         (<*> u)
+         (<*> v)
+         (<*> w))
+     (<*> u (<*> v w))))
+
+;;clojure的partial就是就是认为制造一个等待一个参数的curry 因为curry在clojure不是默认行为 而在pure fp中curry却和高阶函数一样随处可见
+((((fn [x] (partial comp x)) #(* 2 %)) #(+ 10 %)) 10)
+
+;;clojure的comp就是haskell中的dot 将组合的函数从右到左分别apply到给定的参数上
+((comp #(* 2 %) #(+ 10 %) #(- % 3)) 10)
+
+;;Homomorphism 同质性
+;;The result of applying the pure value of f to the pure value of x should be the same as applying f directly to x and then feeding that into pure.
+
+(let [f #(* 2 %)
+      x 10]
+  (= (-> (pure List f)
+         (<*> (pure List x)))
+     (pure List (f x))))
+
+;;Interchange
+;;The result of applying an Applicative Functor u to the pure value of y should be the same as taking the Applicative obtained by calling pure with a function that applies its argument to y and then applying that to u
+
+(let [u (pure List #(+ 10 %))
+      y 50
+      $ (fn [y] #(% y))]
+  (= (<*> u (pure List y))
+     (<*> (pure List ($ y)) u)))
+


Finished wiring - need to display output though

--- src/alphabet_diamond/core.clj
+++ src/alphabet_diamond/core.clj
@@ -25,11 +25,10 @@

 (defn diamond [letter]
 	(let [commands (commands-for letter)]
-		(map row commands)
+		(print (map row commands))
 		)
 	)

 (defn -main
-  	"I don't do a whole lot ... yet."
   	[& args]
   	(diamond args))


fix typo in "leer"

fix typo in "leer"

--- src/babel/espanol/lexicon.clj
+++ src/babel/espanol/lexicon.clj
@@ -687,19 +687,20 @@

    "lavarse" (let [subject-semantics (atom {:human true})
-         subject-agr (atom :top)]
-     {:synsem {:cat :verb
-               :sem {:pred :wash-oneself
-                     :reflexive true
-                     :subj subject-semantics
-                     :obj subject-semantics}
-               :subcat {:1 {:agr subject-agr
-                            :sem subject-semantics}
-                        :2 {:agr subject-agr
-                            :pronoun true
-                            :reflexive true
-                            :sem subject-semantics}}}})
-   "leer" {:espanol  :preterito {:1sing "leì"
+                   subject-agr (atom :top)]
+               {:synsem {:cat :verb
+                         :sem {:pred :wash-oneself
+                               :reflexive true
+                               :subj subject-semantics
+                               :obj subject-semantics}
+                         :subcat {:1 {:agr subject-agr
+                                      :sem subject-semantics}
+                                  :2 {:agr subject-agr
+                                      :pronoun true
+                                      :reflexive true
+                                      :sem subject-semantics}}}})
+
+   "leer" {:espanol {:preterito {:1sing "leì"
                                  :2sing "leiste"
                                  :3sing "leyò"
                                  :1plur "leimos"


cleanup

cleanup

--- src/babel/francais/writer.clj
+++ src/babel/francais/writer.clj
@@ -1,7 +1,6 @@
 (ns babel.francais.writer
   (:refer-clojure :exclude [get-in]))

-(require '[babel.generate :as generate])
 (require '[babel.francais.grammar :refer [small medium]])
 (require '[babel.francais.lexicon :refer [lexicon]])
 (require '[babel.francais.morphology :refer [analyze exception-generator


cleanup - remove unneeded (require)s

cleanup - remove unneeded (require)s

--- src/babel/francais/writer.clj
+++ src/babel/francais/writer.clj
@@ -1,21 +1,14 @@
 (ns babel.francais.writer
   (:refer-clojure :exclude [get-in]))

-(require '[babel.cache :refer [create-index]])
-(require '[babel.engine :refer [generate]])
-(require '[babel.forest :as forest])
 (require '[babel.francais.grammar :refer [small medium]])
 (require '[babel.francais.lexicon :refer [lexicon]])
 (require '[babel.francais.morphology :refer [analyze exception-generator
-                                             fo get-string phonize]])
+                                             fo]])
 (require '[babel.francais.pos :refer [intransitivize transitivize]])
-(require '[babel.lexiconfn :refer (compile-lex map-function-on-map-vals unify)])
-(require '[babel.parse :as parse])
-(require '[babel.ug :refer [head-principle]])
 (require '[babel.writer :refer [delete-from-expressions process write-lexicon]])
-(require '[clojure.string :as string])
 (require '[clojure.tools.logging :as log])
-(require '[dag-unify.core :refer (fail? get-in strip-refs)])
+(require '[dag-unify.core :refer (fail? get-in strip-refs unify)])

 (defn tout [ & [count]]
   (let [count (if count (Integer. count) 10)


Refactor

Refactor

--- src/alphabet_diamond/core.clj
+++ src/alphabet_diamond/core.clj
@@ -7,14 +7,15 @@
 	(int (.charAt (upper-case letter) 0)))

 (defn- letter-range [start-letter end-letter]
-  (map char (range (int start-letter) (inc (int end-letter)))))
+  (map char (range 	(int start-letter)
+  									(inc (int end-letter)))))

 (defn- instruction [letter]
 	(str (char letter)))

 (defn row-instructions-for [end-letter]
 	(let [letters (letter-range \A (ucase-letter end-letter))
-				rows-and-letters (reverse (map (fn [letter] (instruction letter)) letters))]
+				rows-and-letters (reverse (map instruction letters))]
 			(into rows-and-letters (rest rows-and-letters))))

 (defn- everything-but [letter]
@@ -24,16 +25,14 @@
 	(str/replace row-template (everything-but letter) " "))

 (defn diamond [letter]
-	(let [instructions (row-instructions-for letter)]
-		(map row instructions)))
+	(map row (row-instructions-for letter)))

 (defn check-spec [spec]
 	{:pre [(not (nil? spec))
 				 (re-seq #"^[A-Za-z]$" (trim spec))]}
 		true)

-(defn -main
-  	[& args]
+(defn -main [& args]
   	(let [spec (first args)]
 	  	(try (check-spec spec)
 	  		(doall (map println (diamond spec)))


Fix redis port

Fix redis port

--- src/antlion_clojure/redis.clj
+++ src/antlion_clojure/redis.clj
@@ -5,13 +5,13 @@
 (defmacro master-wcar*
   [& body]
   `(wcar {:pool {} :spec {:host (env :redis-master-host)
-                             :port (env :redis-master-port)}}
+                          :port (-> (env :redis-master-port) Integer.)}}
             ~@body))

 (defmacro slave-wcar*
   [& body]
   `(wcar {:pool {} :spec {:host (or (env :redis-service-host) (env :redis-slave-host))
-                             :port (or (env :redis-service-port) (env :redis-slave-port))}}
+                          :port (-> (or (env :redis-service-port) (env :redis-slave-port)) Integer.)}}
             ~@body))

 (def key-leaving-allowed?


Fixed redaction storage (was using different keys so gave new result each time).

--- src/laskuri/util.clj
+++ src/laskuri/util.clj
@@ -170,13 +170,16 @@
   Returns consistent mapping of domains and subdomains to random value."
   (if (domain-whitelist domain)
     [subdomain domain tld]
-    (let [orig-subdomain-redacted (@blacklist-subdomains [subdomain domain tld])
-          orig-domain-redacted (@blacklist [domain tld])
+    (let [domain-key [domain tld]
+          subdomain-key [subdomain domain tld]
+
+          orig-subdomain-redacted (@blacklist-subdomains subdomain-key)
+          orig-domain-redacted (@blacklist domain-key)

           subdomain-redacted (or orig-subdomain-redacted (.substring (.replace (.toString (java.util.UUID/randomUUID)) "-" "") 0 4))
           domain-redacted (or orig-domain-redacted (.substring (.replace (.toString (java.util.UUID/randomUUID)) "-" "") 0 12))]

       ; If we had to generate, store.
-      (when-not orig-subdomain-redacted (swap! blacklist assoc domain domain-redacted))
-      (when-not orig-domain-redacted (swap! blacklist-subdomains assoc [subdomain domain] domain-redacted))
+      (when-not orig-subdomain-redacted (swap! blacklist assoc domain-key domain-redacted))
+      (when-not orig-domain-redacted (swap! blacklist-subdomains assoc subdomain-key domain-redacted))
       [subdomain-redacted domain-redacted "redacted"])))


Configure with inst-fx!

Configure with inst-fx!

--- src/overtone_workspace/beats.clj
+++ src/overtone_workspace/beats.clj
@@ -24,18 +24,23 @@

 (def logistics-scale (scale :C2 :minor-pentatonic (range 1 15)))
 (def logistics-r 3.8)
-(defn logistics-loop [metro beat x]
-  (let [idx (Math/floor (* x (count logistics-scale)))
-        note (nth logistics-scale idx)
-        freq (midi->hz note)
-        dur (* (rand) 4/8 (/ 60.0 (metro :bpm)))
-        next-beat (+ 2/8 beat)
-        next-x (* logistics-r x (- 1 x))] ;; x = r * x * (1 - x)
-    (if (< 0 (rand-int 3))
-      (at (metro beat)
-          (fmchord01 :freq freq :dur dur :amp (+ 5 (rand 2)))))
-    (apply-by (metro next-beat) #'logistics-loop [metro next-beat next-x])
-    ))
+(do
+  ;;(inst-fx! fmchord01 fx-echo)
+    (defn logistics-loop [metro beat x]
+      (let [idx (Math/floor (* x (count logistics-scale)))
+            note (nth logistics-scale idx)
+            freq (midi->hz note)
+            dur (* (rand) 4/8 (/ 60.0 (metro :bpm)))
+            next-beat (+ 2/8 beat)
+            next-x (* logistics-r x (- 1 x))] ;; x = r * x * (1 - x)
+        (if (< 0 (rand-int 3))
+          (at (metro beat)
+              (fmchord01 :freq freq :dur dur :amp (+ 5 (rand 2)))))
+        (apply-by (metro next-beat) #'logistics-loop [metro next-beat next-x])
+        )))
+
+;;(inst-fx! fmchord01 fx-echo)
+;;(clear-fx fmchord01)
 ;; (logistics-loop sequencer-metro (sequencer-metro) 0.1)
 ;; (stop)


First cut at module tree shaking

First cut at module tree shaking

--- src/oxcart/passes/tree_shake.clj
+++ src/oxcart/passes/tree_shake.clj
@@ -12,9 +12,11 @@
    :author "Reid McKenzie"
    :added "0.0.5"}
   (:require [oxcart.util :as util]
+            [oxcart.pattern :as pattern]
             [oxcart.passes.defs :as defs]
             [clojure.set :as set]
-            [clojure.tools.analyzer.ast :as ast]))
+            [clojure.tools.analyzer.ast :as ast]
+            [taoensso.timbre :refer [info warn error]]))

 (defn reach-set
@@ -38,7 +40,7 @@

 (defn global-reach-set
-  "λ {Symbol → AST} → {Symbol → #{Symbol}}
+  "λ {Symbol → #{Symbol}} → {Symbol → #{Symbol}}

   Computes the reach set for an entire program"
   [whole-program-ast]
@@ -47,9 +49,22 @@
                 (util/map-vals reach-set))))

-(defn tree-shake-module
-  [module options]
-  )
+(defn trim-with-emit-set
+  [{:keys [modules] :as whole-program-ast} reach-set]
+  (let [new-ast (atom {:modules modules})]
+
+    (doseq [m modules]
+      (doseq [[sym ast] (get whole-program-ast m)]
+        (if (pattern/def? ast)
+          (if (contains? reach-set (:var ast))
+            (swap! new-ast assoc-in [m sym] ast)
+            (info "Discarding unused def form,"
+                  (util/line ast)))
+          (warn "Discarding non-def top level form,"
+                (util/line ast)))))
+
+    @new-ast))
+

 (defn tree-shake
   "λ Whole-AST → options → Whole-AST
@@ -64,7 +79,18 @@
     :entry is a symbol, presumably a namespace qualified -main var,
     which is the entry point of the prorgam. It is with respect to this
     function that all other defs will be considered for elimination."
-  [ast {:keys [entry] :as options}]
-  (-> ast
-      (defs/locate-defs options)
-      (util/map-vals (partial tree-shake-module options))))
+  [{:keys [modules] :as ast} {:keys [entry] :as options}]
+  (let [;; First find and annotate all the defs in the program
+        ast (-> ast (defs/locate-defs options))
+
+        ;; Then compute the {Var → #{Var}} form of the whole program
+        symbol-sets (->> (for [m   modules
+                               sym (keys (get ast m))
+                               :let [form (get-in ast [m sym])]]
+                           [(:var form) (reach-set form)])
+                         (into {})
+                         global-reach-set)
+
+        ;; The emit set is now trivially
+        emit-set (get symbol-sets (resolve entry))]
+    (trim-with-emit-set ast emit-set)))


Disable excel rendering

Disable excel rendering

--- src/tree/bench.clj
+++ src/tree/bench.clj
@@ -147,15 +147,17 @@
 (defn template-one-sheet
   [pair-of-results-for-one-ds-config]
   (let [{:keys [tree ds freq n b results]} (first pair-of-results-for-one-ds-config)
-    x {;:sheet-name (str (name tree) " " ds " flushed every " freq)
-     1 [["Data poStructure" (name tree)]]
-     2 [["Flush Frequency" freq]]
-     [6 105] (make-template-for-one-tree-freq-combo pair-of-results-for-one-ds-config)}]
+        x {:sheet-name (str (name tree) " " ds " flushed every " freq)
+           0 [["Data Structure" (name tree)]]
+           1 [["Flush Frequency" freq]]
+           ;[5 104] (make-template-for-one-tree-freq-combo pair-of-results-for-one-ds-config)
+
+           }]
     (println)
     (println "here's a sheet")
     (clojure.pprint/pprint x)
     (println)
-
+
     x))

 (defn -main
@@ -191,13 +193,15 @@
               :n (:num-operations options)
               :b (:tree-width options)
               :results (benchmark (:num-operations options) ds flush-freq (get @trees-to-test tree) out)}))
-    (println @results)
-    (let [results-by-tree (group-by (juxt :tree :freq) @results)
+    (println "Excel output is bugged ATM")
+    #_(println @results)
+    #_(let [results-by-tree (group-by (juxt :tree :freq) @results)
           first-result (second (first results-by-tree))]
       (excel/render-to-file
-        "template_benchmark.xlsx"
+        "Workbook1.xlsx"
+        ;"template_benchmark.xlsx"
         (.getPath (File. (first arguments) "analysis.xlsx"))
-        {"Single DS"
+        {"SingleDS"
          (reduce (fn [templs [[tree freq] list-of-results]]
                    (conj templs (template-one-sheet list-of-results)))
                  []
@@ -205,13 +209,13 @@

 (comment
   (excel/render-to-file
-        "template_benchmark.xlsx"
+        "Workbook1.xlsx"
         "template_trial.xlsx"
      {"SingleDS"
-      [{;:sheet-name "cool sheet"
-        2 [["Data poStructure" "lol"]]
-        3 [["Flush aoenuthsaeoFrequency" 1000]]}
-      {;:sheet-name "cool sheet2"
-        1 [["Data poStructure234" "lol"]]
-        3 [["Flush aoenuthsaeoFrequency" 1000]]}]}
+      [{:sheet-name "cool sheet"
+        0 [["Data poStructure" "lol"]]
+        1 [["Flush aoenuthsaeoFrequency" 1000]]}
+      {:sheet-name "cool sheet2"
+        0 [["Data poStructure234" "lol"]]
+        1 [["Flush aoenuthsaeoFrequency" 1000]]}]}
     ))


Fix typo/spelling

Fix typo/spelling

--- src/useful/seq.clj
+++ src/useful/seq.clj
@@ -190,7 +190,7 @@
    one containing b begins. Note that the split? predicate should not take two
    arguments, but instead a single argument, a pair.

-   Like partition-by, a lazy sequence of paritions is returned, but the
+   Like partition-by, a lazy sequence of partitions is returned, but the
    partitions themselves are eager.

    For example, to cause each nil to be folded into the next partition:


Add a date to dtbook meta data

Add a date to dtbook meta data

--- src/catalog/layout/dtbook.clj
+++ src/catalog/layout/dtbook.clj
@@ -5,7 +5,8 @@
   (:require [catalog.layout.common :as layout :refer [empty-or-blank? wrap]]
             [clj-time
              [coerce :as time.coerce]
-             [core :as time.core]]
+             [core :as time.core]
+             [format :as time.format]]
             [clojure.data.xml :as xml]
             [clojure.string :as string]))

@@ -64,7 +65,7 @@
                 {:keys [creator volume date language]
                  :or {creator "SBS Schweizerische Bibliothek für Blinde, Seh- und Lesebehinderte"
                       volume (layout/volume-number (time.core/today))
-                      date (time.coerce/to-date (time.core/today))
+                      date (time.core/now)
                       language "de"}}]
   [:dtbook {:xmlns "http://www.daisy.org/z3986/2005/dtbook/"
             :xmlns:brl "http://www.daisy.org/z3986/2009/braille/"
@@ -74,7 +75,7 @@
           {:dc:Title title
            :dc:Creator creator
            :dc:Publisher creator
-           :dc:Date "FIXME"
+           :dc:Date (time.format/unparse (time.format/formatters :date) date)
            :dc:Format "ANSI/NISO Z39.86-2005"
            :dc:Language language}]
       [:meta {:name (name k) :content v}])]


added go downstairs upstairs

added go downstairs upstairs

--- src/babel/english/lexicon.clj
+++ src/babel/english/lexicon.clj
@@ -474,6 +474,22 @@
                     :subj {:animate true}}}
     :english {:past "went"}}

+   "go downstairs"
+   {:synsem {:cat :verb
+              :sem {:activity true
+                    :discrete false
+                    :pred :go-downstairs
+                    :subj {:animate true}}}
+    :english {:past "went downstairs"}}
+
+   "go upstairs"
+   {:synsem {:cat :verb
+              :sem {:activity true
+                    :discrete false
+                    :pred :go-upstairs
+                    :subj {:animate true}}}
+    :english {:past "went upstairs"}}
+
    "grab"  {:synsem {:cat :verb
                      :sem {:pred :prendere}}
             :english {:participle "grabbing"


+TODO comments

+TODO comments

--- src/babel/italiano/writer.clj
+++ src/babel/italiano/writer.clj
@@ -9,16 +9,16 @@
 (require '[clojure.tools.logging :as log])
 (require '[dag_unify.core :refer (fail? get-in strip-refs unify)])

-(def small (grammar/small))
+(def small (grammar/small))  ;; TODO use medium consistently

 (defn expression [spec]
-  (generate/generate small spec))
+  (generate/generate small spec))  ;; TODO use medium consistently

 (defn fo [spec]
   (morph/fo spec))

 (defn rewrite-lexicon []
-  (let [lexicon (:lexicon small)]
+  (let [lexicon (:lexicon small)] ;; TODO use medium consistently
     (write-lexicon "it" lexicon)))

 (declare generate-one-verb)
@@ -27,7 +27,7 @@
   (let [count (if count (Integer. count) 10)
         ;; subset of the lexicon: only verbs which are infinitives and that can be roots:
         ;; (i.e. those that have a specific (non- :top) value for [:synsem :sem :pred])
-        lexicon (:lexicon small)
+        lexicon (:lexicon small) ;; TODO use medium consistently
         lexemes (if lexeme (list (get lexicon lexeme))
                     (vals lexicon))
         root-verbs


Get rid of debug log message.

Get rid of debug log message.

--- src/clj/elephantdb/loader.clj
+++ src/clj/elephantdb/loader.clj
@@ -111,9 +111,6 @@
     (loop []
       (Thread/sleep interval-ms)
       (when (< @finished-loaders amount-shards)
-        (log-message "Download supervisor - "
-                     "Finished: " @finished-loaders
-                     ", waiting for: " (- amount-shards @finished-loaders))
         (doseq [[domain shard-states] domain-to-shard-states]
           (doseq [[s-id ^ShardState s-state] shard-states]
             (supervise-shard domain s-id max-kbs-per-shard s-state)))


implement Launch Campaign and Shannon Claire

--- src/clj/game/cards-assets.clj
+++ src/clj/game/cards-assets.clj
@@ -258,6 +258,12 @@
                                          (shuffle! state side :deck))}
                            card nil))}]}

+   "Launch Campaign"
+   {:effect (effect (add-prop card :counter 6))
+    :events {:corp-turn-begins {:msg "gain 2 [Credits]" :counter-cost 2
+                                :effect (req (gain state :corp :credit 2)
+                                             (when (zero? (:counter card)) (trash state :corp card)))}}}
+
    "Levy University"
    {:abilities [{:prompt "Choose an ICE" :msg (msg "adds " (:title target) " to HQ")
                  :choices (req (filter #(has? % :type "ICE") (:deck corp)))
@@ -399,6 +405,19 @@
                             :effect (effect (trash card)
                                             (system-msg "trashes Server Diagnostics"))}}}

+   "Shannon Claire"
+   {:abilities [{:cost [:click 1] :msg "draw 1 card from the bottom of R&D"
+                 :effect (effect (move (last (:deck corp)) :hand))}
+                {:label "[Trash]: Search R&D for an agenda" :prompt "Choose an agenda to add to the bottom of R&D"
+                 :msg (msg "reveal " (:title target) " from R&D and add it to the bottom of R&D")
+                 :choices (req (filter #(has? % :type "Agenda") (:deck corp)))
+                 :effect (effect (shuffle! :deck) (move target :deck)
+                                 (trash card {:cause :ability-cost}))}
+                {:label "[Trash]: Search Archives for an agenda" :prompt "Choose an agenda to add to the bottom of R&D"
+                 :msg (msg "reveal " (:title target) " from Archives and add it to the bottom of R&D")
+                 :choices (req (filter #(has? % :type "Agenda") (:discard corp)))
+                 :effect (effect (move target :deck) (trash card {:cause :ability-cost}))}]}
+
    "Shattered Remains"
    {:advanceable :always
     :access {:optional


add Constellation Protocol message using card-str

--- src/clj/game/cards-assets.clj
+++ src/clj/game/cards-assets.clj
@@ -85,7 +85,9 @@
                                                                         (and (= (:advanceable %) "while-rezzed")
                                                                              (:rezzed %))))}
                                                :effect (effect (add-prop :corp target :advance-counter 1)
-                                                               (add-prop :corp fr :advance-counter -1))} card nil)
+                                                               (add-prop :corp fr :advance-counter -1)
+                                                               (system-msg (str "uses Constellation Protocol to move an advancement token from "
+                                                                                (card-str fr) " to " (card-str target))))} card nil)
                                             card nil))}}}}}

    "Contract Killer"


replace closure/load-externs for more control

externs are now logged and checked if they actually exist.

--- src/clj/shadow/cljs/build.clj
+++ src/clj/shadow/cljs/build.clj
@@ -7,7 +7,7 @@
            (com.google.javascript.jscomp.deps JsFileParser)
            (java.util.logging Level)
            [java.util.concurrent Executors Future]
-           (com.google.javascript.jscomp ReplaceCLJSConstants CompilerOptions))
+           (com.google.javascript.jscomp ReplaceCLJSConstants CompilerOptions CommandLineRunner))
   (:require [clojure.data.json :as json]
             [clojure.java.io :as io]
             [clojure.set :as set]
@@ -379,6 +379,7 @@
                            :foreign true
                            :requires (set (map symbol requires))
                            :provides (set (map symbol provides))
+                           :externs externs
                            :externs-source (->> externs
                                                 (map #(get result %))
                                                 (map :input)
@@ -1622,15 +1623,45 @@

   state)

-(defn load-externs [{:keys [build-modules] :as state}]
-  (->> build-modules
-       (mapcat :sources)
-       (map #(get-in state [:sources %]))
-       (filter :foreign)
-       (filter :externs-source)
-       (reduce (fn [externs {:keys [js-name externs-source] :as foreign-src}]
-                 (conj externs (SourceFile/fromCode (str "externs/" js-name) externs-source)))
-         (closure/load-externs state))))
+(defn load-externs [{:keys [logger externs build-modules] :as state}]
+  (let [default-externs
+        (CommandLineRunner/getDefaultExterns)
+
+        manual-externs
+        (when (seq externs)
+          (log-progress logger "Using externs from options:")
+          (->> externs
+               (map
+                 (fn [ext]
+                   (if-let [rc (or (io/resource ext)
+                                   (let [file (io/file ext)]
+                                     (when (.exists file)
+                                       file)))]
+                     (do (log-progress logger (format "\t%s" ext))
+                         (SourceFile/fromCode (str "EXTERNS/" ext) (slurp rc)))
+                     (do (log-warning logger (format "EXTERN missing: %s (file or resource not found)" ext))
+                         nil))))
+               (remove nil?)
+               ;; just to force the logging
+               (into [])))
+
+        foreign-externs
+        (->> build-modules
+             (mapcat :sources)
+             (map #(get-in state [:sources %]))
+             (filter :foreign)
+             (filter :externs-source)
+             (map (fn [{:keys [js-name externs externs-source] :as foreign-src}]
+                    (log-progress logger (format "Using externs for: %s" js-name))
+                    (doseq [ext externs]
+                      (log-progress logger (format "\t%s" ext)))
+                    (SourceFile/fromCode (str "EXTERNS/" js-name) externs-source)))
+             ;; just to force the logging
+             (into []))]
+
+    (->> (concat default-externs foreign-externs manual-externs)
+         (into []))
+    ))

 ;; added by default in init-state


remove debug print

remove debug print

--- src/clj/shadow/cljs/build.clj
+++ src/clj/shadow/cljs/build.clj
@@ -358,9 +358,6 @@
                                    ast-js (with-out-str
                                             (comp/emit ast))

-                                   _ (when (= :ns (:op ast))
-                                       (pprint ast))
-
                                    compile-state (if (= :ns (:op ast))
                                                    (update-rc-from-ns compile-state ast state)
                                                    compile-state)


New function: format-date

New function: format-date

--- src/clj_calendar/calendar.clj
+++ src/clj_calendar/calendar.clj
@@ -24,6 +24,11 @@
     (let [date-format (new java.text.SimpleDateFormat desired-format)]
         (.format date-format (.getTime calendar))))

+(defn format-date
+    "Format given date using the following format: 'yyyy-MM-dd'"
+    [calendar]
+    (format-date-using-desired-format calendar "yyyy-MM-dd"))
+
 (defn format-date-time
     "Format given date using the following format: 'yyyy-MM-dd HH:mm:ss'"
     [calendar]


flesh out purchase in web namespace

flesh out purchase in web namespace

--- src/clj_money/web/trading.clj
+++ src/clj_money/web/trading.clj
@@ -8,6 +8,8 @@
             [clj-time.core :as t]
             [clj-money.web.shared :refer :all]
             [clj-money.web.money-shared :refer [budget-monitors]]
+            [clj-money.coercion :as coercion]
+            [clj-money.validation :as validation]
             [clj-money.models.accounts :as accounts]
             [clj-money.models.commodities :as commodities]
             [clj-money.trading :as trading]))
@@ -50,8 +52,15 @@
           "Back"]]]))))

 (defn purchase
-  [req]
-  "purchase")
+  [{params :params :as req}]
+  (let [result (trading/buy (env :db) (select-keys params [:account-id
+                                                           :commodity-id
+                                                           :shares
+                                                           :value
+                                                           :trade-date]))]
+    (if (validation/has-error? result)
+      (new-purchase req result)
+      (redirect (format "/accounts/%s" (:account-id result))))))

 (defn new-sale
   [req]