added arrivare

added arrivare

--- src/babel/italiano/lexicon.cljc
+++ src/babel/italiano/lexicon.cljc
@@ -274,6 +274,10 @@
                                       :reflexive true
                                       :sem subject-semantics}}}})

+   "arrivare" {:synsem {:essere true
+                            :cat :verb
+                            :sem {:pred :arrive}}}
+
    "ascoltare"  {:synsem {:cat :verb
                           :sem {:pred :listen-to}}}

@@ -898,8 +902,7 @@
              (unify shared-part-of-dire
                     {:synsem {:sem {:pred :tell}}})])

-      "andare"
-
+
       "diventare" {:synsem {:essere true
                             :cat :verb
                             :sem {:pred :become}}}


Fixes #668 - Doppelganger now prompts on each succesful run until runner accepts and then wont prompt again until next turn

--- src/clj/game/cards-hardware.clj
+++ src/clj/game/cards-hardware.clj
@@ -139,14 +139,19 @@

    "Doppelgänger"
    {:effect (effect (gain :memory 1)) :leave-play (effect (lose :memory 1))
-    :events {:successful-run-ends
+    :events {:runner-install
+             {:req (req (= card target))
+              :effect (effect (update! (assoc card :dopp-active true)))}
+             :runner-turn-begins
+             {:effect (effect (update! (assoc card :dopp-active true)))}
+             :successful-run-ends
              {:optional
-              {:req (req (first-event state side :run))
+              {:req (req (:dopp-active card))
                :prompt "Use Doppelgänger to run again?" :player :runner
                :yes-ability {:prompt "Choose a server"
                              :choices (req servers)
                              :msg (msg "to make a run on " target)
-                             :effect (effect (run target))}}}}}
+                             :effect (effect (update! (dissoc card :dopp-active)) (run target))}}}}}

    "Dorm Computer"
    {:data {:counter 4}


throw exception if unable to resolve transaction item

--- src/clj_money/serialization.clj
+++ src/clj_money/serialization.clj
@@ -161,14 +161,17 @@
 (defn- resolve-transaction-item-ids
   [context account-id items]
   (mapv (fn [{:keys [transaction-date amount]}]
-          (->> context
+          (or (->> context
                :transactions
                (filter #(= transaction-date (:transaction-date %)))
                (mapcat :items)
                (filter #(and (= account-id (:account-id %))
                              (= amount (:amount %))))
                (map :id)
-               first))
+               first)
+              (throw (Exception. (format "Unable to find a transaction with date=%s, amount=%s"
+                                         transaction-date
+                                         amount)))))
         items))

 (defn- resolve-reconciliation-transaction-item-ids


Quote file separator pattern in `lumo.util/path-seq` (#199)

--- src/cljs/bundled/lumo/util.cljs
+++ src/cljs/bundled/lumo/util.cljs
@@ -128,8 +128,8 @@

 (defn path-seq
   [file-str]
-  ;; TODO: need to quote path-sep?
   (->> (.-sep js/$$LUMO_GLOBALS.path)
+       gstring/regExpEscape
        re-pattern
        (string/split file-str)))


Make the REPL work with literals.

Make the REPL work with literals.

--- src/cljs/leipzig_live/core.cljs
+++ src/cljs/leipzig_live/core.cljs
@@ -7,19 +7,24 @@

 ;; -------------------------
 ;; Model
-(defonce music (atom "7"))
+(defonce music (atom ""))

 ;; -------------------------
 ;; Behaviour
+(defn identify
+  "Hack to make literal values still evaluate."
+  [expr-str]
+  (str "(identity " expr-str ")"))
+
 (defonce compiler-state (cljs/empty-state))
 (defn evaluate
   [expr-str]
-  (cljs/eval-str
-    compiler-state
-    expr-str
-    nil
-    {:eval cljs/js-eval}
-    #(print-str expr-str " evaluates to " %)))
+    (cljs/eval-str
+      compiler-state
+      (identify expr-str)
+      nil
+      {:eval cljs/js-eval}
+      #(:value %)))

 ;; -------------------------
 ;; Views


Buildings -> global

Buildings -> global

--- src/cljs/puertorico/client.cljs
+++ src/cljs/puertorico/client.cljs
@@ -182,6 +182,7 @@
 (def common
   {:roles [:captain :trader :builder :settler :mayor :craftsman]
    :goods [:coffee 9 :tobacco 9 :corn 10 :sugar 11 :indigo 11]
+   :buildings initial-buildings
    :trader []
    :fields [:quarry 8 :coffee 8 :tobacco 9 :corn 10 :sugar 11 :indigo 12]})

@@ -196,10 +197,8 @@

 (def game (atom (apply create-game ["Kanwei" "Lauren" "Ted"])))

-(def buildings (atom initial-buildings))
-
 (defn building-tile [b-name]
-    (let [building (b-name @buildings)]
+    (let [building (b-name (:buildings @game))]
       [:div.building {:class (:resource building)}
        [:h5 (name b-name)]
        [:i.fa.fa-money.pull-right (:cost building)]
@@ -259,7 +258,7 @@
 (defn player-boards []
   [:div.row
    (for [player (:players @game)]
-     [:div.col-md-3 {:on-click #(swap! players dissoc player)}
+     [:div.col-md-3
         (player-board player)])])

 (defn supply-board []


Added about partial

Added about partial

--- src/clojure/staircase/views.clj
+++ src/clojure/staircase/views.clj
@@ -122,7 +122,7 @@
       (include-css "/css/style.css")
       ]
      (concat [
-              [:body
+              [:body {:class "staircase"}
                (header)
                [:section#content.main body]]
                (footer)
@@ -159,7 +159,7 @@
       [:div.panel-body
        [:native-tool {:tool "tool"}]]
       [:div.panel-footer {:ng-if "tool.action"}
-       [:button.btn.btn-default.pull-right {:ng-click "act()"} "{{tool.action}}"]
+       [:button.btn.btn-default.pull-right {:ng-disabled "tool.disabled" :ng-click "act()"} "{{tool.action}}"]
        [:div.clearfix]]
       ]]

@@ -210,11 +210,61 @@
     [:div.col-xs-12.col-sm-10
      [:div.current-step {:tool "tool" :step "step"} ]]]])

+(def about
+  [:div.container-fluid
+   [:div.row
+    [:div.about.col-xs-10.col-xs-offset-1
+     [:div.about-header
+      [:div.container
+       [:h1 "InterMine Steps"]
+       [:p "The data-flow interface to InterMine data-warehouses,
+           providing an extensible, programmable tool-box for
+           scientists."]]]
+     [:section
+      [:h2 "Using the home-page"]
+      [:p.lead
+       "The " (link-to "/" "home page") " allows quick access to the tools available "
+       "for starting a new history"]
+      [:p
+       "Tools are components that let you interact with your data. They can do a wide
+       range of things, from uploading a data-set, to running a complex query, to
+       managing your stored resources. On the home page you can see the tools that can
+       be used to start a sequence of steps in a data-flow. One of these is shown below:"]
+      [:div.row
+       [:starting-point.col-sm-6 ;; TODO: Move the template below into a directive. Currently not very DRY at all.
+        [:div.panel.panel-default.first-step {:ng-class "tool.action ? 'with-action' : ''"}
+         [:div.panel-heading
+          [:i.fa.fa-undo.pull-right {:ng-show "tool.resettable" :ng-click "reset()"}]
+          "{{tool.heading}}"]
+         [:div.panel-body
+          [:native-tool {:tool "tool"}]]
+         [:div.panel-footer {:ng-if "tool.action"}
+          [:button.btn.btn-default.pull-right {:ng-disabled "tool.disabled" :ng-click "act()"} "{{tool.action}}"]
+          [:div.clearfix]]]]
+       [:div.col-sm-6
+        [:p {:ng-repeat "para in tool.description"} "{{para}}"]
+        [:p
+         "The following standard controls are available for interacting with one of these
+         tools:"]
+        [:table.table
+          [:tr
+           [:td
+            [:button.btn.btn-default {:ng-disabled "tool.disabled" :ng-click "act()"} "{{tool.action}}"]]
+           [:td
+            "This button performs the main action for the component (if it has one)"]]
+         [:tr
+          [:td
+            [:i.fa.fa-undo {:ng-click "reset()"}]]
+          [:td
+           "This button restores the component to its orginal state, removing any filters you may have applied."]]]]
+        ]]]]])
+
 (defn render-partial
   [fragment]
   (case fragment
     "frontpage" (html starting-points)
     "history" (html history)
+    "about" (html about)
     {:status 404}))

 (defn index []


Little bit of optimization for stem-base

Changed add-immediate-elements to return a vector of the new set and the
unused implications. These can then be used in the next iteration of
close-under-implications.

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

--- src/conexp/fca/implications.clj
+++ src/conexp/fca/implications.clj
@@ -40,34 +40,52 @@
   (forall [intent (context-intents ctx)]
 	  (respects? intent impl)))

-(defn add-immediate-elements
-  [implications old-set]
-  (let [conclusions-to-add (for [impl implications
-				 :when (and (subset? (premise impl) old-set)
-					    (exists [x (conclusion impl)] (not (old-set x))))]
-			     (conclusion impl))]
-    (apply union old-set conclusions-to-add)))
+(defn add-immediate-elements [implications initial-set]
+  (loop [conclusions []
+	 impls implications
+	 unused-impls []]
+    (if (empty? impls)
+      [(apply union initial-set conclusions) unused-impls]
+      (let [impl (first impls)]
+	(if (and (subset? (premise impl) initial-set)
+		 (not (subset? (conclusion impl) initial-set)))
+	  (recur (conj conclusions (conclusion impl))
+		 (rest impls)
+		 unused-impls)
+	  (recur conclusions
+		 (rest impls)
+		 (conj unused-impls impl)))))))

 (defn close-under-implications [implications set]
-  (loop [set set]
-    (let [new (add-immediate-elements implications set)]
+  (loop [set set
+	 impls implications]
+    (let [[new impls] (add-immediate-elements impls set)]
       (if (= new set)
 	new
-	(recur new)))))
+	(recur new impls)))))

 (defn clop-by-implications [implications]
   (partial close-under-implications implications))

 (defn follows-semantically? [implication implications]
-  (subset? (conclusion implication) (close-under-implications implications (premise implication))))
+  (subset? (conclusion implication)
+	   (close-under-implications implications (premise implication))))

-(defn add-immediate-elements*
-  [implications old-set]
-  (let [conclusions-to-add (for [impl implications
-				 :when (and (proper-subset? (premise impl) old-set)
-					    (exists [x (conclusion impl)] (not (old-set x))))]
-			     (conclusion impl))]
-    (apply union old-set conclusions-to-add)))
+(defn add-immediate-elements* [implications initial-set]
+  (loop [conclusions []
+	 impls implications
+	 unused-impls []]
+    (if (empty? impls)
+      [(apply union initial-set conclusions) unused-impls]
+      (let [impl (first impls)]
+	(if (and (proper-subset? (premise impl) initial-set)
+		 (not (subset? (conclusion impl) initial-set)))
+	  (recur (conj conclusions (conclusion impl))
+		 (rest impls)
+		 unused-impls)
+	  (recur conclusions
+		 (rest impls)
+		 (conj unused-impls impl)))))))

 (defn clop-by-implications* [implications]
   (binding [add-immediate-elements add-immediate-elements*]


Don't call method Java.endsWith directly in the module emender-jenkins/results

--- src/emender_jenkins/results.clj
+++ src/emender_jenkins/results.clj
@@ -18,6 +18,7 @@
 (require '[clj-jenkins-api.jenkins-api :as jenkins-api])

 (require '[emender-jenkins.config      :as config])
+(use     '[emender-jenkins.utils])

 (def results (atom nil))

@@ -71,9 +72,9 @@
 (defn job-name->environment
     [job-name preview-jobs-suffix stage-jobs-suffix prod-jobs-suffix]
     (cond
-        (.endsWith job-name preview-jobs-suffix) :preview
-        (.endsWith job-name stage-jobs-suffix)   :stage
-        (.endsWith job-name prod-jobs-suffix)    :prod))
+        (endsWith job-name preview-jobs-suffix) :preview
+        (endsWith job-name stage-jobs-suffix)   :stage
+        (endsWith job-name prod-jobs-suffix)    :prod))

 (defn compute-job-status
     [jenkins-job-status buildable?]
@@ -139,9 +140,9 @@
 (defn test-job?
     [job-name jobs-prefix preview-jobs-suffix stage-jobs-suffix prod-jobs-suffix]
     (and (.startsWith job-name jobs-prefix)
-         (or (.endsWith job-name preview-jobs-suffix)
-             (.endsWith job-name stage-jobs-suffix)
-             (.endsWith job-name prod-jobs-suffix))))
+         (or (endsWith job-name preview-jobs-suffix)
+             (endsWith job-name stage-jobs-suffix)
+             (endsWith job-name prod-jobs-suffix))))

 (defn filter-test-jobs
     [all-jobs jobs-prefix preview-jobs-suffix stage-jobs-suffix prod-jobs-suffix]


fix call to move-back, add selected card presentation


Better version of `for-os` macro

Better version of `for-os` macro

--- src/great_things_done/macro.clj
+++ src/great_things_done/macro.clj
@@ -1,14 +1,21 @@
-(ns great_things_done.macro)
+(ns great-things-done.macro)

 (defmacro for-os
   "Execute code depending on the current OS"
   [& body]
-  (let [os-map# (into {}
-                       (into []
-                             (map #(into [] %)
-                                  (partition 2 body))))]
-     (if (even? (count body))
-       (if-let [fun# (get os-map# (System/getProperty "os.name"))]
-         fun#
-         (get os-map# :default))
-       (throw (Exception. "Wrong number of args. `for-os` should have an even number of arguments")))))
+  (let [platform-translation# {"darwin"  "Mac OS X"
+                               "win32"   "Windows"
+                               "freebsd" "BSD"
+                               "linux"   "Linux"
+                               "sunos"   "SunOS"}
+        os-map#               (into {}
+                                    (into []
+                                          (map #(into [] %)
+                                               (partition 2 body))))]
+    (if (even? (count body))
+      `(if (contains? ~os-map# (get ~platform-translation#
+                                    js/process.platform))
+                      (get ~os-map# (get ~platform-translation#
+                                         js/process.platform))
+                      ~(get os-map# :default))
+         (throw (Exception. "Wrong number of args. `for-os` should have an even number of arguments")))))


Alter how middlewares are registered (keyed by var instead of fn).

--- src/incise/middlewares/core.clj
+++ src/incise/middlewares/core.clj
@@ -3,13 +3,11 @@

 (defonce middlewares (atom {}))

-(defn register [rank-or-middleware & more]
-  (let [[rank middleware args] (if (fn? rank-or-middleware)
-                                 [600 rank-or-middleware more]
-                                 [rank-or-middleware (first more) (rest more)])]
-    (swap! middlewares assoc middleware [rank args])))
+(defn register* [rank middleware-var & more]
+  (swap! middlewares assoc middleware-var {:rank rank
+                                           :args more}))

-(defn- combine [app [middleware [_ args]]]
+(defn- combine [app [middleware {:keys [args]}]]
   (apply middleware app args))

 (defn wrap-app [app]


Better implementation for hiding entities

--- desktop/src-common/escape_game/core.clj
+++ desktop/src-common/escape_game/core.clj
@@ -175,7 +175,7 @@
              (arrow :left :room01)]

             :room06
-            [(defentity "" "images/room06.png" 0 0 700 480)
+            [(hide (defentity "room06-bg" "images/room06.png" 0 0 700 480))
              (arrow :left :room05)
              ]})

@@ -198,7 +198,7 @@
     (render! screen [(assoc (texture "images/inventory.png")
                             :x 700 :y 0
                             :width 100 :height 480)])
-    (render! screen entities)
+    (render! screen (remove #(:hidden %) entities))
     (render! screen (:inventory screen))
     (if (:selected screen)
       (render! screen [(assoc (texture "images/inventory-selected.png")
@@ -246,7 +246,7 @@
      (:inventory screen))
     (mapv
      (fn [ent]
-       (cond (and (clicked? ent screen)
+       (cond (and (not (:hidden ent)) (clicked? ent screen)
                   (:action ent))
              (do (debug "ACTIVATING ACTION for" (:name ent))
                  ((:action ent) ent screen entities))


Changing default store back to casandra.

--- src/org/spootnik/cyanite/config.clj
+++ src/org/spootnik/cyanite/config.clj
@@ -17,9 +17,7 @@

 (def ^{:doc "handle storage with cassandra-metric-store by default"}
   default-store
-    {:use "org.spootnik.cyanite.store/devnull"}
-;  {:use "org.spootnik.cyanite.store/cassandra-metric-store"}
-    )
+  {:use "org.spootnik.cyanite.store/cassandra-metric-store"})

 (def ^{:doc "let carbon listen on 2003 by default"}
   default-carbon


show the cache queries while processing log

show the cache queries while processing log

--- src/webapp/framework/server/systemfns.clj
+++ src/webapp/framework/server/systemfns.clj
@@ -621,17 +621,24 @@
 (def realtime-counter (atom 0))
 (defn next-realtime-id [] (swap! realtime-counter inc))

-()
+

 (korma.core/exec-raw ["delete from coils_realtime_log" []] [])

 (defn process-log-entry [ realtime-log-entry ]
-(do
-            (println (str "**** Processing: " realtime-log-entry ) )
-          (println @cached-queries)
-        )  )
+  (do
+   (println (str "**** Processing: " realtime-log-entry))
+   (println (str @cached-queries))
+   (println (str "Count: " (-> @cached-queries keys count str)))
+   ;(let [queries (keys @cached-queries)]
+;   (for [query queries]
+     ;(println (str "   " queries)))
+   ))
+
+
+

 (go
   (loop []


Fix timestamp-be test.

Fix timestamp-be test.

--- test/dsbdp/test/byte_array_conversion.clj
+++ test/dsbdp/test/byte_array_conversion.clj
@@ -56,5 +56,5 @@
 (deftest timestamp-be-conversion-test
   (let [ba (byte-array (map byte [-5 -106 -57 84 15 -54 14 0 -5]))
         expected 1422366459969231000]
-    (is (= expected (timestamp ba 0)))))
+    (is (= expected (timestamp-be ba 0)))))


changed result of get-position to {:x :y :z} map


fix test: pred=:house, not :casa

fix test: pred=:house, not :casa


ply.test should require ply ns

ply.test should require ply ns


CMR-721: Fixed bug in orbits code.

CMR-721: Fixed bug in orbits code.

--- src/cmr/search/data/complex_to_simple_converters/spatial.clj
+++ src/cmr/search/data/complex_to_simple_converters/spatial.clj
@@ -110,7 +110,7 @@
   ;; in the search.
   (let [type (resolve-shape-type (name (:type (first stored-ords))))
         coords (double-array (map srl/stored->ordinate
-                                  (get-in stored-ords [0 :ords])))]
+                                  (:ords (first stored-ords))))]
     (let [{:keys [swath-width
                   period
                   inclination-angle


Improve tailing

Improve tailing

--- test/com/nomistech/clojure_the_language/c_920_io/tailing.clj
+++ test/com/nomistech/clojure_the_language/c_920_io/tailing.clj
@@ -99,4 +99,5 @@
             "Goodbye girl"
             "Goodbye girl"]))

+
 ;; TODO Check that bug: https://issues.apache.org/jira/browse/IO-399


Update lein profiles

Update lein profiles

--- dotfiles/lein/profiles.clj
+++ dotfiles/lein/profiles.clj
@@ -3,21 +3,21 @@
     :plugins [
       [lein-ancient "0.6.15"]
       [lein-bikeshed "0.5.1"]
-      [lein-cljfmt "0.6.3"]
+      [lein-cljfmt "0.6.4"]
       [lein-gen "0.2.2"]
       [lein-kibit "0.1.6"]
       [lein-pprint "1.2.0"]
       [com.jakemccrary/lein-test-refresh "0.23.0"]
-      [cider/cider-nrepl "0.18.0"]
-      [jonase/eastwood "0.3.4"]
+      [cider/cider-nrepl "0.21.1"]
+      [jonase/eastwood "0.3.5"]
       ; [venantius/ultra "0.5.2"]
       [venantius/yagni "0.1.7"]
     ]
     :dependencies [
-      [cljfmt "0.6.3"]
-      [cider/piggieback "0.3.10"]
+      [cljfmt "0.6.4"]
+      [cider/piggieback "0.4.0"]
       [org.clojure/tools.nrepl "0.2.13"]
-      [jonase/eastwood "0.3.4"
+      [jonase/eastwood "0.3.5"
        :exclusions [org.clojure/clojure]]
     ]
     :middleware [


support sending event types

support sending event types

--- src/ninjudd/eventual/server.clj
+++ src/ninjudd/eventual/server.clj
@@ -22,6 +22,8 @@
              (when event
                (when-let [event-id (:event-id (meta event))]
                  (>! out (str "id: " event-id "\n")))
+               (when-let [event-type (:event-type (meta event))]
+                 (>! out (str "event: " event-type "\n")))
                (>! out (str "data: " (f event) "\n\n"))
                (recur))
              (= ch keepalive)


Toggle whether the screen is cleared

Toggle whether the screen is cleared

--- src/blockbuster/core.clj
+++ src/blockbuster/core.clj
@@ -135,13 +135,13 @@
    ["-m" "--pause MILLIS" "Milliseconds to pause between frames"
     :default 0
     :parse-fn #(Long/parseLong %)]
-   ["-c" "--clear" "Whether space should be cleared for the screen"
-    :default true]])
+   ["-c" "--clear" "Whether space should be cleared for the screen"]])

 (defn -main [& args]
   (let [parsed-args (parse-opts args cli-options)
         options (-> parsed-args
                     :options
                     (rename-keys {:file :path}))]
-    (clear-space! options)
+    (when (:clear options)
+      (clear-space! options))
     (draw-movie! options)))


Fix bug in guitar strum direction handling.  Both :up and :down sounded the same!  How did I not notice this before?

Also update code to be more tolerant of odd-sized vectors when specifying frets via the-chord.  For example, a vector of size 3 will just play the top 3 strings, a vector too large will just be truncated.

--- src/overtone/synth/stringed.clj
+++ src/overtone/synth/stringed.clj
@@ -148,8 +148,12 @@
      (let [num-strings (count (chord-fret-map :A))
            ;; ex: [-1 3 2 0 1 0]
            chord-frets (if (vector? the-chord)
-                         ;; FIXME -- assert len(the-chord) is right?
-                         the-chord ; treat the chord as a series of frets
+                         ;; treat the-chord as a series of frets
+                         ;; and gracefully handle odd sized vectors
+                         (vec (take num-strings
+                                    (into the-chord
+                                          (vec (repeat num-strings -1)))))
+                         ;; else use the-chord as an index
                          (chord-fret-map the-chord))
            ;; account for unplayed strings for delta time calc. Code
            ;; gets a bit complicated to deal with the case where
@@ -171,7 +175,7 @@
                     (* 1000 (/ strum-time max-t))
                     0)
                fret-delta (if (= direction :up)
-                            (- max-t (nth fret-times i))
+                            (- max-t (nth fret-times j))
                             (nth fret-times i))]
            (pick-string the-strings the-inst j
                         (nth chord-frets j)


restore missing build messages

restore missing build messages

--- src/cake/main.clj
+++ src/cake/main.clj
@@ -17,7 +17,7 @@

 (defn process-command [[task readline-marker]]
   (binding [*readline-marker* readline-marker]
-    (in-project {:outs System/out :verbose (debug?) :root *root*}
+    (in-project {:outs *outs* :verbose (debug?) :root *root*}
       (doseq [dir ["lib" "classes" "build"]]
         (.mkdirs (file dir)))
       (handler-case :type


Storing facts in a more compact way

Storing facts in a more compact way

--- src/civs/logic/basic.clj
+++ src/civs/logic/basic.clj
@@ -101,7 +101,7 @@
 (def facts (atom []))

 (defn fact [type params]
-  (swap! facts conj {:type type, :params params} ))
+  (swap! facts conj (assoc params :type type)))

 (defn saturate [value max]
   (if (> value max)


Fixing southwest hex calculation

Fixing southwest hex calculation

--- src/clj/zetawar/hex.cljc
+++ src/clj/zetawar/hex.cljc
@@ -30,7 +30,7 @@
     [(inc q) (inc r)]))

 (defn southwest [q r]
-  (if (= (mod q 2) 0)
+  (if (= (mod r 2) 0)
     [(dec q) (inc r)]
     [q (inc r)]))


added delete function

added delete function

--- src/clj_discord/core.clj
+++ src/clj_discord/core.clj
@@ -10,7 +10,7 @@
 (defonce previous-bot (atom -1))
 (defonce bots (atom {}))

-(defn disconnect
+(defn disconnect
   ([]
     (disconnect [0]))
   ([bot]
@@ -22,20 +22,20 @@
         (swap! bots dissoc bot)))))

 (defn connect [params]
-  (let [{:keys [token functions log-events? log-function max-text-message-size bot]
+  (let [{:keys [token functions log-events? log-function max-text-message-size bot]
          :or {functions {}
               log-events? true
               log-function (fn [& args] (println "\n" args))
               max-text-message-size (* 64 1024)
               bot (swap! previous-bot inc)}} params
         token (if (.startsWith token "Bot ") (.trim token) (str "Bot " (.trim token)))
-        params {:token token
-                :functions functions
-                :log-events? log-events?
-                :log-function log-function
-                :max-text-message-size max-text-message-size
+        params {:token token
+                :functions functions
+                :log-events? log-events?
+                :log-function log-function
+                :max-text-message-size max-text-message-size
                 :bot bot}
-
+
         websocket-client (new WebSocketClient (new SslContextFactory))
         heartbeat-thread (Thread. (fn []
                                     (while (:keep-alive (get @bots bot))
@@ -51,11 +51,11 @@
                                                              (log-function "Caught exception: " (.getMessage e))
                                                              (swap! bots update-in [bot] assoc :keep-alive false)
                                                              ))))))]
-
-    (if (contains? @bots bot) (do
+
+    (if (contains? @bots bot) (do
                                 (disconnect bot)
                                 (Thread/sleep 5000)))
-
+
     (swap! bots assoc bot {:params params
                            :keep-alive true
                            :gateway (str
@@ -68,16 +68,16 @@
                            :websocket-client websocket-client
                            :heartbeat-thread heartbeat-thread
                            :control-thread (Thread/currentThread)})
-
+
     (.setMaxTextMessageSize (.getPolicy websocket-client) max-text-message-size)
     (.start websocket-client)
-
+
     (swap! bots update-in [bot] assoc :socket
            (ws/connect
              (:gateway (get @bots bot))
-             :client
+             :client
              websocket-client
-             :on-receive
+             :on-receive
              #(let [received (json/read-str %)
                     logevent (if log-events? (log-function %))
                     op (get received "op")
@@ -88,10 +88,10 @@
                 (if (not (nil? seq)) (swap! bots update-in [bot] assoc :seq seq))
                 (if (not (nil? type)) (doseq [afunction (get functions type (get functions "ALL_OTHER" []))]
                                         (afunction type data))))))
-
+
     (.start heartbeat-thread)
     (Thread/sleep 1000)
-
+
     (ws/send-msg (:socket (get @bots bot)) (json/write-str {:op 2, :d {"token" token
                                                                        "properties" {"$os" "linux"
                                                                                "$browser" "clj-discord"
@@ -99,17 +99,17 @@
                                                                                "$referrer" ""
                                                                                "$referring_domain" ""}
                                                                        "compress" false}}))
-
+
     (while (:keep-alive (get @bots bot)) (Thread/sleep 1000))
     (try
       (connect params)
-      (catch Exception e
+      (catch Exception e
         (do
           (log-function "Caught exception: " (.getMessage e))
           (Thread/sleep 60000)
           (try
             (connect params)
-            (catch Exception e
+            (catch Exception e
               (do
                 (log-function "Caught exception: " (.getMessage e))
                 (log-function "Abandoning the attempts to reconnect bot " bot)
@@ -129,14 +129,14 @@
         previous-activity (:activity (get @bots bot))
         previous-activity (if (nil? previous-activity) 0 previous-activity)
         seconds-since-previous-activity (- now previous-activity)]
-    (if
+    (if
       (> 5 seconds-since-previous-activity)
       false
-      (do
+      (do
         (swap! bots update-in [bot] assoc :activity now)
         true))))

-(defn post-message
+(defn post-message
   ([channel-id message]
     (post-message 0 channel-id message))
   ([bot channel-id message]
@@ -149,7 +149,7 @@
                   :content-type :json
                   :accept :json}))))

-(defn post-message-with-file
+(defn post-message-with-file
   ([channel-id message filename]
     (post-message-with-file 0 channel-id message filename))
   ([bot channel-id message filename]
@@ -161,13 +161,13 @@
                               {:name filename :part_name "file" :content (io/file filename)}]
                   :headers {:authorization (:token (:params (get @bots bot)))}}))))

-(defn post-message-with-mention
+(defn post-message-with-mention
   ([channel-id message user-id]
     (post-message-with-mention 0 channel-id message user-id))
   ([bot channel-id message user-id]
     (post-message bot channel-id (str "<@" user-id ">" message))))

-(defn answer-command
+(defn answer-command
   ([data command answer]
     (answer-command 0 data command answer))
   ([bot data command answer]
@@ -177,3 +177,11 @@
         (get data "channel_id")
         (str " " answer)
         (get (get data "author") "id")))))
+
+(defn delete-message
+  ([data command]
+   (delete-message 0 data command))
+  ([bot data command]
+   (let [channel_id (get data "channel_id") message (get data "id")]
+     (if (and (check-rate-limit bot) (= command (get data "content")))
+       (http/delete (str "https://discordapp.com/api/channels/" channel_id "/messages/" message "?token=" (:token (:params (get @bots bot)))) {:throw-exceptions false})))))


This pattern needs to be revisited, but cancelling out the *go-return-tag* for vars as well if needed.

--- src/cljs/go/compiler.clj
+++ src/cljs/go/compiler.clj
@@ -342,7 +342,7 @@
 (defmethod emit* :no-op [m])

 (defmethod emit* :var
-  [{:keys [info env] :as arg}]
+  [{:keys [info env tag] :as arg}]
   (let [info (cond-> info (:type info) (update-in [:name] go-type-fqn))]
     ; We need a way to write bindings out to source maps and javascript
     ; without getting wrapped in an emit-wrap calls, otherwise we get
@@ -352,14 +352,16 @@
       ; (prevents duplicate fn-param-names)
       (emits (munge arg))
       (when-not (= :statement (:context env))
-        (emit-wrap env (emits (munge (cond ;; this runs munge in a different order from most other things.
-                                      (or ((hash-set ana/*cljs-ns* 'cljs.core) (:ns info))
-                                          (:field info))
-                                      (update-in info [:name] (comp go-public munge name))
-                                      (:ns info)
-                                      (update-in info [:name] #(str (cond-> % (not (string? %)) namespace)
-                                                                    "." (-> % name munge go-public)))
-                                      :else info))))))))
+        (binding [*go-return-tag* (when (go-needs-coercion? tag *go-return-tag*)
+                                    *go-return-tag*)]
+          (emit-wrap env (emits (munge (cond ;; this runs munge in a different order from most other things.
+                                        (or ((hash-set ana/*cljs-ns* 'cljs.core) (:ns info))
+                                            (:field info))
+                                        (update-in info [:name] (comp go-public munge name))
+                                        (:ns info)
+                                        (update-in info [:name] #(str (cond-> % (not (string? %)) namespace)
+                                                                      "." (-> % name munge go-public)))
+                                        :else info)))))))))
 (defmethod emit* :meta
   [{:keys [expr meta env]}]
   (emit-wrap env


Rename fn.

Rename fn.

--- src/cavm/core.clj
+++ src/cavm/core.clj
@@ -49,7 +49,7 @@
     mdata
     {":probeMap" "probeMap" "PLATFORM" "platform"}))

-(defn load-tsv-file [file]
+(defn load-matrix-file [file]
   (with-open [in (io/reader file)]
     (let [{md :meta deps :deps fm :features} (cgdata/matrix-file file)
           md (genomic-renames md)
@@ -152,7 +152,7 @@

 (defn -main [& args]
   (let [[opts extra usage] (apply cli (cons args argspec))
-        load-fn (if (:p opts) load-probemap-file load-tsv-file)]
+        load-fn (if (:p opts) load-probemap-file load-matrix-file)]
     (with-db (create-db (:d opts))
       (cond
         (:help opts) (println usage)


Rename to send-chs.

Rename to send-chs.

--- src/cbfg/net.cljs
+++ src/cbfg/net.cljs
@@ -35,17 +35,17 @@
                                                       (>= ts deliver-at))
                                              [[(:recv-ch stream) msg]])))
                                        streams)
-                  sendables (mapcat (fn [[send-ch stream]]
-                                      (when (and (not (:send-closed stream))
-                                                 (< (count (:msgs stream))
-                                                    (get opts :max-msgs-per-stream 10)))
-                                        [send-ch]))
-                                    streams)
+                  send-chs (mapcat (fn [[send-ch stream]]
+                                     (when (and (not (:send-closed stream))
+                                                (< (count (:msgs stream))
+                                                   (get opts :max-msgs-per-stream 10)))
+                                       [send-ch]))
+                                   streams)
                   chs (-> [request-listen-ch request-connect-ch]
                           (into close-accept-chs)
                           (into close-recv-chs)
                           (into deliverables)
-                          (into sendables)
+                          (into send-chs)
                           (into results))
                   [v ch] (aalts net chs)]
               (cond
@@ -72,7 +72,6 @@
                          server-recv-ch (achan-buf net end-point-buf-size)
                          close-server-recv-ch (achan net)]
                      ; TODO: Need to model running out of ports.
-                     ; TODO: Need to model closing recv-ch's.
                      (recur (inc ts)
                             listens
                             (-> streams
@@ -94,7 +93,7 @@
                    (do (aclose net result-ch)
                        (recur (inc ts) listens streams results)))
                  (net-clean-up net listens streams results))
-               (some #(= ch %) sendables)
+               (some #(= ch %) send-chs)
                (let [send-ch ch
                      stream (get streams send-ch)
                      [msg result-ch] v]


Fix component function

Fix component function

--- src/cljs/gtfve/maps.cljs
+++ src/cljs/gtfve/maps.cljs
@@ -99,7 +99,9 @@
                                 (.setOptions marker (clj->js m-opts))))
       :component-will-unmount (fn [this]
                                 (.setMap marker nil))
-      :component-function (fn [opts]
+      :component-function (fn [opts gmap]
+                            [:noscript])})))
+
                             [:noscript])})))

 (defn map-listen


Reimplementing jump

Reimplementing jump

--- src/cljs/kenny/core.cljs
+++ src/cljs/kenny/core.cljs
@@ -14,7 +14,7 @@
 (def app-state (atom {:text "Hello Chestnut!"
                       :hero {:move false
                              :position {:bottom 560 :left 70}
-                             :jump false
+                             :jump {:time nil :bottom nil}
                              }

                       :grid [[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
@@ -58,7 +58,7 @@

 (defn beneath-1px [position]
   (let [{:keys [left bottom]} position]
-    {:left left :bottom (- bottom 1)}
+    {:left left :bottom (- bottom 5)}
     ))

 (defn left-1px [position]
@@ -71,12 +71,50 @@
     {:left (+ left 1) :bottom bottom}
     ))

+(defn gravity [app]
+  (let [dy (get-in @app [:hero :position :bottom])
+        t (get-in @app [:hero :jump :start])
+        dt (/ (- (.getTime (js/Date.)) t) 1000)
+        vforce (* v dt)
+        gforce (/ (* g dt dt) 2)
+        gv (/ (* g dt) 2)
+        height (+ (- vforce gforce) (current-standing-height))
+        position (get-in @app [:hero :position])
+        ]
+    (if (or
+         (is-solid? @app (first (hero-feet-coords position)))
+         (is-solid? @app (last (hero-feet-coords position)))
+         )
+      (* 70  (last (first (hero-feet-coords @app))))
+      70
+      height
+      ))
+  )
+
+(defn new-gravity [current-vertical jump-time app]
+  (let [dy (get-in app [:hero :position :bottom])
+        starting-bottom (get-in app [:hero :jump :bottom])
+        dt (/ (- (.getTime (js/Date.)) jump-time) 1000)
+        vforce (* 500 dt)
+        gforce (/ (* 1000 dt dt) 2)
+        gv (/ (* 1000 dt) 2)
+        height (+ (- vforce gforce) starting-bottom)
+        ]
+    ;; (if hit-block-above) -> reset :hero :jump :start
+    ;; (if hit-block-below) -> reset :hero :jump :start
+    height
+    )
+  )
+
 (defn vertical-position [app]
   (let [current-vertical (get-in app [:hero :position :bottom])
         current-block-no (most-supportive-block (beneath-1px (get-in app [:hero :position])))]
-    (if (>= current-block-no 1)
-      current-vertical
-      (- current-vertical 1)
+    (if-let [jump-time (get-in app [:hero :jump :start])]
+      (new-gravity current-vertical jump-time app)
+      (if (>= current-block-no 1)
+        current-vertical
+        (- current-vertical 5)
+        )
       )
     ))

@@ -160,8 +198,9 @@
   (condp = (aget e "keyCode")
     88 (om/update! app [:hero :move] :right)
     90 (om/update! app [:hero :move] :left)
-    32 (when-not (get-in @app [:hero :jump])
-         (om/update! app [:hero :jump] (.getTime (js/Date.))))
+    32 (when-not (get-in @app [:hero :jump :start])
+         (om/update! app [:hero :jump :start] (.getTime (js/Date.)))
+         (om/update! app [:hero :jump :bottom] (get-in @app [:hero :position :bottom])))
     nil
     )
   )


Setup opts for commandline

Setup opts for commandline

--- src/cljs/nansi/core.cljs
+++ src/cljs/nansi/core.cljs
@@ -5,6 +5,7 @@
    [clojure.tools.cli :refer [parse-opts]]
    [cljs.core.async :refer [put! alts! chan <! >! timeout close!]]
    [nansi.mirror :as mirror]
+   [nansi.html :as html]
    [cljs.nodejs :as nodejs]))

 (nodejs/enable-util-print!)
@@ -63,13 +64,14 @@

 (def cli-options
   ;; An option with a required argument
-  [["-f" "--file FILE" "Filename"
+  [["-m" "--mirror" "Mirror input"
     ;; :default 80
     ;; :parse-fn #(Integer/parseInt %)
     ;; :validate [#(< 0 % 0x10000) "Must be a valid file"]
     ;; :validate [#(valid-file? %)
     ;;            "Must be a valid file"]
     ]
+   ["-H" "--html" "output escaped html"]
    ;; A non-idempotent option
    ["-v" nil "Verbosity level"
     :id :verbosity
@@ -80,14 +82,16 @@

 (defn -main [& args]
   (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
-    ;; Handle help and error conditions
     (cond
       (:help options) (exit 0 (usage summary))
-      (< (count arguments) 1) (exit 1 (usage summary))
+      (not= (count arguments) 1) (exit 1 (usage summary))
+      (:mirror options) (mirror/output (read-file (first arguments)))
+      (:html options) (html/output (read-file (first arguments)))
       errors (exit 1 (error-msg errors)))

+    #_(println options)
     ;; Execute program with options
-    (case (first arguments)
+    #_(case (first arguments)
       "valid-file" (go (.log js/console (<! (valid-file? "resources/partial.txt"))))
       "read-file" (go (.log js/console (<! (read-file "resources/partial.txt"))))
       ;; "mirror" (mirror/output)


Reuse getCurrentPosition

Reuse getCurrentPosition

--- src/cljs/map.cljs
+++ src/cljs/map.cljs
@@ -77,7 +77,7 @@
     ;; FIXME: first switch to https for panoramap.org
     ;; http://stackoverflow.com/questions/32106849/getcurrentposition-and-watchposition-are-deprecated-on-insecure-origins
     ;; (when (= local 1)
-    ;;   (.getCurrentPosition (.-geolocation js/navigator) geolocalize))
+    (.getCurrentPosition (.-geolocation js/navigator) geolocalize))
     (set! (.-onclick stop) #(set! stopper "stop"))
     (set! (.-onclick sh)
           #(let [z (.getZoom mymap)]


add :reload command to bake server

add :reload command to bake server

--- bake/bake.clj
+++ bake/bake.clj
@@ -19,5 +19,8 @@
   (when (= 0 (bake.swank/num-connections))
     ok))

+(defn reload-files [_]
+  (doseq [file (read)] (load-file file)))
+
 (defn start-server [port]
-  (create-server port eval-multi :quit verify-quit))
+  (create-server port eval-multi :quit verify-quit :reload reload-files))


update version

update version


EIP may no longer be necessary

EIP may no longer be necessary


correctly resume keycard setup after cancel

Signed-off-by: Michele Balistreri <47483730395cccb6448ad7313d5cedb48de25e40@bitgamma.com>

--- src/status_im/keycard/core.cljs
+++ src/status_im/keycard/core.cljs
@@ -50,33 +50,27 @@
             (common/listen-to-hardware-back-button)
             (navigation/navigate-replace :keycard-recovery-pin nil)))

-(fx/defn load-recovery-pin-screen-with-pairings
-  [{:keys [db] :as cofx}]
+(fx/defn load-pairing
+  [{:keys [db]}]
   (let [instance-uid (get-in db [:keycard :application-info :instance-uid])
-        {:keys [pairing paired-on]} (get-in db [:keycard :pairings (keyword instance-uid)])]
-    (fx/merge cofx
-              {:db (-> db
-                       (assoc-in [:keycard :secrets :pairing] pairing)
-                       (assoc-in [:keycard :secrets :paired-on] paired-on))}
-              (load-recovery-pin-screen))))
+        pairing-data (or (get-in db [:keycard :pairings (keyword instance-uid)])
+                         (get-in db [:keycard :pairings instance-uid]))]
+    {:db (update-in db [:keycard :secrets] merge pairing-data)}))

 (fx/defn proceed-setup-with-initialized-card
-  [{:keys [db] :as cofx} flow instance-uid]
+  [{:keys [db] :as cofx} flow instance-uid paired?]
   (log/debug "[keycard] proceed-setup-with-initialized-card"
              "instance-uid" instance-uid)
   (if (= flow :import)
     (navigation/navigate-to-cofx cofx :keycard-recovery-no-key nil)
-    (let [pairing-data (get-in db [:keycard :pairings (keyword instance-uid)])
-          paired? (get-in db [:keycard :application-info :paired?])]
-      (if paired?
-        (fx/merge cofx
-                  {:db (update-in db [:keycard :secrets] merge pairing-data)}
-                  (common/listen-to-hardware-back-button)
-                  (when (= flow :create)
-                    (mnemonic/set-mnemonic))
-                  (when (= flow :recovery)
-                    (onboarding/proceed-with-generating-key)))
-        (recovery/load-pair-screen cofx)))))
+    (if paired?
+      (fx/merge cofx
+                (common/listen-to-hardware-back-button)
+                (when (= flow :create)
+                  (mnemonic/set-mnemonic))
+                (when (= flow :recovery)
+                  (onboarding/proceed-with-generating-key)))
+      (recovery/load-pair-screen cofx))))

 (fx/defn navigate-to-keycard-settings
   {:events [:profile.ui/keycard-settings-button-pressed]}
@@ -524,9 +518,12 @@
               (set-setup-step card-state)
               (common/hide-connection-sheet)

+              (when paired?
+                (load-pairing))
+
               (when (and flow
                          (= card-state :init))
-                (proceed-setup-with-initialized-card flow instance-uid))
+                (proceed-setup-with-initialized-card flow instance-uid paired?))

               (when (= card-state :pre-init)
                 (if (= flow :import)
@@ -542,7 +539,7 @@
                 (if (common/find-multiaccount-by-key-uid db key-uid)
                   (multiaccounts.recover/show-existing-multiaccount-alert key-uid)
                   (if paired?
-                    (load-recovery-pin-screen-with-pairings)
+                    (load-recovery-pin-screen)
                     (recovery/load-pair-screen))))

               (when (= card-state :blank)


🏗 Parse instants of various formats

🏗 Parse instants of various formats

--- src/territory_bro/migration.clj
+++ src/territory_bro/migration.clj
@@ -3,7 +3,9 @@
 ;; The license text is at http://www.apache.org/licenses/LICENSE-2.0

 (ns territory-bro.migration
-  (:require [clojure.tools.logging :as log]
+  (:require [clojure.string :as str]
+            [clojure.test :refer [deftest is testing]]
+            [clojure.tools.logging :as log]
             [territory-bro.config :as config]
             [territory-bro.congregation :as congregation]
             [territory-bro.db :as db]
@@ -11,7 +13,42 @@
             [territory-bro.gis-user :as gis-user]
             [territory-bro.region :as region]
             [territory-bro.territory :as territory]
-            [territory-bro.user :as user]))
+            [territory-bro.user :as user])
+  (:import (java.time Instant OffsetDateTime ZoneOffset ZoneId ZonedDateTime)
+           (java.time.format DateTimeFormatter DateTimeParseException)))
+
+(def patterns [(DateTimeFormatter/ofPattern "EE LLL d y H:m:s 'GMT'Z")
+               (-> (DateTimeFormatter/ofPattern "d LLL H:m:s y")
+                   (.withZone (ZoneId/of "Europe/Helsinki")))
+               (DateTimeFormatter/ofPattern "EE, d LLL y H:m:s Z")])
+
+(defn- parse-instant [s]
+  (let [parsed (->> patterns
+                    (map (fn [pattern]
+                           (try
+                             (-> s
+                                 (ZonedDateTime/parse pattern)
+                                 (.toInstant))
+                             (catch DateTimeParseException e
+                               (str e "\n\t for pattern: " pattern))))))]
+    (or (->> parsed
+             (filter (partial instance? Instant))
+             first)
+        (throw (RuntimeException. (str "Could not parse '" s "'\n" (str/join "\n" parsed)))))))
+
+(deftest parse-instant-test
+  (is (= (.toInstant (OffsetDateTime/of 2015 12 27
+                                        19 32 0 0
+                                        (ZoneOffset/ofHours 2)))
+         (parse-instant "Sun Dec 27 2015 19:32:00 GMT+0200")))
+  (is (= (.toInstant (OffsetDateTime/of 2015 11 7
+                                        22 44 53 0
+                                        (ZoneOffset/ofHours 2)))
+         (parse-instant "7 Nov 22:44:53 2015")))
+  (is (= (.toInstant (OffsetDateTime/of 2016 2 19
+                                        18 40 18 0
+                                        (ZoneOffset/ofHours 2)))
+         (parse-instant "Fri, 19 Feb 2016 18:40:18 +0200"))))

 (defn migrate-congregation [tenant]
   (db/as-tenant tenant


CMR-4579 - Use the latest EDSC stubbed data with new concept-id.

--- search-app/project.clj
+++ search-app/project.clj
@@ -17,7 +17,7 @@
                                org.clojure/tools.reader
                                org.clojure/java.jdbc
                                ring/ring-codec]]
-                 [gov.nasa.earthdata/cmr-edsc-stubs "0.1.0-SNAPSHOT"
+                 [gov.nasa.earthdata/cmr-edsc-stubs "0.2.0-SNAPSHOT"
                   :exclusions [cljs-http
                                clj-http
                                com.google.code.findbugs/jsr305


finished chatpter 3 dissatisfied with the macros

--- chap_03.clj
+++ chap_03.clj
@@ -75,3 +75,36 @@
 ; usage for artist-selector
 ; (filter (cddb/artist-selector "Dixie Chicks") (cddb/init-db))

+; more general (but allows "bad" keys to be specified)
+(defn where [criteria]
+  (fn [cd]
+    (loop [criteria criteria]
+      (let [[k,v] (first criteria)]
+	(or (not k)
+	    (and (= (k cd) v) (recur (rest criteria))))))))
+
+; in Clojure it is idiomatic for the functional argument to come first
+(defn update [db criteria updates]
+  (map
+   (fn [cd]
+     (if (criteria cd)
+       (merge cd updates)
+       cd))
+   db))
+
+(defmacro backwards [expr] (reverse expr))
+
+; create a var for make-comparison-expr to use (should make this private)
+(def where-cd nil)
+
+; destructuring in anticipation of make-comparisons-list
+(defn make-comparison-expr [[field value]]
+  `(= (~field where-cd) ~value))
+
+(defn make-comparisons-list [criteria]
+  (map make-comparison-expr criteria))
+
+(defmacro where [criteria]
+  `(fn [cd#]
+     (binding [where-cd cd#]
+       (and ~@(make-comparisons-list criteria)))))


Add a random property to world state

Add a random property to world state

--- src/constraint/core.cljs
+++ src/constraint/core.cljs
@@ -96,6 +96,10 @@
   (merge state {:editing? false
                 :selected nil}))

+(defn reset-random
+  [state]
+  (merge state {:random false}))
+
 (def interval 20)

 (def ticker (atom interval))
@@ -108,24 +112,30 @@

 (defn get-random-legal-move-name
   [world-state]
-  (first (rand-nth (get-legal-moves world-state)))
+  (->> world-state
+       get-legal-moves
+       rand-nth
+       first))

 (defn random-move
   [_ world-state]
-  (swap! ticker dec)
-  (if (neg? @ticker)
+  (if (:random world-state)
     (do
-      (reset! ticker interval)
-      (let [random-move-name (get-random-legal-move-name world-state)]
-        (flip-update-edge random-move-name world-state)))
+      (swap! ticker dec)
+      (if (neg? @ticker)
+        (do
+          (reset! ticker interval)
+          (let [random-move-name (get-random-legal-move-name world-state)]
+            (flip-update-edge random-move-name world-state)))
+        world-state))
     world-state))
+

 (go
   (let [read-state (reader/read-string (<! (GET "./state.edn")))]
     (big-bang!
-      :initial-state (reset-edit read-state)
+      :initial-state (->> read-state reset-edit reset-random)
       :to-draw draw-world
       :on-tick random-move
-      :on-click update-state))
-  )
+      :on-click update-state)))


Fix ns docstring codestyle on sign.impl ns.


Remove dummy file

Remove dummy file

--- src/bbloom/vdom.clj
+++ src/bbloom/vdom.clj
@@ -1,6 +0,0 @@
-(ns bbloom.vdom)
-
-(defn foo
-  "I don't do a whole lot."
-  [x]
-  (println x "Hello, World!"))


Fix key.

Fix key.

--- src/cavm/cgdata.clj
+++ src/cavm/cgdata.clj
@@ -217,7 +217,7 @@
   (let [mfile (io/as-file (str file ".json"))]
     (if (.exists mfile)
       (json/read-str (slurp mfile))
-      {:name file})))
+      {"name" file})))

 (defn- path-from-root
   "Return file path relative to root"


require not import

require not import

--- src/fogus/me/trammel.clj
+++ src/fogus/me/trammel.clj
@@ -1,6 +1,5 @@
 (ns fogus.me.trammel
-  (:include '[clojure.test :as test]))
+  (:require '[clojure.test :as test]))

 (defmacro defcontract [& specs]
   nil)
-


Fixing docstring for next-closed-set

Fixing docstring for next-closed-set

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

--- src/conexp/base.clj
+++ src/conexp/base.clj
@@ -123,7 +123,8 @@
                               start))))))

 (defn next-closed-set
-  "Computes next closed set with the Next Closure Algorithm. The order of elements in base,
+  "Computes next closed set of the closure operator clop after A with
+  the Next Closure algorithm. The order of elements in base,
   interpreted as increasing, is taken to be the basic order of the
   elements."
   [base clop A]


Requiring clojure.test explicitly

Requiring clojure.test explicitly

and adding some explicit namespace references

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

--- src/conexp/util.clj
+++ src/conexp/util.clj
@@ -95,19 +95,19 @@

 ;;; Testing

+(require 'clojure.test)
+
 (defn test-conexp
   "Runs tests for conexp. If with-contrib? is given and true, tests
   conexp.contrib.tests too."
   ([] (test-conexp false))
   ([with-contrib?]
      (if with-contrib?
-       (do (require 'clojure.test
-                    'conexp.tests
+       (do (require 'conexp.tests
                     'conexp.contrib.tests)
            (clojure.test/run-tests 'conexp.tests
                                    'conexp.contrib.tests))
-       (do (require 'clojure.test
-                    'conexp.tests)
+       (do (require 'conexp.tests)
            (clojure.test/run-tests 'conexp.tests)))))

 (defmacro tests-to-run
@@ -116,12 +116,12 @@
   current namespace, before all other tests in supplied as arguments."
   [& namespaces]
   `(defn ~'test-ns-hook []
-     (test-all-vars '~(ns-name *ns*))
+     (clojure.test/test-all-vars '~(ns-name *ns*))
      (doseq [ns# '~namespaces]
-       (let [result# (do (require ns#) (test-ns ns#))]
+       (let [result# (do (require ns#) (clojure.test/test-ns ns#))]
          (dosync
-          (ref-set *report-counters*
-                   (merge-with + @*report-counters* result#)))))))
+          (ref-set clojure.test/*report-counters*
+                   (merge-with + @clojure.test/*report-counters* result#)))))))

 (defmacro with-testing-data
   "Expects for all bindings the body to be evaluated to true. bindings
@@ -137,8 +137,8 @@
                  (if-not result#
                    ~(let [vars (vec (remove keyword? (take-nth 2 bindings)))]
                       `(do (println "Test failed for" '~vars "being" ~vars)
-                           (is false)))
-                   (is true))))
+                           (clojure.test/is false)))
+                   (clojure.test/is true))))
             body)))

 ;;; Types


Minor changes |cb

Minor changes |cb

--- src/cljs/conference_rating/conference_detail_page/conference_detail_page.cljs
+++ src/cljs/conference_rating/conference_detail_page/conference_detail_page.cljs
@@ -99,17 +99,17 @@

 ;;TODO show badges for experience level (in navy lue), too

-  (defn conference-badges [simple-conference]
-    (let [dev-count (get-in simple-conference [:aggregated-ratings :roles :dev])]
-    [:div
-     (conference-badges-row (if (> dev-count 0) [badge (str "DEV " dev-count) "badge-light-blue"])
-                            (badge "QA" "badge-light-blue")
-                            (badge "BA" "badge-light-blue"))
-     (conference-badges-row (badge "Inspiring" "badge-light-primary")
-                            (badge "learnings" "badge-light-primary")
-                            (badge "Network" "badge-light-primary")
-                            (badge "Hires" "badge-light-primary")
-                            (badge "Clients" "badge-light-primary"))]))
+(defn conference-badges [simple-conference]
+  (let [dev-count (get-in simple-conference [:aggregated-ratings :roles :dev])]
+  [:div
+   (conference-badges-row (if (> dev-count 0) [badge (str "DEV " dev-count) "badge-light-blue"])
+                          (badge "QA" "badge-light-blue")
+                          (badge "BA" "badge-light-blue"))
+   (conference-badges-row (badge "Inspiring" "badge-light-primary")
+                          (badge "learnings" "badge-light-primary")
+                          (badge "Network" "badge-light-primary")
+                          (badge "Hires" "badge-light-primary")
+                          (badge "Clients" "badge-light-primary"))]))

 (defn conference-average-attendee [simple-conference]
   [:div


Bug fix for selecting wombat.

Bug fix for selecting wombat.

--- src/cljs/wombats_web_client/components/modals/join-wombat-modal.cljs
+++ src/cljs/wombats_web_client/components/modals/join-wombat-modal.cljs
@@ -50,7 +50,7 @@
                              :opacity "0.8"}}
       [:img {:src "/images/checkmark.svg"}]]
      [:img {:src (str "/images/wombat_" color-text "_right.png")
-            :onClick #(reset! wombat-color-selection color-text)}]]))
+            :onClick #(swap! cmpnt-state assoc :wombat-color color-text)}]]))

 (defn select-wombat-color [cmpnt-state selected-color]
   [:div.select-color


place test output in out dir

place test output in out dir

--- src/crison/core.clj
+++ src/crison/core.clj
@@ -77,5 +77,5 @@
 (defn run [input-d output-d]
   (binding [*input-dir* input-d
             *output-dir* output-d
-            *test-out* (writer (str (date) "-tests.txt"))]
+            *test-out* (writer (str output-d (date) "-tests.txt"))]
     (run-tests 'crison.core)))


Don't use default port names for transport test

--- test/riemann/transport_test.clj
+++ test/riemann/transport_test.clj
@@ -26,8 +26,8 @@
            ["riemann.transport"
             "riemann.core"
             "riemann.pubsub"]
-           (let [server (ws-server)
-                 uri    "http://127.0.0.1:5556/events"
+           (let [server (ws-server {:port 15556})
+                 uri    "http://127.0.0.1:15556/events"
                  core   (transition! (core) {:services [server]})]
              ; Two simple events
              (let [res (http/put uri
@@ -53,8 +53,8 @@
 (deftest sse-subscribe-events-test
   (riemann.logging/suppress
    ["riemann.transport" "riemann.core" "riemann.pubsub"]
-   (let [s1       (tcp-server)
-         s2       (sse-server)
+   (let [s1       (tcp-server {:port 15555})
+         s2       (sse-server {:port 15558})
          core     (core)
          index    (wrap-index (index/index) (:pubsub core))
          pubsub   (pubsub/pubsub-registry)
@@ -64,14 +64,14 @@
                     :pubsub   pubsub
                     :services [s1 s2]
                     :streams  [index]})
-         client   (client/tcp-client)
+         client   (client/tcp-client {:port 15555})
          convert  (comp json/parse-string
                         second
                         (partial re-matches #"data: (.*)\n\n")
                         formats/bytes->string)
          response @(http-request
                      {:method :get
-                      :url    "http://127.0.0.1:5558/index?query=true"})]
+                      :url    "http://127.0.0.1:15558/index?query=true"})]
      (try
        (client/send-event client {:service "service1"})
        (client/send-event client {:service "service2"})
@@ -89,7 +89,7 @@
          (riemann.logging/suppress ["riemann.transport"
                                     "riemann.core"
                                     "riemann.pubsub"]
-           (let [server (udp-server)
+           (let [server (udp-server {:port 15555})
                  core   (transition! (core) {:services [server]})
                  client (wait-for-result (udp-socket {}))
                  msg (ChannelBuffers/wrappedBuffer
@@ -97,7 +97,7 @@

              (try
                (enqueue client {:host "localhost"
-                                :port 5555
+                                :port 15555
                                 :message msg})
                (Thread/sleep 100)
                (finally
@@ -131,11 +131,13 @@
   (let [server {:tls? true
                 :key "test/data/tls/server.pkcs8"
                 :cert "test/data/tls/server.crt"
-                :ca-cert "test/data/tls/demoCA/cacert.pem"}
+                :ca-cert "test/data/tls/demoCA/cacert.pem"
+                :port 15555}
         client {:tls? true
                 :key "test/data/tls/client.pkcs8"
                 :cert "test/data/tls/client.crt"
-                :ca-cert "test/data/tls/demoCA/cacert.pem"}]
+                :ca-cert "test/data/tls/demoCA/cacert.pem"
+                :port 15555}]
     ; Works with valid config
     (test-tcp-client client server)

@@ -163,12 +165,12 @@
          (riemann.logging/suppress ["riemann.transport"
                                     "riemann.core"
                                     "riemann.pubsub"]
-            (let [server (tcp-server)
+            (let [server (tcp-server {:port 15555})
                   core   (transition! (core) {:services [server]})
                   client (wait-for-result
                            (aleph.tcp/tcp-client
                              {:host "localhost"
-                              :port 5555
+                              :port 15555
                               :frame (finite-block :int32)}))]

               (try


Added the ability to edit pages.

Added the ability to edit pages.

--- src/ackbar/core.clj
+++ src/ackbar/core.clj
@@ -5,13 +5,12 @@
             [clojure.contrib.str-utils2 :as s])
   (:import com.google.appengine.api.datastore.EntityNotFoundException))

-(ds/defentity Page [^:key name, body])
+(ds/defentity Page [^:key title, body])

-(defn canonical-name
-  "Converts a given page name to a standard format, suitable for use in a URL."
+(defn canonical-title
+  "Converts a given page title to a standard format, suitable for use in a URL."
   [str]
   (s/replace (s/replace (.toLowerCase str) #"\s+" "_") #"\W+" ""))
-

 (defn wrap-result [result]
   {:status 200
@@ -31,49 +30,51 @@

 (defn render-page
   "Retrieve a page from the datastore and render it for display to the user"
-  [name]
+  [title]
   (try
-    (response-wrapper name (:body (ds/retrieve Page name)))
+    (response-wrapper title (:body (ds/retrieve Page title)))
     (catch EntityNotFoundException _
-      (response-wrapper "404" (str "Unable to find page: " name) 404))))
+      (response-wrapper "404" (str "Unable to find page: " title) 404))))

+(defn add-or-edit-form
+  "Returns a form to add or edit a page."
+  ([url] (add-or-edit-form url "" ""))
+  ([url title body]
+     (form-to [:post url]
+              (label "title" "Title:") [:br]
+              (text-field "title" title) [:br]
+              (label "body" "Body:") [:br]
+              (text-area {:cols 80 :rows 40} "body" body) [:br]
+              (submit-button "Submit"))))
+
 (defn admin-add-page
   "Displays the Ackbar Admin 'Add Page' Page"
   []
   (response-wrapper "Add Page"
-                    (form-to [:post "/admin/add"]
-                             (label "title" "Title:")
-                             [:br]
-                             (text-field "title")
-                             [:br]
-                             (label "body" "Body:")
-                             [:br]
-                             (text-area {:cols 80 :rows 40} "body")
-                             [:br]
-                             (submit-button "Submit")
-                             )))
+                    (add-or-edit-form "/admin/add")))

 (defn add-page
   "Adds a page to the database with the specified title and content"
   [title body]
-  (ds/save! (Page. (canonical-name title) body))
-  (result "Page saved!")
-  )
+  (if (ds/exists? Page title)
+    (result "ERROR: Page already exists!")
+    (do (ds/save! (Page. (canonical-title title) body))
+        (result "Page saved!"))))

 (defn page-link
   "Builds a link to the specified page object"
   [page]
-  (link-to (str "/" (:name page)) (:name page)))
+  (link-to (str "/" (:title page)) (:title page)))

 (defn edit-link
   "Builds a link to edit the specified page"
   [page]
-  (link-to (str "/admin/edit/" (:name page)) "edit"))
+  (link-to (str "/admin/edit/" (:title page)) "edit"))

 (defn delete-link
   "Builds a link to delete the specified page"
   [page]
-  (form-to [:post (str "/admin/delete/" (:name page))]
+  (form-to [:post (str "/admin/delete/" (:title page))]
            (submit-button "Delete")))

 (defn admin-page-list
@@ -88,31 +89,47 @@
                               (edit-link page) (delete-link page)])])))

 (defn delete-page
-  "Deletes the specified page by name."
-  [name]
-    (try
-      (do (ds/delete! (ds/retrieve Page name))
-          (response-wrapper "Deleted"
-                            (str "Page deleted: " name)))
+  "Deletes the specified page by title."
+  [title]
+  (try
+    (do (ds/delete! (ds/retrieve Page title))
+        (response-wrapper "Deleted"
+                          (str "Page deleted: " title)))

     (catch EntityNotFoundException _
-      (response-wrapper "404" (str "Unable to find page: " name) 404))))
+      (response-wrapper "404" (str "Unable to find page: " title) 404))))

 (defn admin-edit-page
   "Displays the Ackbar Admin 'Edit Page' Page"
-  []
-  (result "Admin Edit Page"))
+  [title]
+  (try
+    (def page (ds/retrieve Page title))
+    (response-wrapper "Edit Page"
+                      (add-or-edit-form "/admin/edit"
+                                        (:title page)
+                                        (:body page)))
+    (catch EntityNotFoundException _
+      (response-wrapper "404" (str "Unable to find page: " title) 404))))

+(defn edit-page
+  "Edits a page, updating its title and content"
+  [title body]
+  (if (ds/exists? Page (canonical-title title))
+    (ds/delete! (ds/retrieve Page (canonical-title title))))
+  (ds/save! (Page. (canonical-title title) body))
+  (result "Page updated!"))
+
 (defroutes ackbar-app-handler
   (GET "/" [] (render-page "home"))
   (GET "/admin/add" [] (admin-add-page))
   (GET "/admin/pages" [] (admin-page-list))
   (POST "/admin/add" {params :params}
         (add-page (params "title") (params "body")))
-  (GET "/admin/edit/:name" [name] (admin-edit-page name))
-  (POST "/admin/edit/:name" [name params] (render-page "edit page post"))
-  (POST "/admin/delete/:name" [name] (delete-page name))
-  (GET "/:name" [name] (render-page (canonical-name name)))
+  (GET "/admin/edit/:title" [title] (admin-edit-page title))
+  (POST "/admin/edit" {params :params}
+        (edit-page (params "title") (params "body")))
+  (POST "/admin/delete/:title" [title] (delete-page title))
+  (GET "/:title" [title] (render-page (canonical-title title)))
   (ANY "*" [] (response-wrapper "404" "NOT FOUND!" 404)))

 (ae/def-appengine-app ackbar-app #'ackbar-app-handler)


rename LocalNode => ClusterNode

rename LocalNode => ClusterNode

See this crux commit https://github.com/juxt/crux/commit/63133e9e9ce460741ddfba50869e9db5971034a7#diff-227053ed026509ec67b4b0f20b016440

--- lib/crux.ig/src/juxt/crux/ig/system.clj
+++ lib/crux.ig/src/juxt/crux/ig/system.clj
@@ -41,6 +41,6 @@
   [_ opts]
   (crux.api/start-standalone-system opts))

-(defmethod ig/init-key ::local-node
+(defmethod ig/init-key ::cluster-node
   [_ opts]
-  (crux.api/start-local-node opts))
+  (crux.api/start-cluster-node opts))


Prioritise vars which are matched to constants

--- src/aurora/language.cljs
+++ src/aurora/language.cljs
@@ -249,7 +249,8 @@
                     (doseq [[_ field-type key val] (@clause-id->fields clause-id)]
                       (assert (= field-type "variable") [rule-id clause-id key val])
                       (aset fields (var->ix val) key))
-                    (Sink. clause-type name fields)))]
+                    (Sink. clause-type name fields)))
+        rule-id->var->constant? (atom {})]

     ;; rewrite clauses
     (doseq [[rule-id clauses] @rule-id->clauses]
@@ -262,6 +263,7 @@
               ;; rewrite (foo 1) to (foo x) (=constant x 1)
               (let [new-var (new-id)
                     new-clause-id (new-id)]
+                (swap! rule-id->var->constant? assoc-in [clause-id val] true)
                 (swap! clause-id->fields update-in [clause-id] disj [clause-id "constant" key val])
                 (swap! clause-id->fields update-in [clause-id] conj [clause-id "variable" key new-var])
                 (swap! clause-id->fields assoc new-clause-id #{[new-clause-id "variable" "variable" new-var]
@@ -360,7 +362,11 @@
               (when (= field-type "variable")
                 (swap! var->when-count update-in [val] #(+ (or % 0) (if (= clause-type "when") 1 0)))))))

-        (let [vars (map first (reverse (sort-by val @var->when-count)))
+        (let [var->priority (for [[var when-count] @var->when-count]
+                              (if (get-in @rule-id->var->constant? [rule-id var])
+                                js/Infinity
+                                when-count))
+              vars (map first (reverse (sort-by val @var->when-count)))
               var->ix (zipmap vars (range))
               num-vars (count vars)


Sketch query compiler

Sketch query compiler

--- src/aurora/language.cljs
+++ src/aurora/language.cljs
@@ -298,7 +298,7 @@
 (def empty-flow-plan
   (FlowPlan. [(Union. #{}) (Union. #{}) (Union. #{}) (Union. #{})] {}))

-(defn output-flow [flow-plan node memory]
+(defn add-output [flow-plan node memory]
   (update-in flow-plan [:node->flow (memory->node memory) :nodes] conj node))

 (defn add-flow [{:keys [node->flow flow->node] :as flow-plan} flow]
@@ -323,7 +323,7 @@
         [plan edges-lookup] (add-flow plan (Lookup. [edges-index] connecteds-index #js [1] #js [0 3]))
         [plan connecteds-lookup] (add-flow plan (Lookup. [connecteds-index] edges-index #js [0] #js [2 1]))
         [plan new-connecteds] (add-flow plan (FilterMap. [edges edges-lookup connecteds-lookup] (fn [x] (->connected (fact-ix x 0) (fact-ix x 1)))))
-        plan (output-flow plan new-connecteds :pretended)
+        plan (add-output plan new-connecteds :pretended)
         state (flow-plan->flow-state plan)]
     (apush* (aget (:node->facts state) 0) #js [(->edge 0 1) (->edge 1 2) (->edge 2 3) (->edge 3 1)])
     (-> (fixpoint state) :node->state (aget 1) persistent!))
@@ -432,32 +432,58 @@
 (defrecord Recall [memory pattern]) ;; memory is one of :known :pretended :remembered :forgotten :known&pretended
 (defrecord Compute [pattern])
 (defrecord Output [memory pattern]) ;; memory is one of :pretended :remembered :forgotten
-(defrecord OutputMany [memory vars expr]) ;; memory is one of :pretended :remembered :forgotten
+;; (defrecord OutputMany [memory vars expr]) ;; memory is one of :pretended :remembered :forgotten

 ;; horrible non-relational things
 (deffact Let "Let [name] be the result of [vars] [expr]")
 (deffact When "When [vars] [expr]")

-;; if clause can be calculated somehow then return a new [plan node shape] pair that calculates it
+(defn recall->node [plan {:keys [memory pattern]}]
+  (let [[plan node] (add-flow plan (FilterMap. (memory->nodes memory) (pattern->deconstructor pattern)))]
+    [plan node (pattern->vars pattern)]))
+
+;; if clause can be calculated somehow then return a new [plan node vars] pair that calculates it
 ;; TODO make this extensible
-(defn compute? [plan node shape {:keys pattern}]
+(defn compute->node [plan node vars {:keys [pattern]}]
   (condp = (.-shape pattern)
-    Let (when (every? (set shape) (:vars pattern))
-          (let [let-fun (expr->fun shape (:expr pattern))
+    Let (when (every? (set vars) (:vars pattern))
+          (let [let-fun (expr->fun vars (:expr pattern))
                 filter-map-fun (fn [fact]
                                  (let [new-value (.apply let-fun (.-values fact))
                                        new-values (aclone (.-values fact))]
                                    (apush new-values new-value)
                                    (Fact. nil new-values)))
                 [plan node] (add-flow plan (->FilterMap [node] filter-map-fun))]
-            [plan node (conj shape (:name pattern))]))
-    When (when (every? (set shape) (:vars pattern))
-           (let [when-fun (expr->fun shape (:expr pattern))
+            [plan node (conj vars (:name pattern))]))
+    When (when (every? (set vars) (:vars pattern))
+           (let [when-fun (expr->fun vars (:expr pattern))
                  filter-map-fun (fn [fact]
                                   (when (.apply when-fun (.-values fact))
                                     fact))
                  [plan node] (add-flow plan (->FilterMap [node] filter-map-fun))]
-             [plan node shape]))))
+             [plan node vars]))))
+
+(defn computes->node [plan node vars computes]
+  (let [orig-node node] ;; too much shadowing :S
+    (loop [plan plan
+           node node
+           vars vars
+           computes-remaining computes
+           computes-unapplied []]
+      (if-let [[compute & computes-remaining] (seq computes-remaining)]
+        (if-let [[new-plan new-node new-vars] (compute->node plan node vars compute)]
+          (recur new-plan new-node new-vars computes-remaining computes-unapplied)
+          (recur plan node vars computes-remaining (conj computes-unapplied compute)))
+        (if (= node orig-node)
+          [plan node vars computes-unapplied]
+          (computes? plan node vars computes-unapplied))))))
+
+(defn output->node [plan node vars {:keys [memory pattern]}]
+  (assert (every? (set vars) (pattern->vars pattern)))
+  (let [[plan output-node] (add-flow plan (FilterMap. [node] (pattern->constructor pattern)))
+        plan (add-output plan output-node memory)]
+    plan))
+

 ;; RULES

@@ -472,13 +498,15 @@

 ;; Correctness: Each clause must appear at least once in the plan
 ;; Heuristic: Each Recall clause is used at most once in the plan
-;; Heuristic: Each Filter/Let clause is used at most once per path in the pln
-
-(defn rule->flow-plan [flow-plan rule]
-  (loop [flow-plan flow-plan
-         shape []
-         clauses (:clauses rule)]
-    (if-let [[new-flow-plan new-shape clause] (first (map #(clause->flow-plan flow-plan shape %) clauses))]
-      (recur new-flow-plan new-shape (filter #(not= clause %) clauses))
-      (do (assert (empty? clauses) (str "Cannot join " (pr-str shape) " with " (pr-str clauses)))
-        flow-plan))))
+;; Heuristic: Each Filter/Let clause is used at most once per path in the plan
+
+
+(defn rule->flow-plan [rule]
+  (let [recalls (filter #(= Recall (type %)) (:clauses rule))
+        computes (filter #(= Compute (type %)) (:clauses rule))
+        outputs (filter #(= Output (type %)) (:clauses rule))
+        computes? (fn [plan node vars computes]
+                    (if-let [[plan node vars] (first (map #(compute? plan node vars) computes)))
+        node->remaining-computes (reduce recalls empty-flow-plan )]
+    (loop [plan plan
+           node->remaining-computes (zipmap recall-nodes (repeat computes))])


exit on UnsatisfiedLinkError since there is no way to recover

--- src/cake/server.clj
+++ src/cake/server.clj
@@ -65,6 +65,10 @@
    :quit        quit
    :repl        repl})

+(defn fatal? [e]
+  (and (instance? clojure.lang.Compiler$CompilerException e)
+       (instance? UnsatisfiedLinkError (.getCause e))))
+
 (defn- create* [port f commands]
   (let [commands (apply hash-map commands)]
     (server-socket/create-server port
@@ -81,7 +85,8 @@
                   (command))
                 (f form))
               (catch Exception e
-                (print-stacktrace e))))))
+                (print-stacktrace e)
+                (when (fatal? e) (System/exit 1)))))))
       0 (InetAddress/getByName "localhost"))))

 (defn create [port f & commands]


Adds a docstring for functions

Adds a docstring for functions


Refactor influxdb client to accept sequences of events.

--- src/riemann/influxdb.clj
+++ src/riemann/influxdb.clj
@@ -3,17 +3,40 @@
   (:require [capacitor.core :as influx])
   (:use [clojure.string :only [join split]]))

-(defn influxdb-series
-  "Constructs a series name for an event."
-  [opts event]
-  ((:series opts) event))
-
+(defn event->point
+  "Transform a Riemann event to an InfluxDB point, or nil if the event is
+  missing a metric or service."
+  [event]
+  (when (and (:metric event) (:service event))
+    {:name (:service event)
+     :host (or (:host event) "")
+     :state (:state event)
+     :value (:metric event)}))
+
+(defn events->points
+  "Takes a series fn that finds the series for a given event, and a sequence of
+  events, and emits a map of series names to vectors of points for that series."
+  [series-fn events]
+  (persistent!
+    (reduce (fn [m event]
+              (let [series (or (series-fn event) "riemann-events")
+                    point  (event->point event)]
+                (if point
+                  (assoc! m series (conj (get m series []) point))
+                  m)))
+            (transient {})
+            events)))
+
 (defn influxdb
-  "Returns a function which accepts an event and sends it to InfluxDB.
+  "Returns a function which accepts an event, or sequence of events, and sends
+  it to InfluxDB.

-  ;; For giving series name as the concatenation of :host and :service fields with dot separator.
+  ; For giving series name as the concatenation of :host and :service fields
+  ; with dot separator.

-  (influxdb {:host \"play.influxdb.org\" :port 8086 :series #(str (:host %) \".\" (:service %))})
+  (influxdb {:host   \"play.influxdb.org\"
+             :port   8086
+             :series #(str (:host %) \".\" (:service %))})

   Options:

@@ -24,9 +47,10 @@
   :username       Name of the user who is allowed to push metrics to this DB.

   :password       Password of the corresponding user.
-
-  :series         Name of the InfluxDB's time-series. Default value is :service field of event,
-                  incase that is nil, \"riemann-events\" will be the default name."
+
+  :series         Function which takes an event and returns the InfluxDB series
+                  name to use. Defaults to :service. If this function returns
+                  nil, series names default to \"riemann-events\"."
   [opts]
   (let [opts (merge {:host "127.0.0.1"
                      :port 8086
@@ -34,12 +58,14 @@
                      :username "root"
                      :password "root"
                      :db "riemann"
-                     :series :service} opts)
+                     :series :service}
+                    opts)
+        series (:series opts)
         client (influx/make-client opts)]
-    (fn [event]
-      (when (:metric event)
-        (when (:service event)
-          (influx/post-points client (if-let [series (influxdb-series opts event)] series "riemann-events") [{ :name (:service event)
-                                                                                :host (if-let [hostname (:host event)] hostname "")
-                                                                                :state (:state event)
-                                                                                :value (:metric event) }]))))))
+
+    (fn stream [events]
+      (let [events (if (sequential? events) events (list events))
+            points (events->points series events)]
+        (when-not (empty? points)
+          (doseq [[series points] points]
+            (influx/post-points client series points)))))))


GAWB-2189: spacing

GAWB-2189: spacing

--- src/cljs/main/broadfcui/page/workspace/method_configs/method_config_editor.cljs
+++ src/cljs/main/broadfcui/page/workspace/method_configs/method_config_editor.cljs
@@ -47,12 +47,12 @@
    (fn [{:keys [props state]} & [method-ref]]
      (let [{:keys [namespace name snapshotId]} (or method-ref props)]
        (endpoints/call-ajax-orch
-         {:endpoint (endpoints/get-agora-method namespace name snapshotId)
-          :headers utils/content-type=json
-          :on-done (fn [{:keys [success? get-parsed-response status-text]}]
-                     (if success?
-                       (swap! state assoc :loaded-method (get-parsed-response))
-                       (swap! state assoc :error status-text)))})))})
+        {:endpoint (endpoints/get-agora-method namespace name snapshotId)
+         :headers utils/content-type=json
+         :on-done (fn [{:keys [success? get-parsed-response status-text]}]
+                    (if success?
+                      (swap! state assoc :loaded-method (get-parsed-response))
+                      (swap! state assoc :error status-text)))})))})

 (defn- input-output-list [{:keys [values ref-prefix invalid-values editing? all-values]}]
@@ -155,11 +155,11 @@
                                                                       :after-delete (:after-delete props)}])}]))

             (when-not editing?
-             [comps/SidebarButton {:style :light :color :button-primary :margin (when can-edit? :top)
-                                   :text "Publish..." :icon :share
-                                   :onClick #(modal/push-modal
-                                              [publish/PublishDialog {:config-id config-id
-                                                                      :workspace-id (:workspace-id props)}])}])
+              [comps/SidebarButton {:style :light :color :button-primary :margin (when can-edit? :top)
+                                    :text "Publish..." :icon :share
+                                    :onClick #(modal/push-modal
+                                               [publish/PublishDialog {:config-id config-id
+                                                                       :workspace-id (:workspace-id props)}])}])

             (when editing?
               (list
@@ -261,7 +261,7 @@
                     :inputs (deref-vals :inputs "in")
                     :outputs (deref-vals :outputs "out")
                     :methodRepoMethod (merge (:methodRepoMethod config)
-                                              ((@refs "methodDetailsViewer") :get-fields))
+                                             ((@refs "methodDetailsViewer") :get-fields))
                     :workspaceName workspace-id)
          :headers utils/content-type=json
          :on-done (fn [{:keys [success? get-parsed-response]}]
@@ -302,30 +302,30 @@
                                                           :name method-name
                                                           :snapshotId new-snapshot-id})
        (endpoints/call-ajax-orch
-         {:endpoint (endpoints/create-template method-ref)
-          :payload method-ref
-          :headers utils/content-type=json
-          :on-done (fn [{:keys [success? get-parsed-response]}]
-                     (let [response (get-parsed-response)]
-                       (if success?
-                         (endpoints/call-ajax-orch
-                           {:endpoint (endpoints/get-validated-workspace-method-config (:workspace-id props) (:config-id props))
-                            :on-done (fn [{:keys [success? get-parsed-response status-text]}]
-                                       (let [valid-response (get-parsed-response)]
-                                         (if success?
-                                           (endpoints/call-ajax-orch
-                                             {:endpoint endpoints/get-inputs-outputs
-                                              :payload (:methodRepoMethod response)
-                                              :headers utils/content-type=json
-                                              :on-done (fn [{:keys [success? get-parsed-response]}]
-                                                         (swap! state dissoc :blocker :wdl-parse-error)
-                                                         (let [template {:methodConfiguration (merge valid-response config-namespace+name)}]
-                                                           (if success?
-                                                               (swap! state assoc
-                                                                      :loaded-config valid-response
-                                                                      :inputs-outputs (get-parsed-response)))
-                                                             (swap! state assoc :error (:message (get-parsed-response)))))})
-                                           (swap! state assoc :error status-text))))})
-                         (do
-                           (swap! state assoc :blocker nil :wdl-parse-error (:message response))
-                           (comps/push-error (style/create-server-error-message (:message response)))))))})))})+        {:endpoint (endpoints/create-template method-ref)
+         :payload method-ref
+         :headers utils/content-type=json
+         :on-done (fn [{:keys [success? get-parsed-response]}]
+                    (let [response (get-parsed-response)]
+                      (if success?
+                        (endpoints/call-ajax-orch
+                         {:endpoint (endpoints/get-validated-workspace-method-config (:workspace-id props) (:config-id props))
+                          :on-done (fn [{:keys [success? get-parsed-response status-text]}]
+                                     (let [valid-response (get-parsed-response)]
+                                       (if success?
+                                         (endpoints/call-ajax-orch
+                                          {:endpoint endpoints/get-inputs-outputs
+                                           :payload (:methodRepoMethod response)
+                                           :headers utils/content-type=json
+                                           :on-done (fn [{:keys [success? get-parsed-response]}]
+                                                      (swap! state dissoc :blocker :wdl-parse-error)
+                                                      (let [template {:methodConfiguration (merge valid-response config-namespace+name)}]
+                                                        (if success?
+                                                          (swap! state assoc
+                                                                 :loaded-config valid-response
+                                                                 :inputs-outputs (get-parsed-response)))
+                                                        (swap! state assoc :error (:message (get-parsed-response)))))})
+                                         (swap! state assoc :error status-text))))})
+                        (do
+                          (swap! state assoc :blocker nil :wdl-parse-error (:message response))
+                          (comps/push-error (style/create-server-error-message (:message response)))))))})))})


[sum-of- multiples] adjust testsuite to match common-testdata

This exercise has got common testdata quite a while ago. This commit
implements that common testdata in the most recent version.

It does not use a generator though.

--- exercises/sum-of-multiples/test/sum_of_multiples_test.clj
+++ exercises/sum-of-multiples/test/sum_of_multiples_test.clj
@@ -3,22 +3,37 @@
             sum-of-multiples))

 (deftest sum-to-1
-  (is (zero? (sum-of-multiples/sum-of-multiples 1))))
+  (is (zero? (sum-of-multiples/sum-of-multiples '(3 5) 1))))

-(deftest sum-to-3
-  (is (= 3 (sum-of-multiples/sum-of-multiples 4))))
+(deftest sum-to-4
+  (is (= 3 (sum-of-multiples/sum-of-multiples '(3 5) 4))))

 (deftest sum-to-10
-  (is (= 23 (sum-of-multiples/sum-of-multiples 10))))
+  (is (= 23 (sum-of-multiples/sum-of-multiples '(3 5) 10))))

 (deftest sum-to-100
-  (is (= 2318 (sum-of-multiples/sum-of-multiples 100))))
+  (is (= 2318 (sum-of-multiples/sum-of-multiples '(3 5) 100))))

 (deftest sum-to-1000
-  (is (= 233168 (sum-of-multiples/sum-of-multiples 1000))))
+  (is (= 233168 (sum-of-multiples/sum-of-multiples '(3 5) 1000))))

-(deftest sum-of-configurable-to-20
-  (is (= 51 (sum-of-multiples/sum-of-multiples [7 13 17] 20))))
+(deftest sum-to-20-using-7-13-17
+  (is (= 51 (sum-of-multiples/sum-of-multiples '(7 13 17) 20))))

-(deftest sum-of-configurable-to-10000
-  (is (= 2203160 (sum-of-multiples/sum-of-multiples [43 47] 10000))))
+(deftest sum-to-15-using-4-6
+  (is (= 30 (sum-of-multiples/sum-of-multiples '(4 6) 15))))
+
+(deftest sum-to-150-using-5-6-8
+  (is (= 4419 (sum-of-multiples/sum-of-multiples '(5 6 8) 150))))
+
+(deftest sum-to-51-using-5-25
+  (is (= 275 (sum-of-multiples/sum-of-multiples '(5 25) 51))))
+
+(deftest sum-to-10_000-using-43-47
+  (is (= 2203160 (sum-of-multiples/sum-of-multiples '(43 47) 10000))))
+
+(deftest sum-to-100-using-1
+  (is (= 4950 (sum-of-multiples/sum-of-multiples '(1) 100))))
+
+(deftest sum-to-10_000-using-empty
+  (is (zero? (sum-of-multiples/sum-of-multiples '() 10000))))


Added function to compute closed sets in parallel

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

--- src/conexp/base.clj
+++ src/conexp/base.clj
@@ -847,6 +847,25 @@
      (all-closed-sets base clop #{}))
   ([base clop initial]
      (all-closed-sets-in-family (constantly true) base clop initial)))
+
+(defn parallel-closures
+  "Returns the set of all closures of the closure operator on the given base set.
+Computes the closures in parallel, to the extent possible."
+  [base clop]
+  (loop [n        0
+         closures #{(clop #{})}
+         current  #{(clop #{})}]
+    (if (< (count base) n)
+      closures
+      (let [next-current (atom current)]
+        (doall (pmap (fn [C]
+                       (when (not= (count C) n)
+                         (swap! next-current #(disj % C))
+                         (doseq [x base :when (not (contains? C x))]
+                           (swap! next-current #(conj % (clop (conj C x)))))))
+                     current))
+        (recur (inc n) (into closures @next-current) @next-current)))))
+

 ;;; Common Math Algorithms


Remove unused lenses related code from utils ns.

--- src/uxbox/util/lens.cljs
+++ src/uxbox/util/lens.cljs
@@ -1,17 +1,6 @@
 (ns uxbox.util.lens
   (:refer-clojure :exclude [derive merge])
   (:require [cats.labs.lens :as l]))
-
-(defn dep-in
-  [where link]
-  {:pre [(vector? where) (vector? link)]}
-  (l/lens
-   (fn [s]
-     (let [value (get-in s link)
-           path (conj where value)]
-       (get-in s path)))
-   (fn [s f]
-     (throw (ex-info "Not implemented" {})))))

 (defn getter
   [f]
@@ -22,13 +11,3 @@
   (l/lens
    (fn [s] (cljs.core/merge s data))
    #(throw (ex-info "Not implemented" {}))))
-
-(defn derive
-  [a path]
-  (l/focus-atom (l/in path) a))
-
-(defn focus
-  ([state]
-   (l/focus-atom l/id state))
-  ([lens state]
-   (l/focus-atom lens state)))


API to retrieve profile info

API to retrieve profile info

--- src/trak/api.cljs
+++ src/trak/api.cljs
@@ -3,7 +3,10 @@
             [cljs-http.client :as http]
             [cljs.core.async :refer [<!]]
             [trak.pubsub :as pubsub])
-  (:require-macros [cljs.core.async.macros :refer [go]]))
+  (:require-macros [cljs.core.async.macros :refer [go]]
+                   [trak.config :refer [cljs-env]]))
+
+

 (defn- api-call
@@ -23,3 +26,12 @@
                                                      :params {:call     :find-albums
                                                               :response response}})))
   )
+
+(defn me [auth]
+  (api-call (partial http/get)
+            "https://api.spotify.com/v1/me"
+            {:with-credentials? false
+             :oauth-token       auth}
+            (fn [response] (pubsub/publish :actions {:action :api-call-result
+                                                     :params {:call     :me
+                                                              :response response}}))))


Import processing with transducers

Import processing with transducers

--- src/app/importer.cljs
+++ src/app/importer.cljs
@@ -6,24 +6,25 @@
             [cljs.core.async :refer [put!]]))

-(defn tokenize-content []
-  (concat (vec (for [page js/content]
+(def tokenize-content (concat (vec (for [page js/content]
                  (.split page ". ")
                  ))))

+(def split-by-line
+  (mapcat #(str/split % #"\n")))

-(defn split-by-line [input]
-  (let [in (if (sequential? input) input [input])]
-    (flatten (map #(str/split  % #"\n") in))))
+(def trim-items
+  (map #(clojure.string/trim %)))

-(defn trim-items [input]
-  (map #(clojure.string/trim %) input))
+(def remove-empty ;; comp throws an error..
+  (filter #(not= "" %)))

-(defn remove-empty [input] ;; comp throws an error..
-  (filter #(not= "" %) input) )
+(def process-pipeline (comp split-by-line trim-items remove-empty))

 (defn process-input [input]
-  (vec (distinct (remove-empty (trim-items (split-by-line input))))))
+  (let [in (if (sequential? input) input [input])]
+    (vec (distinct (sequence process-pipeline in)))))
+

 (defn textarea-import! [words eventbus-in]
   (let [ws (js->clj (.-value (.getElementById js/document "textareaimport")))


Fixes for treeterator

Fixes for treeterator

--- src/aurora/btree.cljs
+++ src/aurora/btree.cljs
@@ -417,6 +417,7 @@
         (aset seek-key moving-key-ix (.key this))
         (.maintain this))
   (up [this]
+      (assert (true? end?)) ;; ?
       (assert (> moving-key-ix 0))
       (aset seek-key moving-key-ix greatest)
       (set! moving-key-ix pinned-key-ix)
@@ -446,19 +447,19 @@
                     min-key (.key (aget iterators current))]
                 (when-not (key= min-key max-key)
                   (.seek (aget iterators current) max-key)
-                  (if (.-end? (aget iterators current))
+                  (if (true? (.-end? (aget iterators current)))
                     (set! end? true)
                     (recur (mod (+ current 1) (alength iterators)))))))))
   (next [this]
         (when (false? end?)
           (.next (aget iterators 0))
-          (if (.-end? (aget iterators 0))
+          (if (true? (.-end? (aget iterators 0)))
             (set! end? true)
             (.search this 1))))
   (seek [this key]
         (when (false? end?)
           (.seek (aget iterators 0) key)
-          (if (.-end? (aget iterators 0))
+          (if (true? (.-end? (aget iterators 0)))
             (set! end? true)
             (.search this 1)))))

@@ -466,7 +467,7 @@
   (assert (> (alength iterators) 0))
   (assert (every? #(= (.-key-len (aget iterators 0)) (.-key-len %)) iterators))
   (if (> (alength iterators) 1)
-    (if (some #(.-end? %) iterators)
+    (if (some #(true? (.-end? %)) iterators)
       (Intersection. iterators true (.-key-len (aget iterators 0)))
       (let [intersection (Intersection. (into-array (sort-by #(.key %) key-compare iterators)) false (.-key-len (aget iterators 0)))]
         (.search intersection 0)
@@ -542,39 +543,40 @@
       join)))

 ;; tree view of a trie
-(deftype Treeterator [iterator key ^:mutable key-ix ^:mutable end? key-len]
+(deftype Treeterator [iterator key-cache ^:mutable key-ix ^:mutable end? key-len]
   Object
   (key [this]
        (when (false? end?)
-         (aclone key)))
+         (aclone key-cache)))
   (val [this]
        (when (false? end?)
          (.val iterator)))
   (walk-up [this]
            (loop []
              (when (false? end?)
-               (if (.-end? iterator)
+               (when (true? (.-end? iterator))
                  (if (<= key-ix 0)
                    (set! end? true)
                    (do
                      (set! key-ix (- key-ix 1))
                      (.up iterator)
+                     (.-end? iterator)
                      (recur)))))))
   (walk-down [this]
              (loop []
-               (when (and (false? end?) (< key-ix (- (alength key) 1)))
+               (if (and (false? end?) (< key-ix (- (alength key-cache) 1)))
                  (do
+                   (aset key-cache key-ix (.key iterator))
                    (set! key-ix (+ key-ix 1))
                    (.down iterator)
-                   (aset key key-ix (.key iterator))))))
+                   (recur))
+                 (aset key-cache key-ix (.key iterator)))))
   (next [this]
-        (.walk-up this)
-        (when (false? end?)
-          (.next iterator)
-          (if (false? (.-end? iterator))
-            (aset key key-ix (.key iterator))
-            (set! end? true)))
-        (.walk-down this))
+        (.next iterator)
+        (aset key-cache key-ix (.key iterator))
+        (when (.-end? iterator)
+            (.walk-up this)
+            (.walk-down this)))
   (seek [this key]
         (assert false "TODO")))

@@ -795,6 +797,19 @@
                  actionss (gen/vector (gen/vector (gen-action key-len)) 1 4)
                  movements (gen/vector (gen-movement key-len))]
                 (run-intersection-prop min-keys key-len actionss movements)))
+
+(defn run-trie-tree-prop [min-keys key-len actions movements]
+  (let [tree (apply-to-tree (tree min-keys key-len) actions)
+        iterator-results (apply-to-iterator (iterator tree) movements)
+        round-trip-results (apply-to-iterator (treeterator (trieterator (iterator tree))) movements)]
+    #_(.pretty-print tree)
+    (= (map vec iterator-results) (map vec round-trip-results))))
+
+(defn trie-tree-prop [key-len]
+  (prop/for-all [min-keys gen/s-pos-int
+                 actions (gen/vector (gen-action key-len))
+                 movements (gen/vector (gen-next key-len))] ;; TODO use gen-movement once Treeterator supports seek
+                (run-trie-tree-prop min-keys key-len actions movements)))

 (comment
   (dc/quick-check 1000 (least-prop 1))
@@ -819,6 +834,8 @@
   ;; cljs.core.pr_str(cemerick.double_check.quick_check(1000, aurora.btree.iterator_prop)
   (dc/quick-check 5000 (intersection-prop 1))
   ;; cljs.core.pr_str(cemerick.double_check.quick_check(1000, aurora.btree.intersection_prop))
+  (dc/quick-check 1000 (trie-tree-prop 1))
+  (dc/quick-check 1000 (trie-tree-prop 2))

   (defn f []


remove comment

remove comment

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -602,9 +602,6 @@
 (defmethod js-source-file JavaScriptFile [_ js]
   (when-let [url (deps/-url js)]
     (js-source-file (javascript-name url) (io/input-stream url))))
-
-;; TODOs
-;; topo sort modules, so we can easily add dependency between modules

 (defn add-cljs-base-module
   ([modules] (add-cljs-base-module modules nil))


layout adjustment.

layout adjustment.

--- src/clj/forma/static.clj
+++ src/clj/forma/static.clj
@@ -17,8 +17,8 @@

 (def chunk-size 24000)

-(def
-  ^{:doc "These are the static datasets, described briefly below. Each dataset must be formatted as:
+(def ^{:doc "These are the static datasets, described briefly
+  below. Each dataset must be formatted as:

     {:corner [lon, lat]
      :travel [lon-dir, lat-dir]


Streamline reports-for-date fn.

Streamline reports-for-date fn.

--- src/clj/hbg_crime/db.clj
+++ src/clj/hbg_crime/db.clj
@@ -54,8 +54,6 @@

 (defn reports-for-date
   [date]
-  (println date)
-  (let [reports (j/query db (s/select * :reports (str "where endtime::date = '"
-                                                      date
-                                                      "'")))]
-    reports))
+  (j/query db (s/select * :reports (str "where endtime::date = '"
+                                        date
+                                        "'"))))