fix the nesting

fix the nesting

--- src/pc/views/blog/diagramming_with_precursor.clj
+++ src/pc/views/blog/diagramming_with_precursor.clj
@@ -10,73 +10,74 @@
    :body
    (list
     [:article
-     [:p "Precursor works great for building flow diagrams. It has the sketching tools you need to clearly express your ideas, but keeps things simple so that you don't get distracted from your goal."]
-
+     [:p "Precursor works great for building flow diagrams. It has the sketching tools you need to clearly express your ideas, but keeps things simple so that you don't get distracted from your goal."]]
+    [:article
      [:h3 "Why flow diagrams?"]
      [:p "Flow diagrams can help you design and understand complex systems. They provide a high-level overview of a system that helps you anchor your thinking and visualize relationships between the system's components."]
-     [:p "A common mistake in sketching flow diagrams is to add too much detail. It may seem important to build a comprehensive diagram, but your audience (which may be you in a couple of months) will get overwhelmed. It's better to err on the side of being too abstract. If you need to, you can always add more detail later. If your diagram starts to get too complex, consider extracting the complex parts into separate diagrams."]
+     [:p "A common mistake in sketching flow diagrams is to add too much detail. It may seem important to build a comprehensive diagram, but your audience (which may be you in a couple of months) will get overwhelmed. It's better to err on the side of being too abstract. If you need to, you can always add more detail later. If your diagram starts to get too complex, consider extracting the complex parts into separate diagrams."]]

+    [:article
      [:h3 "Let's build something"]
      [:p "For a case-study in sketching flow diagrams, we're going to map out Precursor's infrastructure."]
-     [:p "Precursor's infrastructure is made up of 2 main types of components: 1. ones that store data and 2. ones that process data. We'll represent components that store data with the classic spinning disks icon. I'm a pretty poor artist, but I searched Google for \"database icon\" and they're just a stack of circles. We'll spend 30 seconds and illustrate one ourselves. Then when we need it to represent a component, we can just copy/paste it into place."]
+     [:p "Precursor's infrastructure is made up of 2 main types of components: 1. ones that store data and 2. ones that process data. We'll represent components that store data with the classic spinning disks icon. I'm a pretty poor artist, but I searched Google for \"database icon\" and they're just a stack of circles. We'll spend 30 seconds and illustrate one ourselves. Then when we need it to represent a component, we can just copy/paste it into place."]]

-     (common/demo (external-cdn-path "/blog/diagramming-with-precursor/db-placeholder.png")
-                  (external-cdn-path "/blog/diagramming-with-precursor/db.gif"))
+    (common/demo (external-cdn-path "/blog/diagramming-with-precursor/db-placeholder.png")
+                 (external-cdn-path "/blog/diagramming-with-precursor/db.gif"))

-     [:article
-      [:p "For components that process data, we'll illustrate a blade server. Again, I searched Google for server icon and the basic shape is just a rectangle in front and a couple of narrowing lines traveling backwards. I'll take another 30 seconds to illustrate one of these."]]
+    [:article
+     [:p "For components that process data, we'll illustrate a blade server. Again, I searched Google for server icon and the basic shape is just a rectangle in front and a couple of narrowing lines traveling backwards. I'll take another 30 seconds to illustrate one of these."]]

-     (common/demo (external-cdn-path "/blog/diagramming-with-precursor/blade-placeholder.png")
-                  (external-cdn-path "/blog/diagramming-with-precursor/blade.gif"))
+    (common/demo (external-cdn-path "/blog/diagramming-with-precursor/blade-placeholder.png")
+                 (external-cdn-path "/blog/diagramming-with-precursor/blade.gif"))

-     [:article
-      [:p "If you’re thinking you can't sketch, banish that thought. Anyone can sketch well enough to get an idea across. You don't need to waste time searching for and importing the same icon that AWS uses. We're not making marketing materials, we're making diagrams that you use to communicate your ideas to others. Identify the basic shape of the icon, and sketch it as faithfully as you can in 30 seconds. If you're really that bad, you can make a legend to translate your scribbles into English."]
-      [:p "Now that we have our main components, we can start putting them together. I like to start mapping the system from the perspective of a user visiting the site. That means that I'll need to illustrate a couple of laptops to represent the users."]]
+    [:article
+     [:p "If you’re thinking you can't sketch, banish that thought. Anyone can sketch well enough to get an idea across. You don't need to waste time searching for and importing the same icon that AWS uses. We're not making marketing materials, we're making diagrams that you use to communicate your ideas to others. Identify the basic shape of the icon, and sketch it as faithfully as you can in 30 seconds. If you're really that bad, you can make a legend to translate your scribbles into English."]
+     [:p "Now that we have our main components, we can start putting them together. I like to start mapping the system from the perspective of a user visiting the site. That means that I'll need to illustrate a couple of laptops to represent the users."]]

-     (common/demo (external-cdn-path "/blog/diagramming-with-precursor/clients-placeholder.png")
-                  (external-cdn-path "/blog/diagramming-with-precursor/clients.gif"))
+    (common/demo (external-cdn-path "/blog/diagramming-with-precursor/clients-placeholder.png")
+                 (external-cdn-path "/blog/diagramming-with-precursor/clients.gif"))

-     [:article
-      [:p "When the user makes the request, it goes through the load balancer to a web server. The web server delivers a web page with links to javascript and css. Those assets live on our CDN and the client fetches them directly from there. We'll use arrows to indicate the direction of data flow. To create an arrow, hold \"A\" then click on the borders of shapes to connect them."]]
+    [:article
+     [:p "When the user makes the request, it goes through the load balancer to a web server. The web server delivers a web page with links to javascript and css. Those assets live on our CDN and the client fetches them directly from there. We'll use arrows to indicate the direction of data flow. To create an arrow, hold \"A\" then click on the borders of shapes to connect them."]]

-     [:figure
-      [:a.img {:data-caption-black "Hold \"A\" and click the edges of shapes to create arrows."}
-       [:img {:src (external-cdn-path "/blog/diagramming-with-precursor/web-part.png")}]]]
+    [:figure
+     [:a.img {:data-caption-black "Hold \"A\" and click the edges of shapes to create arrows."}
+      [:img {:src (external-cdn-path "/blog/diagramming-with-precursor/web-part.png")}]]]

-     [:article
-      [:p "How did those assets get in the CDN? Somebody pushed some code to GitHub, CircleCI fetched the code, built the assets, ran some tests, then deployed the assets to s3. On the first request, the CDN fetched the assets from s3."]]
+    [:article
+     [:p "How did those assets get in the CDN? Somebody pushed some code to GitHub, CircleCI fetched the code, built the assets, ran some tests, then deployed the assets to s3. On the first request, the CDN fetched the assets from s3."]]

-     [:figure
-      [:a.img {:data-caption-black "Hold \"A\" and click the edges of shapes to create arrows."}
-       [:img {:src (external-cdn-path "/blog/diagramming-with-precursor/web-and-build-server-parts.png")}]]]
+    [:figure
+     [:a.img {:data-caption-black "Hold \"A\" and click the edges of shapes to create arrows."}
+      [:img {:src (external-cdn-path "/blog/diagramming-with-precursor/web-and-build-server-parts.png")}]]]

-     [:article
-      [:p "Now the user sketches some shapes. Those get sent to the web server which forwards them to the Datomic transactor. The transactor stores them in our Postgres database. The next time someone loads the page, the Datomic peer in the web server will fetch the shapes from Postgres."]]
+    [:article
+     [:p "Now the user sketches some shapes. Those get sent to the web server which forwards them to the Datomic transactor. The transactor stores them in our Postgres database. The next time someone loads the page, the Datomic peer in the web server will fetch the shapes from Postgres."]]

-     [:figure
-      [:a.img {:data-caption-black "Hold \"A\" and click the edges of shapes to create arrows."}
-       [:img {:src (external-cdn-path "/blog/diagramming-with-precursor/full-infrastructure.png")}]]]
+    [:figure
+     [:a.img {:data-caption-black "Hold \"A\" and click the edges of shapes to create arrows."}
+      [:img {:src (external-cdn-path "/blog/diagramming-with-precursor/full-infrastructure.png")}]]]

-     [:article
-      [:p "Now we have a good overview of our infrastructure. When a new engineer joins the team, this is one of the first things we'll show them. It's even embedded in our GitHub README. You can see an example of that "
-       [:a {:href "https://github.com/PrecursorApp/image-refresh-demo"}
-        "in our demo repo"]
-       "."]
-      [:p "The final diagram is "
-       [:a {:href "https://precursor.precursorapp.com/document/17592197950857"}
-        "available as a read-only doc"]
-       ". If you want to use it as a starting point, just select the parts you want, hit Cmd+c or Ctrl+c to copy, and Cmd+v or Ctrl+v to paste them into a new document."]]
+    [:article
+     [:p "Now we have a good overview of our infrastructure. When a new engineer joins the team, this is one of the first things we'll show them. It's even embedded in our GitHub README. You can see an example of that "
+      [:a {:href "https://github.com/PrecursorApp/image-refresh-demo"}
+       "in our demo repo"]
+      "."]
+     [:p "The final diagram is "
+      [:a {:href "https://precursor.precursorapp.com/document/17592197950857"}
+       "available as a read-only doc"]
+      ". If you want to use it as a starting point, just select the parts you want, hit Cmd+c or Ctrl+c to copy, and Cmd+v or Ctrl+v to paste them into a new document."]]

-     [:h3 "Tools review"]
+    [:h3 "Tools review"]

-     [:article
-      [:p "Connect shapes with an arrow by holding \"A\" and clicking on the borders of shapes to connect them."]
-      [:p "Copy and paste shapes by selecting them and hitting your system's copy/paste shortcut (Ctrl+c/Ctrl+v on Windows, Cmd+c/Cmd+v on mac)."]
-      [:p "Hold \"Alt\" and scroll to zoom in. You can do more precise placement when zoomed."]
-      [:p "Hit \"+\" or \"-\" to resize selected text."]
-      [:p "Export docs as svg and "
-       [:a {:href "https://github.com/PrecursorApp/image-refresh-demo"}
-        "embed them in a GitHub README"]
-       "."]]
+    [:article
+     [:p "Connect shapes with an arrow by holding \"A\" and clicking on the borders of shapes to connect them."]
+     [:p "Copy and paste shapes by selecting them and hitting your system's copy/paste shortcut (Ctrl+c/Ctrl+v on Windows, Cmd+c/Cmd+v on mac)."]
+     [:p "Hold \"Alt\" and scroll to zoom in. You can do more precise placement when zoomed."]
+     [:p "Hit \"+\" or \"-\" to resize selected text."]
+     [:p "Export docs as svg and "
+      [:a {:href "https://github.com/PrecursorApp/image-refresh-demo"}
+       "embed them in a GitHub README"]
+      "."]]

-     ])})
+    )})


Fixing workflow, resetting the auth-ns atom on stop.

--- src/httpkit/core.clj
+++ src/httpkit/core.clj
@@ -36,7 +36,8 @@
   system)

 (defn stop [system]
-  (server/stop!))
+  (server/stop!)
+  (foe/stop!))

 (defn wrap-outer-logging [handler]
   (fn [req]


Don't include data dumps in the jar

Don't include data dumps in the jar

--- src/kevin/loader.clj
+++ src/kevin/loader.clj
@@ -1,6 +1,6 @@
 (ns kevin.loader
   "To use, download the movies, actors and actresses lists from a mirror on
-  http://www.imdb.com/interfaces, and copy them (still zipped) to the resources
+  http://www.imdb.com/interfaces, and copy them (still zipped) to the data
   folder. You can then run `lein run -m kevin.loader`"
   (:gen-class)
   (:require [clojure.java.io :as io]
@@ -107,9 +107,9 @@
   (let [system (system/start (system/system))]
     (alter-var-root #'conn (constantly (:conn (:db system))))
     (println "Loading movies...")
-    (load-file-with-parser "resources/movies.list.gz" parse-movies :start-at "MOVIES LIST")
+    (load-file-with-parser "data/movies.list.gz" parse-movies :start-at "MOVIES LIST")
     (println "Loading actors...")
-    (load-file-with-parser "resources/actors.list.gz" parse-actors :start-at "THE ACTORS LIST")
+    (load-file-with-parser "data/actors.list.gz" parse-actors :start-at "THE ACTORS LIST")
     (println "Loading actresses...")
-    (load-file-with-parser "resources/actresses.list.gz" parse-actors :start-at "THE ACTRESSES LIST")
+    (load-file-with-parser "data/actresses.list.gz" parse-actors :start-at "THE ACTRESSES LIST")
   ))


PDOK-1599: analyse tests

PDOK-1599: analyse tests

--- src/test/clojure/pdok/featured/extracts_test.clj
+++ src/test/clojure/pdok/featured/extracts_test.clj
@@ -23,8 +23,10 @@
     (is (= 2 )(count features-for-extract))))

 (deftest test-rendered-feature-gml
-  (let [[error features-for-extract] (features-for-extract "test" "dummy" "gml2extract" (one-feature) "src/test/resources/templates")
-        _ (println features-for-extract)
+  (let [_ (println (str "feature one " (one-feature)))
+        [error features-for-extract] (features-for-extract "test" "dummy" "gml2extract" (one-feature) "src/test/resources/templates")
+        _ (println (str "error " error))
+        _ (println (str "feature for extracts" features-for-extract))
         [tiles result-feature] (first features-for-extract)
         _ (println result-feature)]
     (is (boolean (re-find #"<geo><gml:Polygon" result-feature)))


Added width option to custom pretty printer

--- src/polismath/pretty_printers.clj
+++ src/polismath/pretty_printers.clj
@@ -18,9 +18,9 @@
       (prindent indent 2 c))))

-(defn wide-pp [x]
-  (binding [*print-miser-width*  400
-            *print-right-margin* 400]
+(defn wide-pp [x & {:keys [width] :or {width 400}}]
+  (binding [*print-miser-width*  width
+            *print-right-margin* width]
     (pprint x)))


(PDB-2982) Clarify args of embeddable-certname.

Clarify that `puppetdb.queue/embeddable-certname` and the two
functions it calls to determine the certname length all take the
metadata command name, rather than the command name that the rest of
PuppetDB uses.

--- src/puppetlabs/puppetdb/queue.clj
+++ src/puppetlabs/puppetdb/queue.clj
@@ -58,14 +58,14 @@
       "-")))

 (defn max-certname-length
-  "Given the received-at time, command and command version for a metadata
-  string, returns the maximum allowable length (in bytes) of a certname in that
-  string. Note that this length is only achievable if the certname does not
-  need to be sanitized, since sanitized certnames always have a SHA1 hash
-  appended."
-  [received command version]
+  "Given the received-at time, metadata command name and command version for
+  a metadata string, returns the maximum allowable length (in bytes) of
+  a certname in that string. Note that this length is only achievable if the
+  certname does not need to be sanitized, since sanitized certnames always have
+  a SHA1 hash appended."
+  [received metadata-command version]
   (let [time-length (-> received tcoerce/to-long str utf8-length)
-        command-length (utf8-length command)
+        command-length (utf8-length metadata-command)
         version-length (utf8-length (str version))
         field-separators 3]
     (- 255 ; overall filename length limit
@@ -74,13 +74,13 @@
        5))) ; length of '.json' suffix in UTF-8

 (defn truncated-certname-length
-  "Given the received-at time, command, and command version that will be in
-  a metadata string, returns the length (in bytes) to truncate certnames to when
-  they are longer than the `max-certname-length` for the string or they contain
-  characters that must be sanitized. This is less than the string's
-  `max-certname-length` to leave space for the SHA1 hash."
-  [received command version]
-  (- (max-certname-length received command version)
+  "Given the received-at time, metadata command name, and command version that
+  will be in a metadata string, returns the length (in bytes) to truncate
+  certnames to when they are longer than the `max-certname-length` for the
+  string or they contain characters that must be sanitized. This is less than
+  the string's `max-certname-length` to leave space for the SHA1 hash."
+  [received metadata-command version]
+  (- (max-certname-length received metadata-command version)
      1 ; for the additional field separator between certname and hash
      constants/sha1-hex-length))

@@ -90,11 +90,11 @@
   replace any illegal filesystem characters and underscores with dashes, and
   will be truncated if the original version will cause the metadata string to
   exceed 255 characters."
-  [received command version certname]
+  [received metadata-command version certname]
   (let [cn-length (utf8-length certname)
-        trunc-length (truncated-certname-length received command version)
+        trunc-length (truncated-certname-length received metadata-command version)
         sanitized-certname (sanitize-certname certname)]
-    (if (or (> cn-length (max-certname-length received command version))
+    (if (or (> cn-length (max-certname-length received metadata-command version))
             (and (not= certname sanitized-certname)
                  (> cn-length trunc-length)))
       (utf8-truncate sanitized-certname trunc-length)


get-content now looking at the collection rather than the tag when destructuring...

--- scraper/src/scraper/core.clj
+++ scraper/src/scraper/core.clj
@@ -34,7 +34,7 @@
       (by-fn html-tree #(= (tag %) x)))

 (defn get-content [html-tree x]
-      (let [[tag-element attributes-element content-element] x]
+      (let [[tag-element attributes-element content-element] html-tree]
            content-element))

 (defn get-attribute [html-tree x]
@@ -62,6 +62,8 @@
 (defn build-zone-modifiers [url]
   (by-tag (second (by-tag (first (by-attribute (parse url) {:class "factionTable"})) :tr)) :ul))

+(def test-map {})
+
 (defn -main
   "Entry point to scraper methods. Pulls in data from project1999's wiki to insert into an SQLite DB."
   [& args]
@@ -79,7 +81,10 @@
         urls (map #(:href (first (vals %))) the-factions)
         urls (build-all-faction-urls urls)]

-    (build-zone-modifiers (first urls))
+    (by-tag (first (build-zone-modifiers (first urls))) :li)
+    ;(assoc test-map :zones-raise (get-content (by-tag (first (build-zone-modifiers (first urls))) :li) nil)
+    ;                :zones-lower (get-content (by-tag (second (build-zone-modifiers (first urls))) :li) nil))
+
     ;(by-tag (second (by-tag (first (by-attribute (parse (first urls)) {:class "factionTable"})) :tr)) :ul)
     ;(doall (map #(into {} {:zones-raise get-faction-info urls))
       ;(doall (map get-faction-info url)))


Applies UMM sanitization to umm-c-generator

--- umm-spec-lib/src/cmr/umm_spec/test/umm_generators.clj
+++ umm-spec-lib/src/cmr/umm_spec/test/umm_generators.clj
@@ -5,6 +5,7 @@
             [com.gfredericks.test.chuck.generators :as chgen]
             [cmr.umm-spec.json-schema :as js]
             [cmr.umm-spec.record-generator :as record-gen]
+            [cmr.umm-spec.test.umm-record-sanitizer :as san]
             [clojure.set :as set]))

 ;; We could move this to common lib if desired at some point. There's not much here that is UMM specific.
@@ -211,19 +212,11 @@
     (schema-type->generator schema (:root schema) root-type-def)))

 (def umm-c-generator
-  (schema->generator js/umm-c-schema))
+  (gen/fmap san/sanitized-umm-record
+            (schema->generator js/umm-c-schema)))

 (comment

-  (last (gen/sample (schema->generator js/umm-c-schema) 10))
+  (last (gen/sample umm-c-generator 10))

   )
-
-
-
-
-
-
-
-
-


reorganize a bit

reorganize a bit

--- src/mantra/core.cljs
+++ src/mantra/core.cljs
@@ -83,29 +83,6 @@

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(declare start-osc stop-osc)
-
-(defn play-note
-  "Uses a one-off oscillator to play a note.
-
-   If duration is present, the oscillator is stopped after `duration` ms.
-
-   Otherwise, the note rings out indefinitely, until the oscillator is stopped."
-  [osc-model {:keys [pitch duration volume] :as note-model}]
-
-  ; stop any currently playing oscillators for this osc-model
-  (stop-osc osc-model)
-
-  (let [{:keys [osc-node gain-node] :as osc-impl} (osc* osc-model)]
-    (start-osc osc-impl)
-
-    (freq osc-node (or pitch (:freq osc-model)))
-
-    (gain-ramp gain-node (or volume (:gain osc-model) 1))
-
-    (when duration
-      (c/set-timeout! clock #(stop-osc osc-impl) duration))))
-
 (defn start-osc
   "Start an oscillator and add it to *oscillators*."
   [{:keys [osc-node] :as osc-impl}]
@@ -137,6 +114,34 @@
   (doseq [osc @*oscillators*]
     (stop-osc osc)))

+(defn play-note
+  "Uses a one-off oscillator to play a note.
+
+   If duration is present, the oscillator is stopped after `duration` ms.
+
+   Otherwise, the note rings out indefinitely, until the oscillator is stopped."
+  [osc-model {:keys [pitch duration volume] :as note-model}]
+
+  ; stop any currently playing oscillators for this osc-model
+  (stop-osc osc-model)
+
+  (let [{:keys [osc-node gain-node] :as osc-impl} (osc* osc-model)]
+    (freq osc-node (or pitch (:freq osc-model)))
+    (gain-ramp gain-node (or volume (:gain osc-model) 1))
+
+    (start-osc osc-impl)
+
+    (when duration
+      (c/set-timeout! clock #(stop-osc osc-impl) duration))))
+
+(defn play-notes
+  "Plays a sequence of notes, one after the other.
+
+   If pitch is omitted (or nil), the note is treated as a rest (a pause in the
+   sequence, the length of `duration`."
+  [osc-model notes]
+  "TODO")
+
 (comment "
   TODO:
     - play-notes and play-chord will also stop all notes
@@ -144,5 +149,7 @@
     - ditto for also-play-chord, also-play-notes
     - 'mute' functionality, stops oscs but also keeps track of their state so
       they can be restarted when 'unmuted'
+    - a generic `play` function that will do the right thing, depending on the types of the arguments
+        e.g. multiple arguments are treated as a sequence of notes, a collection of notes is treated as a chord
 ")


Added get-enum interface to handle weird enums that are not referenced directly. For example ACCELCAL_VEHICLE_POS.

--- src/mavlink/core.clj
+++ src/mavlink/core.clj
@@ -1125,3 +1125,9 @@
     ; Return a map holding the statistics atom and the close-channel function
     {:statistics statistics
      :close-channel-fn #(shutdown-fn nil)}))
+
+(defn get-enum
+  "Look up value in an enum group and return the enum-key for that value.
+   nil in case of error."
+  [mavlink group-id v]
+  (get-in mavlink [:enums-by-group group-id v]))


publish advert

publish advert

--- src/clj/salava/extra/application/db.clj
+++ src/clj/salava/extra/application/db.clj
@@ -193,11 +193,11 @@
 (defn insert-advert-event! [ctx data]
   (insert-badge-advert-event<! data (u/get-db ctx)))

-(defn advert [ctx subject verb object type country]
-  (u/publish ctx :advert {:subject subject :verb verb :object object :type type :country country}))
+(defn advert [ctx subject verb object type country ctime]
+  (u/publish ctx :advert {:subject subject :verb verb :object object :type type :country country :ctime}))

 (defn publish-advert [ctx id data]
-  (advert ctx id "advertise" (:remote_id data) "advert" (:country data)))
+  (advert ctx id "advertise" (:remote_id data) "advert" (:country data) (if (= 0 (:not_before data)) (t/unix-time) (:not_before data))))

 (def do-publish (memoize publish-advert))


Refactor draw card handler

Refactor draw card handler

--- src/cljs/love_letter_cljs/handlers.cljs
+++ src/cljs/love_letter_cljs/handlers.cljs
@@ -124,24 +124,26 @@

 (defn play-card [db face player-id]
   (let [path [:players player-id :hand]
-        discarded-card (retrieve-card db face player-id)
-        discard-pile (:discard-pile db)]
+        discarded-card (retrieve-card db face player-id)]
+    (when (nil? discarded-card) (throw (js/Error. "Tried to discard a nil card")))
     (-> db
         (assoc-in path (u/remove-first face (get-in db path)))
         (update-in [:discard-pile] conj discarded-card))))

+(defn handle-draw-card [db player-id]
+  (let [with-card-drawn (g/move-card db [:deck] [:players player-id :hand])]
+    #_(if (g/countess-check with-card-drawn player-id)
+      (-> with-card-drawn
+          (play-card :countess player-id)
+          (start-next-turn)))
+      (set-phase with-card-drawn :play)))
+
 (register-handler
  :draw-card
  [(undoable)
  standard-middlewares]
  (fn [db [_ player-id]]
-   (as-> db d
-     (merge d (g/draw-card db player-id))
-     (if (g/countess-check d player-id)
-       (-> d
-           (play-card :countess player-id)
-           (start-next-turn))
-       d))))
+   (handle-draw-card db player-id)))

 (defn resolve-effect [db]
   (let [{:keys [card-target active-card guard-guess]} db


support profiles and args

support profiles and args

--- src/org/spootnik/fleet/http.clj
+++ src/org/spootnik/fleet/http.clj
@@ -1,17 +1,18 @@
 (ns org.spootnik.fleet.http
-  (:require [compojure.core            :refer [routes GET POST PUT DELETE]]
-            [clojure.tools.logging     :refer [error]]
-            [clojure.pprint            :refer [pprint]]
-            [ring.util.response        :refer [response redirect]]
-            [cheshire.core             :refer [generate-string]]
-            [ring.middleware.json      :as json]
-            [compojure.route           :as route]
-            [clojure.core.async        :as async]
-            [clojure.stacktrace]
-            [org.spootnik.fleet.api    :as api]
-            [org.spootnik.fleet.engine :as engine]
-            [org.spootnik.fleet.history :as history]
-            [org.httpkit.server        :as http]))
+  (:require [compojure.core                 :refer [routes GET POST PUT DELETE]]
+            [clojure.tools.logging          :refer [error]]
+            [clojure.pprint                 :refer [pprint]]
+            [ring.util.response             :refer [response redirect]]
+            [cheshire.core                  :refer [generate-string]]
+            [ring.middleware.keyword-params :refer [wrap-keyword-params]]
+            [ring.middleware.params         :refer [wrap-params]]
+            [ring.middleware.json           :as json]
+            [compojure.route                :as route]
+            [clojure.core.async             :as async]
+            [org.spootnik.fleet.api         :as api]
+            [org.spootnik.fleet.engine      :as engine]
+            [org.spootnik.fleet.history     :as history]
+            [org.httpkit.server             :as http]))

 (defn json-response
   [body]
@@ -43,8 +44,12 @@

    (GET "/scenarios/:script_name/executions" request
         (let [script_name (-> request :params :script_name)
-              scenario (api/get! scenarios script_name)
-              ch       (async/chan 10)]
+              args        (if-let [args (-> request :params :args)]
+                            (if (sequential? args) args [args])
+                            [])
+              scenario    (api/get! scenarios script_name)
+              profile     (-> request :params :profile keyword)
+              ch          (async/chan 10)]
           (http/with-channel request hchan
             (future
               (try
@@ -62,7 +67,9 @@
                 (http/close hchan)
                 (catch Exception e
                   (error e "cannot handle incoming message"))))
-            (engine/request engine scenario ch))))
+            (engine/request engine
+                            (api/prepare scenario profile args)
+                            ch))))

    ;; defaults
    (GET "/" []      (redirect "/index.html"))
@@ -85,5 +92,7 @@
   (api/load! scenarios)
   (http/run-server (-> (api-routes scenarios engine)
                        (wrap-error)
+                       (wrap-keyword-params)
+                       (wrap-params)
                        (json/wrap-json-body {:keywords? true}))
                    opts))


Fix of status-im.models.network/action-handler to make tests pass again

Signed-off-by: Aleksandr Pantiukhov <33cce7019c5ec80a74fe74102c4c2175a8341f94@gmail.com>

--- src/status_im/models/network.cljs
+++ src/status_im/models/network.cljs
@@ -59,7 +59,7 @@

 (defn- action-handler
   ([handler]
-   (handler nil nil))
+   (action-handler handler nil nil))
   ([handler data cofx]
    (when handler
      (handler data cofx))))


♻ Reduce the scope of the command variable

--- src/territory_bro/projections.clj
+++ src/territory_bro/projections.clj
@@ -129,8 +129,7 @@
     (when change
       (let [new-id (when (= :INSERT (:op change))
                      (when (nil? (:replacement_id change)) ; the replacement ID should already be unused, and replacing it a second time would bring chaos (e.g. infinite loop)
-                       (:id (:new change))))
-            command (gis-sync/change->command change state)]
+                       (:id (:new change))))]
         (if (and new-id (event-store/stream-exists? conn new-id))
           (let [replacement-id (UUID/randomUUID)
                 {:keys [schema table]} change]
@@ -139,7 +138,8 @@
                     {:replacement-id replacement-id})
             (gis-db/replace-id! conn schema table new-id replacement-id)
             (recur conn state))
-          (let [events (dispatcher/command! conn state command)
+          (let [command (gis-sync/change->command change state)
+                events (dispatcher/command! conn state command)
                 ;; the state needs to be updated for e.g. command validation's foreign key checks
                 state (reduce update-projections state events)]
             (gis-db/mark-changes-processed! conn [(:id change)])


Handle any number of fqs; more accurate check for completion restart

--- services/sfj-breseq-runs.clj
+++ services/sfj-breseq-runs.clj
@@ -11,9 +11,10 @@
                        (infof "Fut (%s) starting ..." i)
                        (loop [q1 (<!! quads)]
                          (when q1
-                           (if (fs/exists? (last q1))
+                           (if (fs/exists?
+                                (fs/join (last q1) "output/index.html"))
                              (recur (<!! quads)) ; restart check
-                             (let [[[q1r1 q1r2] q1-refgbk q1-outdir] q1
+                             (let [[fqs q1-refgbk q1-outdir] q1
                                    _ (infof "Fut (%s),  %s start..."
                                             i q1-outdir)
                                    poly (if (re-find #"[Cc]lone" q1-outdir)
@@ -21,16 +22,17 @@
                                           ["-p"])
                                    ret (apply
                                         pg/breseq
-                                        (concat poly ["-j" "4"
-                                                      "-o" q1-outdir
-                                                      "-r" q1-refgbk
-                                                      q1r1 q1r2]
+                                        (concat poly
+                                                ["-j" "4"
+                                                 "-o" q1-outdir
+                                                 "-r" q1-refgbk]
+                                                fqs
                                                 [{:verbose true :throw false}]))
                                    exit-code @(ret :exit-code)
                                    exit (if (= 0 exit-code) :success exit-code)
                                    err (-> (ret :stderr) (str/split #"\n") last)
                                    retmap {:name "breseq-runs"
-                                           :value [[q1r1 q1r2] q1-outdir]
+                                           :value [fqs q1-outdir]
                                            :exit exit
                                            :err err}]
                                (swap! results (fn[a] (conj a retmap)))


add more explanatory text about differences between error fns

--- src/vip/data_processor/errors.clj
+++ src/vip/data_processor/errors.clj
@@ -27,7 +27,11 @@
 (defn add-v5-errors
   "Same error options as add-errors, also with a parent-element-id which
    is often used to associate some child error on, say, Id, to the element it
-   is in, ie Precinct."
+   is in, ie Precinct. This is important since we drop the table that was
+   previously used to look this up. So if there is a parent element associated
+   to the particular error type, it's important to use this instead of
+   `add-errors` to preserve that information. If your error is of a more
+   global type of nature, you can just use `add-errors`."
   [{:keys [errors-chan] :as ctx}
    severity scope identifier error-type parent-element-id
    & error-data]


calc mandelbrot set

calc mandelbrot set

--- src/mandel/core.clj
+++ src/mandel/core.clj
@@ -4,7 +4,19 @@
            (javax.swing JFrame))
   (:gen-class))

-(set! *warn-on-reflection* true)
+;(set! *warn-on-reflection* true)
+
+(defn mandelbrot
+  [^double cx ^double cy ^long max-iterations]
+  (loop [x 0
+         y 0
+         iter 0]
+    (let [abs-squared (+ (* x x) (* y y))]
+      (if (or (> abs-squared 8) (= iter max-iterations))
+        (- iter (/ (Math/log (/ (Math/log abs-squared) (Math/log 4))) (Math/log 2)))
+        (recur (+ (- (* x x) (* y y)) cx)
+               (+ (* 2 x y) cy)
+               (unchecked-inc iter))))))

 (defn hue-to-rgb ^long
   [^long hue]
@@ -19,22 +31,28 @@
       (< hue 360) (unchecked-add-int 0xff0000 x))))

 (defn get-color ^long
-  [^long x ^long y ^long width]
-  (hue-to-rgb (unchecked-divide-int (unchecked-multiply-int 360 x) width)))
+  [^long x ^long y ^long width ^long height]
+  (let [cx (* 4 (/ (- x (/ width 1.5)) width))
+        cy (* 4 (/ (- y (/ height 2)) height))
+        max-iterations 100
+        iter (mandelbrot cx cy max-iterations)]
+    (if (>= iter max-iterations)
+      0x000000
+      (hue-to-rgb (unchecked-add-int 240 (unchecked-divide-int (unchecked-multiply-int iter 360) max-iterations))))))

 (defn set-pixel
   [image-data width x y color]
   (aset-int image-data (unchecked-add-int (unchecked-multiply-int y width) x) color))

 (defn draw-line
-  [image-data width y]
+  [image-data width height y]
   (doseq [x (range width)]
-    (set-pixel image-data width x y (get-color x y width))))
+    (set-pixel image-data width x y (get-color x y width height))))

 (defn draw
   [frame buffered-image width height]
   (let [image-data (-> buffered-image (.getRaster) (.getDataBuffer) (.getData))]
-    (dorun (pmap #(draw-line image-data width %) (shuffle (range height)))))
+    (dorun (pmap #(draw-line image-data width height %) (shuffle (range height)))))
   (.repaint frame))

 (defn create-frame


yet another try

yet another try

--- src/ontrail/core.clj
+++ src/ontrail/core.clj
@@ -214,4 +214,4 @@
   (nc/newcomment-cache-restore-all)
   (schedule-work nc/newcomment-cache-store-all 2400)
   (aleph/start-http-server ring-handler
-                     {:port 8080 :websocket true}))
+                     {:host "localhost" :port 8080 :websocket true}))


Extract gravatar calculations and return users in same form as everywhere else.

--- src/ontrail/user.clj
+++ src/ontrail/user.clj
@@ -5,15 +5,18 @@

 (def #^{:private true} logger (org.slf4j.LoggerFactory/getLogger (str *ns*)))

+(defn as-gravatar [user]
+  (let [gravatar? (get user :gravatar)
+        email (get user :email)
+        gravatar-md5-hash (md5 email)]
+    (if gravatar?
+      (str "http://www.gravatar.com/avatar/" gravatar-md5-hash)
+      "/img/default-avatar.png")))
+
 (defn get-avatar-url [user]
   (let [onuser (mc/find-one-as-map ONUSER {:username user})]
     (if (not-nil? onuser)
-      (let [gravatar? (get onuser :gravatar)
-            email (get onuser :email)
-            gravatar-md5-hash (md5 email)]
-        (if gravatar?
-          (str "http://www.gravatar.com/avatar/" gravatar-md5-hash)
-          "/img/default-avatar.png"))
+      (as-gravatar onuser)
       "/img/drno.png")))

 (defn create-user [username password email gravatar]
@@ -24,7 +27,8 @@
 (defn get-user [username]
   (mc/find-one-as-map ONUSER {:username username}))

-(defn as-user [user] (dissoc user :_id :passwordHash :email))
+(defn as-user [user]
+  {:user (:username user) :profile (:profile user) :avatar (as-gravatar user)})
 (defn as-user-list [results] (map as-user results))

 (defn get-user-list [rule page]


Cleanup and formatting

Cleanup and formatting

--- Clojure/src/ambly/repl/jsc.clj
+++ Clojure/src/ambly/repl/jsc.clj
@@ -18,22 +18,26 @@

 (def ambly-bonjour-name-prefix "Ambly ")

-(defn service-name->display-name [service-name]
-  (subs service-name (count ambly-bonjour-name-prefix)))
-
-(defn service-map->choice-list [service-map]
-  (map vector (iterate inc 1) service-map))
-
-(defn print-services [service-map]
-  (doseq [[choice-number [service-name _]] (service-map->choice-list service-map)]
-    (println (str "[" choice-number "] " (service-name->display-name service-name)))))
-
-(defn discover-and-pick-ambly-instance
-  "Looks for Ambly WebDAV services advertised via Bonjour and presents
-  a simple command-line UI letting user pick one."
+(defn bonjour-name->display-name
+  [bonjour-name]
+  (subs bonjour-name (count ambly-bonjour-name-prefix)))
+
+(defn name-endpoint-map->choice-list [name-endpoint-map]
+  (map vector (iterate inc 1) name-endpoint-map))
+
+(defn print-discovered-devices [name-endpoint-map]
+  (if (empty? name-endpoint-map)
+    (println "(No devices)")
+    (doseq [[choice-number [bonjour-name _]] (name-endpoint-map->choice-list name-endpoint-map)]
+      (println (str "[" choice-number "] " (bonjour-name->display-name bonjour-name))))))
+
+(defn discover-and-choose-device
+  "Looks for Ambly WebDAV devices advertised via Bonjour and presents
+  a simple command-line UI letting user pick one, unless
+  choose-first-discovered? is set to true in which case the UI is bypassed"
   [choose-first-discovered?]
   (let [reg-type "_http._tcp.local."
-        discovered-services (atom (sorted-map))
+        name-endpoint-map (atom (sorted-map))
         mdns-service (JmDNS/create)
         service-listener
         (reify ServiceListener
@@ -42,37 +46,37 @@
               (when (.startsWith name ambly-bonjour-name-prefix)
                 (.requestServiceInfo mdns-service (.getType service-event) (.getName service-event) 1))))
           (serviceRemoved [_ service-event]
-            (swap! discovered-services dissoc (.getName service-event)))
+            (swap! name-endpoint-map dissoc (.getName service-event)))
           (serviceResolved [_ service-event]
             (let [entry {(.getName service-event)
                          (let [info (.getInfo service-event)]
                            {:address (.getAddress info)
                             :port    (.getPort info)})}]
-              (swap! discovered-services merge entry))))]
+              (swap! name-endpoint-map merge entry))))]
     (try
       (.addServiceListener mdns-service reg-type service-listener)
       (loop [count 0]
-        (when (empty? @discovered-services)
+        (when (empty? @name-endpoint-map)
           (Thread/sleep 100)
-          (when (= 1000 count)
-            (println "\nSearching ..."))
+          (when (= 20 count)
+            (println "\nSearching for devices ..."))
           (recur (inc count))))
       (Thread/sleep 500)                                    ;; Sleep a little more to catch stragglers
-      (loop [current-discovered-services @discovered-services]
+      (loop [current-name-endpoint-map @name-endpoint-map]
         (println)
-        (print-services current-discovered-services)
+        (print-discovered-devices current-name-endpoint-map)
         (when-not choose-first-discovered?
-          (println "\n[r] Refresh\n")
+          (println "\n[R] Refresh\n")
           (print "Choice: ")
           (flush))
         (let [choice (if choose-first-discovered? "1" (read-line))]
-          (if (= "r" choice)
-            (recur @discovered-services)
-            (let [choices (service-map->choice-list current-discovered-services)
-                  choice-ndx (try (dec (Long/parseLong choice)) (catch NumberFormatException _ nil))]
+          (if (= "r" (.toLowerCase choice))
+            (recur @name-endpoint-map)
+            (let [choices (name-endpoint-map->choice-list current-name-endpoint-map)
+                  choice-ndx (try (dec (Long/parseLong choice)) (catch NumberFormatException _ -1))]
               (if (< -1 choice-ndx (count choices))
                 (second (nth choices choice-ndx))
-                (recur current-discovered-services))))))
+                (recur current-name-endpoint-map))))))
       (finally
         (future
           (.removeServiceListener mdns-service reg-type service-listener)
@@ -187,16 +191,15 @@
 (defn setup
   [repl-env opts]
   (let [_ (set-logging-level "javax.jmdns" java.util.logging.Level/SEVERE)
-        [webdav-endpoint-name webdav-endpoint] (discover-and-pick-ambly-instance (:choose-first-discovered repl-env))
-        _ (println "\nConnecting to" (service-name->display-name webdav-endpoint-name) "...\n")
-        ; Assuming IPv4 for now
-        endpoint-address (.getHostAddress (:address webdav-endpoint))
-        endpoint-port (:port webdav-endpoint)
+        [bonjour-name endpoint] (discover-and-choose-device (:choose-first-discovered repl-env))
+        endpoint-address (.getHostAddress (:address endpoint))
+        endpoint-port (:port endpoint)
         webdav-mount-point (str "/Volumes/Ambly-" endpoint-address)
         output-dir (io/file webdav-mount-point)
         _ (.mkdirs output-dir)
         env (ana/empty-env)
         core (io/resource "cljs/core.cljs")]
+    (println "\nConnecting to" (bonjour-name->display-name bonjour-name) "...\n")
     (reset! (:webdav-mount-point repl-env) webdav-mount-point)
     (shell/sh "mount_webdav" (str "http://" endpoint-address ":" endpoint-port) webdav-mount-point)
     (reset! (:socket repl-env)


标记新的版本号

标记新的版本号

--- advance/project.clj
+++ advance/project.clj
@@ -1,4 +1,4 @@
-(defproject org.clojars.marsliu/jparsec-adv "0.5.0"
+(defproject org.clojars.marsliu/jparsec-adv "0.5.1"
   :description "Haskell Parsec Library's Java 1.8+ Editon"
   :url "https://github.com/Dwarfartisan/jparsec"
   :license {:name "THE MIT LICENSE"


Fix IOpacity protocol implementation for Element. Fixes #56.

Checks both getOpacity and get getComputedStyle.

--- src/lib/cljs/one/browser/animation.cljs
+++ src/lib/cljs/one/browser/animation.cljs
@@ -96,7 +96,10 @@

   js/Element
   (opacity [this]
-    (opacity (style/getOpacity this))))
+    (let [op (style/getComputedStyle this "opacity")]
+      (if (= op "")
+        (opacity (style/getOpacity this))
+        op))))

 (extend-type goog.fx.AnimationQueue


Simplify the code

Simplify the code

--- src/mdr2/dtbook.clj
+++ src/mdr2/dtbook.clj
@@ -110,44 +110,41 @@
        [:p]]]]))

 (defn- dtbook-sexp
-  [{:keys [title creator subject description publisher date type format identifier
-           source language rights
-           source_date source_edition source_publisher source_rights source_title
-           multimedia_type multimedia_content narrator produced_date
-           revision revision_date revision_description
-           total_time audio_format production_type
-           library_number]}] ; only books imported from the libray have this
+  [{:keys [title creator language production_type library_number] :as production}]
   [:dtbook {:xmlns "http://www.daisy.org/z3986/2005/dtbook/"
             :version "2005-3" :xml:lang language}
    [:head
-    [:meta {:name "dc:Title" :content title}]
-    [:meta {:name "dc:Creator" :content creator}]
-    [:meta {:name "dc:Subject" :content subject}]
-    [:meta {:name "dc:Description" :content description}]
-    [:meta {:name "dc:Publisher" :content publisher}]
-    [:meta {:name "dc:Date" :content date}]
-    [:meta {:name "dc:Type" :content type}]
-    [:meta {:name "dc:Format" :content format}]
-    [:meta {:name "dc:Identifier" :content identifier}]
-    [:meta {:name "dc:Source" :content source}]
-    [:meta {:name "dc:Language" :content language}]
-    [:meta {:name "dc:Rights" :content rights}]
-    [:meta {:name "dtb:uid" :content identifier}]
-    [:meta {:name "dtb:sourceDate" :content source_date}]
-    [:meta {:name "dtb:sourceEdition" :content source_edition}]
-    [:meta {:name "dtb:sourcePublisher" :content source_publisher}]
-    [:meta {:name "dtb:sourceRights" :content source_rights}]
-    [:meta {:name "dtb:sourceTitle" :content source_title}]
-    [:meta {:name "dtb:multimediaType" :content multimedia_type}]
-    [:meta {:name "dtb:multimediaContent" :content multimedia_content}]
-    [:meta {:name "dtb:narrator" :content narrator}]
-    [:meta {:name "dtb:producer" :content publisher}]
-    [:meta {:name "dtb:producedDate" :content produced_date}]
-    [:meta {:name "dtb:revision" :content revision}]
-    [:meta {:name "dtb:revisionDate" :content revision_date}]
-    [:meta {:name "dtb:revisionDescription" :content revision_description}]
-    [:meta {:name "dtb:totalTime" :content total_time}]
-    [:meta {:name "dtb:audioFormat" :content audio_format}]]
+    (for [[meta-name meta-key]
+          (->> [:dc:Title :title
+                :dc:Creator :creator
+                :dc:Subject :subject
+                :dc:Description :description
+                :dc:Publisher :publisher
+                :dc:Date :date
+                :dc:Type :type
+                :dc:Format :format
+                :dc:Identifier :identifier
+                :dc:Source :source
+                :dc:Language :language
+                :dc:Rights :rights
+                :dtb:uid :identifier
+                :dtb:sourceDate :source_date
+                :dtb:sourceEdition :source_edition
+                :dtb:sourcePublisher :source_publisher
+                :dtb:sourceRights :source_rights
+                :dtb:sourceTitle :source_title
+                :dtb:multimediaType :multimedia_type
+                :dtb:multimediaContent :multimedia_content
+                :dtb:narrator :narrator
+                :dtb:producer :publisher
+                :dtb:producedDate :produced_date
+                :dtb:revision :revision
+                :dtb:revisionDate :revision_date
+                :dtb:revisionDescription :revision_description
+                :dtb:totalTime :total_time
+                :dtb:audioFormat :audio_format]
+               (partition 2))]
+      [:meta {:name (name meta-name) :content (meta-key production)}])]
    (cond
      library_number (commercial-audiobook title creator language)
      (= production_type "periodical") (periodical title creator)


mount-state marker vs. session-id ts

mount-state marker vs. session-id ts

--- src/mount/mount.clj
+++ src/mount/mount.clj
@@ -5,7 +5,8 @@

 (disable-reload!)

-(defonce ^:private session-id (System/currentTimeMillis))
+;; (defonce ^:private session-id (System/currentTimeMillis))
+(defonce ^:private mount-state 42)
 (defonce ^:private state-seq (atom 0))
 (defonce ^:private state-order (atom {}))

@@ -29,7 +30,7 @@
 (defmacro defstate [state & body]
   (let [[state [c cf d df]] (macro/name-with-attributes state body)
         {:keys [start stop]} (validate {c cf d df})]
-    (let [s-meta (-> {:session-id session-id
+    (let [s-meta (-> {:mount-state mount-state
                       :order (make-state-seq state)
                       :start `(fn [] (~@start))
                       :started? false}
@@ -56,11 +57,15 @@
           (throw (RuntimeException. (str "could not stop [" name "] due to") t)))))
     (alter-meta! var assoc :started? false)))

+(defn mount-state? [var]
+  (= (-> var meta :mount-state)
+     mount-state))
+
 (defn find-all-states []
   (->> (all-ns)
        (mapcat ns-interns)
        (map second)
-       (filter #(= (:session-id (meta %)) session-id))))
+       (filter mount-state?)))

 ;; TODO: narrow down by {:mount {:include-ns
 ;;                                {:starts-with ["app.foo" "bar.baz"]


basic functions in acq eng

basic functions in acq eng

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

--- clojure/acq_engine.clj
+++ clojure/acq_engine.clj
@@ -1,10 +1,65 @@
 (ns acq-engine
-  (:import MMStudioPlugin))
+  (:import MMStudioPlugin
+           [org.micromanager.navigation MultiStagePosition]))

 (def gui (MMStudioPlugin/getMMStudioMainFrameInstance))
 (def mmc (.getMMCore gui))
 (def acq (.getAcquisitionEngine gui))

-(defn snap-image []
-  (. (doto mmc .snapImage) getImage))
+(defn snap-image [event auto-shutter]
+  (if (and auto-shutter (. mmc getShutterOpen))
+    (. mmc setShutterOpen true))
+  (. mmc snapImage)
+  (if (and auto-shutter (event :close-shutter))
+     (. mmc setShutterOpen false))
+  (. mmc getImage))

+(defn collect-burst-image []
+  (while (zero? (. mmc remainingImageCount))
+    (Thread/sleep 5))
+  (. mmc popNextImage))
+
+(defn update-channel [event]
+  (when-let [channel (event :channel)]
+    (let [channel-group (. mmc getChannelGroup)
+          config (.config channel)]
+      (. mmc setConfig channel-group config))))
+
+(defn update-slice [event]
+  (when-let [slice (event :slice)]
+    (when-let [focusDevice (. mmc getFocusDevice)]
+      (. mmc setPosition focusDevice slice))))
+
+(defn get-stage-positions [^MultiStagePosition msp]
+  (map #(.get msp %) (range (.size msp))))
+
+(defn update-position [event]
+  (when-let [position (event :position)]
+    (for [sp (get-stage-positions position)]
+      (let [stage (.stageName sp)]
+        (condp = (.numAxes sp)
+          1 (. mmc setPosition stage (.x sp))
+          2 (. mmc setXYPosition stage (.x sp) (.y sp)))))))
+
+(defn clock-ms []
+  (quot (System/nanoTime) 1000000))
+
+(defn acq-sleep [event last-wake-time]
+  (let [sleep-time (-
+                     (+ last-wake-time (event :interval-ms))
+                     (clock-ms))]
+    (when (pos? sleep-time)
+      (Thread/sleep sleep-time)))
+  (clock-ms))
+
+(defn run-task [event]
+  (let [last-wake-time (atom 0)]
+    (update-channel event)
+    (update-position event)
+    (reset! last-wake-time
+      (acq-sleep event @last-wake-time))
+    (run-autofocus event)
+    (update-slice event)
+    (snap-image event)))
+
+


Clear search results when starting a new search.

--- src-cljs/pepa/search.cljs
+++ src-cljs/pepa/search.cljs
@@ -66,14 +66,13 @@
                   (catch js/Error e nil))]
       (when (not= query (:search/query state))
         (println "got new query")
-        ;; Cancel old search by closing the result channel
-        (cancel-search! state)
+        ;; Cancel old search & clear results
+        (clear-results! state)
         ;; Start new search, store result channel in app-state
         (let [chan (api/search-documents query)]
           (om/transact! state (fn [state]
                                 (assoc state
                                        :search/query query
-                                       :search/results nil
                                        :search/channel chan)))
           (when-let [results (<! chan)]
             (doto state


csv export can choose a year

csv export can choose a year

--- src/ontrail/csv.clj
+++ src/ontrail/csv.clj
@@ -14,7 +14,7 @@
   (mq/with-collection EXERCISE
     (mq/find query)
     (mq/sort {:creationDate 1})
-    (mq/batch-size 5000)))
+    (mq/batch-size 1000)))

 (defn csv-escape [field]
   (let [s (str field)]
@@ -52,8 +52,8 @@
                      get-pace
                      tags])))

-(def ex-filter
-  {:creationDate {"$gte" (time/date-time 2013 1 1)}})
+(defn ex-filter [year user]
+  {"$and" [{:creationDate {"$gte" (time/date-time year 1 1)}} {:creationDate {"$lt" (time/date-time (inc year) 1 1)}} {:user user}]})

 (defn to-csv [exs]
   (str
@@ -63,5 +63,6 @@
 (defn export [params]
   (.info logger (str "Exporting csv " params))
   (if-let [user (:user params)]
-    (to-csv (exs (assoc ex-filter :user user)))
+    (let [year (if (:year params) (Integer/valueOf (:year params)) (time/year (time/now)))]
+      (to-csv (exs (ex-filter year user))))
     ""))


Remove type hint and add assertion

Remove type hint and add assertion

--- src/play_clj/g2d.clj
+++ src/play_clj/g2d.clj
@@ -55,7 +55,8 @@
       (:object arg)
       (NinePatch. (:object arg))
       (map? arg)
-      (let [{:keys [^TextureRegion region left right top bottom]} arg]
+      (let [{:keys [region left right top bottom]} arg]
+        (assert (and region left right top bottom))
         (NinePatch. region left right top bottom))
       :else
       arg)))


update eina message

update eina message

--- src/panpan/eina.clj
+++ src/panpan/eina.clj
@@ -1,5 +1,6 @@
 (ns panpan.eina
   (:require
+    [clojure.string    :as str]
     [panpan.github.rss :as rss]
     [jubot.adapter     :as ja]
     [jubot.scheduler   :as js]
@@ -10,6 +11,7 @@
 (def ^:const NAME "エイナ")
 (def ^:const ICON "https://dl.dropboxusercontent.com/u/14918307/slack_icon/eina.png")
 (def ^:private out #(do (ja/out (apply str %&) :as NAME :icon-url ICON) nil))
+(def ^:private pre #(str "```\n" % "\n```"))

 (def ^:const MESSAGES
   {:open-pull-request
@@ -50,12 +52,17 @@

 (defn eina-handler
   "エイナ(さん)?.+github.+テスト - github rss 取得のテスト"
-  [{:keys [text]}]
-  (when (re-find #"エイナ(さん)?.+github.+テスト" text)
-    (jb/set rss/RSS_URL nil)
-    (doseq [feed (rss/get-github-feeds)]
-      (out (rss/github-respond feed)))
+  [{:keys [user] :as arg}]
+  (jh/regexp arg
+    #"エイナ(さん)?.+github.*テスト"
+    (fn [& _]
+      (out "@" user " はーい")
+      (jb/set rss/RSS_URL nil)
+      (->> (rss/get-github-feeds)
+           (map rss/github-respond)
+           (str/join "\n")
+           pre
+           out)

-    (jb/set rss/RSS_URL nil)
-    ((first github-schedule))))
-
+      (jb/set rss/RSS_URL nil)
+      ((first github-schedule)))))


[en/time] 'next <time>' only catches non-latent times

--- resources/duckling/rules/en.time.clj
+++ resources/duckling/rules/en.time.clj
@@ -221,7 +221,7 @@
   (pred-nth %2 0)

   "next <time>"
-  [#"(?i)next" (dim :time)]
+  [#"(?i)next" (dim :time #(not (:latent %)))]
   (pred-nth-not-immediate %2 0)

   "last <time>"


Use Ryu for json floating point

Use Ryu for json floating point

--- src/cavm/json.clj
+++ src/cavm/json.clj
@@ -1,5 +1,7 @@
 (ns cavm.json
   (:import (java.io PrintWriter))
+  (:import info.adams.ryu.RyuFloat)
+  (:import info.adams.ryu.RoundingMode)
   (:require [clojure.data.json :as json]))

 ;
@@ -18,9 +20,9 @@
   (json/-write (seq arr) out)) ; XXX is the seq here expensive? Using vec fails.

 (defn- write-floating-point [x ^PrintWriter out]
-   (if (Double/isNaN x)
-     (.print out "\"NaN\"")
-     (.format out java.util.Locale/US "%.4g" (to-array [x]))))
+  (if (Double/isNaN x)
+    (.print out "\"NaN\"")
+    (.print out (RyuFloat/floatToString x RoundingMode/ROUND_EVEN 4))))

 (extend mikera.arrayz.INDArray json/JSONWriter {:-write write-array})
 (extend java.lang.Float json/JSONWriter {:-write write-floating-point})


wheeee

wheeee

--- src/caws/core.clj
+++ src/caws/core.clj
@@ -4,3 +4,7 @@
   "I don't do a whole lot."
   [x]
   (println x "Hello, World!"))
+
+(defn start [router & {:keys [ip port]
+                       :or {ip "0.0.0.0" port 8080}}]
+  )


Shorter code.

Shorter code.

--- src/cbfg/net.cljs
+++ src/cbfg/net.cljs
@@ -11,6 +11,11 @@
        (doseq [[result-ch msg] results]
          (aclose cleanup result-ch)))
   :done)
+
+(defn add-result [results result-ch result]
+  (if result-ch
+    (conj results [result-ch :ok])
+    results))

 (defn make-net [actx request-listen-ch request-connect-ch & opts]
   (ago-loop net actx
@@ -72,8 +77,7 @@
                          server-recv-ch (achan-buf net end-point-buf-size)
                          close-server-recv-ch (achan net)]
                      ; TODO: Need to model running out of ports.
-                     (recur (inc ts)
-                            listens
+                     (recur (inc ts) listens
                             (-> streams
                                 (assoc client-send-ch {:send-ch client-send-ch
                                                        :recv-ch server-recv-ch
@@ -98,45 +102,27 @@
                      stream (get streams send-ch)
                      [msg result-ch] v]
                  (if v
-                   (if (:recv-ch stream)
-                     (recur (inc ts)
-                            listens
+                   (recur (inc ts) listens
+                          (if (:recv-ch stream)
                             (update-in streams [send-ch :msgs]
                                        conj [(+ ts (get opts :delivery-delay 0)) msg])
-                            (if result-ch
-                              (conj results [result-ch :ok])
-                              results))
-                     (recur (inc ts)
-                            listens
-                            streams
-                            (if result-ch
-                              (conj results [result-ch :error])
-                              results)))
-                   (if (:recv-ch stream)
-                     (recur (inc ts)
-                            listens
+                            streams)
+                          (add-result results result-ch :ok))
+                   (recur (inc ts) listens
+                          (if (:recv-ch stream)
                             (assoc-in streams [send-ch :send-closed] true)
-                            (if result-ch
-                              (conj results [result-ch :ok])
-                              results))
-                     (recur (inc ts)
-                            listens
-                            (dissoc streams send-ch)
-                            (if result-ch
-                              (conj results [result-ch :ok])
-                              results)))))
+                            (dissoc streams send-ch))
+                          (add-result results result-ch :ok))))
                :else ; Test if it's a completed deliverable (recv-ch aput'ed).
                (if-let [stream (first (filter #(= (:recv-ch %) ch) (vals streams)))]
                  (let [stream2 (update-in stream [:msgs] rest)]
                    (if (and (:send-closed stream2)
                             (empty? (:msgs stream2)))
                      (do (aclose net (:recv-ch stream2))
-                         (recur (inc ts)
-                                listens
+                         (recur (inc ts) listens
                                 (dissoc streams (:send-ch stream2))
                                 results))
-                     (recur (inc ts)
-                            listens
+                     (recur (inc ts) listens
                             (assoc streams (:send-ch stream2) stream2)
                             results)))
                  (if-let [stream (first (filter #(= (:close-recv-ch %) ch) (vals streams)))]
@@ -162,9 +148,7 @@
                                   results)))
                      (if (seq (filter #(= ch (first %)) results))
                        (do (aclose net ch) ; Handle a completed result-ch aput.
-                           (recur (inc ts)
-                                  listens
-                                  streams
+                           (recur (inc ts) listens streams
                                   (remove #(= (first %) ch) results)))
                        (println "UNKNOWN ch"
                                 listens :streams streams :results results)))))))))


Remove out-of-date docstring

Remove out-of-date docstring

--- src-cljs/frontend/utils.cljs
+++ src-cljs/frontend/utils.cljs
@@ -245,7 +245,6 @@
                                  "CircleCI"))))

 (defn set-page-description!
-  "This is an experiment... Not sure if GoogleBot looks at this after rendering."
   [description]
   (let [meta-el (.querySelector js/document "meta[name=description]")]
     (.setAttribute meta-el "content" description)))


Fix build breaker

Fix build breaker

--- src/shuppet/elb.clj
+++ src/shuppet/elb.clj
@@ -15,7 +15,7 @@
 (def ^:const ^:private elb-url (env :service-aws-elb-url))
 (def ^:const ^:private elb-version (env :service-aws-elb-api-version))

-(defn- get-request
+(defn get-request
   [params]
   (let [url (str elb-url  "/?" (map-to-query-string
                                 (merge {"Version" elb-version} params)))
@@ -72,12 +72,12 @@
 (defn- elb-config [config]
   (dissoc config :HealthCheck))

-(defn- create-healthcheck [config]
+(defn create-healthcheck [config]
   (get-request (merge {"Action" "ConfigureHealthCheck"} (to-aws-format (healthcheck-config config))))
   (log/info "I've created a new health check config for" (elb-name config))
   config)

-(defn- create-elb [config]
+(defn create-elb [config]
   (get-request (merge {"Action" "CreateLoadBalancer"} (to-aws-format  (elb-config config))))
   (log/info "I've created a new ELB called" (elb-name config))
   config)


generate version 6 bytecode by default for jdk 6

--- src/insn/core.clj
+++ src/insn/core.clj
@@ -9,6 +9,10 @@
            [java.io File FileOutputStream]
            [java.lang.reflect Constructor]))

+(def ^:private jvm-version
+  (-> (System/getProperty "java.specification.version")
+      Double/valueOf))
+
 (def ^{:doc "The class/interface flags to use if unspecified."
        :dynamic true}
   *class-flags* #{:public :final})
@@ -27,7 +31,8 @@

 (def ^{:doc "The bytecode version to use for types if unspecified."
        :dynamic true}
-  *bytecode-version* 1.7)
+  *bytecode-version*
+  (if (>= jvm-version 1.7) 7 6))

 ;;;


CMR-2312 Adds test for JSON schema parsing errors.

--- umm-spec-lib/test/cmr/umm_spec/test/umm_json.clj
+++ umm-spec-lib/test/cmr/umm_spec/test/umm_json.clj
@@ -131,3 +131,12 @@
                                                 (umm-cmn/map->RangeDateTimeType
                                                  {:BeginningDateTime (t/date-time 2002)
                                                   :EndingDateTime (t/date-time 2003)})]})]}))))
+
+(deftest json-schema-parsing-errors
+  (is (= "Could not parse value: foo"
+         (-> {:SpatialExtent {:OrbitParameters {:NumberOfOrbits "foo"}}}
+             js/parse-umm-c
+             :SpatialExtent
+             :OrbitParameters
+             :_errors
+             :NumberOfOrbits))))


Unprep planes properly

Unprep planes properly

--- renderer/src/renderer/engine/draw.cljs
+++ renderer/src/renderer/engine/draw.cljs
@@ -240,9 +240,10 @@

 (defn unprep-planes-state! [gl]
   ;; reverse the state here
-  (doto gl
-    (.disableVertexAttribArray (:position a))
-    (.bindBuffer bo/array-buffer nil)))
+  (let [{a :attribs} (s/create-get-plane-shader gl)]
+    (doto gl
+      (.disableVertexAttribArray (:position a))
+      (.bindBuffer bo/array-buffer nil))))

 (let [m (js/vec3.create)
       na (js/vec3.create)                                   ;


add function metadata

add function metadata

--- src/quil/core.clj
+++ src/quil/core.clj
@@ -4375,8 +4375,15 @@
   [app-name & opts]
   `(defapplet ~app-name ~@opts))

-(defn key-coded?
-  "Returns true if char c is a 'coded' char i.e. it is necessary to fetch the key-code as an integer and use that to determine the specific key pressed. See key-keyword."
+(defn ^{:requires-bindings false
+        :processing-name nil
+        :category "Input"
+        :subcategory "Keyboard"
+        :added "1.6"}
+  key-coded?
+  "Returns true if char c is a 'coded' char i.e. it is necessary to
+  fetch the key-code as an integer and use that to determine the
+  specific key pressed. See key-keyword."
   [c]
   (= PConstants/CODED (int c)))

@@ -4415,7 +4422,12 @@
              KeyEvent/VK_F23     :f23
              KeyEvent/VK_F24     :f24})

-(defn key-as-keyword
+(defn ^{:requires-bindings true
+        :processing-name nil
+        :category "Input"
+        :subcategory "Keyboard"
+        :added "1.6"}
+  key-as-keyword
   "Returns a keyword representing the currently pressed key. Modifier
   keys are represented as: :up, :down, :left, :right, :alt, :control,
   :shift, :command, :f1-24"


Update zh_hans.cljs

Update zh_hans.cljs

corrected some errors

--- src/status_im/translations/zh_hans.cljs
+++ src/status_im/translations/zh_hans.cljs
@@ -12,7 +12,7 @@
    ;drawer
    :invite-friends                        "邀请朋友"
    :faq                                   "常问问题解答"
-   :switch-users                          "S切换用户"
+   :switch-users                          "切换用户"

    ;chat
    :is-typing                             "正在打字"
@@ -33,14 +33,14 @@

    ;sync
    :sync-in-progress                      "正在同步…"
-   :sync-synced                           "同步中"
+   :sync-synced                           "已同步"

    ;messages
    :status-sending                        "正在发送"
-   :status-pending                        "发送中"
+   :status-pending                        "等待中"
    :status-sent                           "已发送"
    :status-seen-by-everyone               "所有人可见"
-   :status-seen                           "看到"
+   :status-seen                           "可见"
    :status-delivered                      "已交付"
    :status-failed                         "失败"

@@ -90,7 +90,7 @@
    :written-down                          "确保你把它安全地写下来"
    :phone-number-required                 "点击此处输入你的电话号码，我会找到你的朋友"
    :intro-status                          "跟我聊天，以设置你的帐户并更改你的设置！"
-   :intro-message1                        "欢迎来到状态\n点击该消息，以设置你的密码并开始！"
+   :intro-message1                        "欢迎来到Status\n点击该消息，以设置你的密码并开始！"
    :account-generation-message            "给我一点时间，我得疯狂地计算一下，以生成你的帐户！"

    ;chats
@@ -117,7 +117,7 @@
    :contacts-group-people                 "联系人"
    :contacts-group-new-chat               "开始新的聊天"
    :no-contacts                           "还没有联系人"
-   :show-qr                               "显示QR"
+   :show-qr                               "显示二维码"

    ;group-settings
    :remove                                "删除"
@@ -173,11 +173,11 @@
    ;new-contact
    :add-new-contact                       "添加新的联系人"
    :import-qr                             "导入"
-   :scan-qr                               "扫描QR"
+   :scan-qr                               "扫描二维码"
    :name                                  "名称"
    :whisper-identity                      "Whisper身份"
    :address-explication                   "也许这里应该有一些文本来解释什么是地址，以及在哪里查找它"
-   :enter-valid-address                   "请输入有效地址或扫描QR码"
+   :enter-valid-address                   "请输入有效地址或扫描二维码"
    :contact-already-added                 "已添加该联系人"
    :can-not-add-yourself                  "不能添加自己"
    :unknown-address                       "未知地址"


so much faster debugger rendering

so much faster debugger rendering

Signed-off-by: Chris Granger <5654cde260ae99bc4d30054171b8bcd902efd19a@gmail.com>

--- src/aurora/editor/ui.cljs
+++ src/aurora/editor/ui.cljs
@@ -386,31 +386,28 @@
                               (second)
                               (language/flow->nodes))))
         active-outs (when-let [cur (aget out-nodes cur-active)]
-                      (set cur))]
+                      (set cur))
+        iy (+ 25 (* cur-active 60))]
     [:div#debugger-middle
      [:svg {:width 100 :height (* 60 (count flows))}
       (concat
-       (for [[i flow] flows
-             :let [iy (+ 25 (* i 60))]
-             in (language/flow->nodes flow)
+       (for [in active-ins
              :let [y (+ 25 (* in 60))
                    diff (js/Math.abs (- iy y))
-                   cx (- 100 (max 30 (min 100 (* 10 (js/Math.abs (- i in))))))
+                   cx (- 100 (max 30 (min 100 (* 10 (js/Math.abs (- cur-active in))))))
                    cy (if (> iy y)
                         (+ y (/ diff 2))
                         (+ iy (/ diff 2)))]]
-         (debugger-path iy cx cy y (if (= i cur-active) :in))
+         (debugger-path iy cx cy y :in)
          )
-       (for [[i flow] flows
-             :let [iy (+ 25 (* i 60))]
-             in (aget out-nodes i)
+       (for [in active-outs
              :let [y (+ 25 (* in 60))
                    diff (js/Math.abs (- iy y))
-                   cx (- 100 (max 30 (min 100 (* 10 (js/Math.abs (- i in))))))
+                   cx (- 100 (max 30 (min 100 (* 10 (js/Math.abs (- cur-active in))))))
                    cy (if (> iy y)
                         (+ y (/ diff 2))
                         (+ iy (/ diff 2)))]]
-         (debugger-path iy cx cy y (if (= i cur-active) :out))
+         (debugger-path iy cx cy y :out)
          )
        )]
      [:ul


fix bug in generation of spanish

fix bug in generation of spanish

add {:synsem {:sem {:reflexive false}} to
(intransitive-unspecified-obj) definition to prevent this rule from
applying to reflexive verbs

--- src/babel/espanol/pos.clj
+++ src/babel/espanol/pos.clj
@@ -49,6 +49,7 @@

 (def intransitive-unspecified-obj
   (unifyc verb-subjective
+          {:synsem {:sem {:reflexive false}}}
           pos/intransitive-unspecified-obj))

 (def intransitive


Order and group items before generating neu als hörbuch

--- src/catalog/web/views.clj
+++ src/catalog/web/views.clj
@@ -95,8 +95,9 @@
 (defn neu-als-hörbuch [year issue]
   (let [temp-file (java.io.File/createTempFile (file-name :catalog-hörbuch year issue) ".pdf")
         editorial (db/read-editorial year issue :hörbuch)
-        recommendation (db/read-recommendation issue :hörbuch)]
-    (-> (db/read-catalog year issue)
+        recommendation (db/read-recommendation year issue :hörbuch)]
+    (-> (db/read-catalog year issue)
+        (vubis/order-and-group vubis/get-update-keys-neu-als-hörbuch)
         (layout.fop/document :hörbuch editorial recommendation)
         (layout.fop/generate-pdf! temp-file))
     (-> temp-file


player-view has no component state, can use IRender

--- src-cljs/core.cljs
+++ src-cljs/core.cljs
@@ -238,8 +238,8 @@
                            #(put! (om/get-state owner :dequeue)
                                   (first (:player-queue @app)))
                            true)))
-    om/IRenderState
-    (render-state [this state]
+    om/IRender
+    (render [this]
       (let [queue (om/observe owner (player-queue))
         bits (best-media-url (first queue))]
         (dom/div nil


tabs vs spaces

tabs vs spaces

--- src/cion_clojure/core.clj
+++ src/cion_clojure/core.clj
@@ -1,17 +1,16 @@
 (ns cion-clojure.core
-  (:gen-class)
-  (:require [clj-http.client :as client])
-  (:require [clojure.data.json :as json])
-  (:use [clojure.data.xml], [clojure.tools.cli :only [cli]]))
+	(:gen-class)
+	(:require [clj-http.client :as client])
+	(:require [clojure.data.json :as json])
+	(:use [clojure.data.xml], [clojure.tools.cli :only [cli]]))

 (defn create-project [project-name ci-server-url]
-  (client/post (str ci-server-url "/httpAuth/app/rest/projects")
-  {:body project-name
-   :content-type "text/plain"
-   :accept :xml}))
-
-(defn create-projects [project-names ci-server-url]
-	(map create-project project-names ci-server-url))
+	(client/post (str ci-server-url "/httpAuth/app/rest/projects")
+		{
+			:body project-name
+			:content-type "text/plain"
+			:accept :xml
+		}))

 (defn extract-name [node]
 	(:name (:attrs node)))
@@ -26,22 +25,23 @@
 	(str "\"" s "\""))

 (defn -main [& args]
-  (alter-var-root #'*read-eval* (constantly false))
-  (def command-line-options
-	(cli args
-	["-u" "--url" "CI server api url" :default ""]
-	["-f" "--file" "Setup CI server using specified file" :default ""]))
-  (if (= args nil)
-	(print (nth command-line-options 2))
-	(do
-		(def command-line-values
-			(first command-line-options))
-		(if (= (:file command-line-values) "")
-			(do
-				(def project-names (get-project-names (:url command-line-values)))
-				(defn project-as-json [project-name]
-					(str "{	\"project\": { \"name\": " (quoted project-name) "}}"))
-				(println "{ \"projects\" : [" (clojure.string/join ",\n " (map project-as-json project-names)) "] }"))
-			(do
-				(def projects (:projects (json/read-str (slurp (:file command-line-values)) :key-fn keyword)))
-				(println projects))))))+	(alter-var-root #'*read-eval* (constantly false))
+	(def command-line-options
+		(cli args
+			["-u" "--url" "CI server api url" :default ""]
+			["-f" "--file" "Setup CI server using specified file" :default ""]))
+	(if (= args nil)
+		(print (nth command-line-options 2))
+		(do
+			(def command-line-values (first command-line-options))
+			(def ci-server-url (:url command-line-values))
+			(if (= (:file command-line-values) "")
+				(do
+					(def project-names (get-project-names ci-server-url))
+					(defn project-as-json [project-name]
+						(str "{	\"project\": { \"name\": " (quoted project-name) "}}"))
+					(println "{ \"projects\" : [" (clojure.string/join ",\n " (map project-as-json project-names)) "] }"))
+				(do
+					(def projects (map :project (:projects (json/read-str (slurp (:file command-line-values)) :key-fn keyword))))
+					(def project-names (map :name projects))
+					(print project-names))))))


some stats

some stats

--- src/clj/ceres/curator.clj
+++ src/clj/ceres/curator.clj
@@ -24,14 +24,12 @@
             [ceres.collector :refer [db custom-formatter news-accounts store]])
  (:import org.bson.types.ObjectId))

-
 (defrecord Source [name articles])
 (defrecord Article [source tweet reactions])
 (defrecord Reaction [tweet reactions])

 (def tokenize (make-tokenizer "data/de-token.bin"))
 (def stopwords (read-string "data/stopwords.txt"))
-

 ;; --- DATA MINING ---

@@ -94,20 +92,20 @@
   "Find all tweets that are related to a given tweet by a retweet or reply"
   [tweet]
   (let [tweet-id (:id_str tweet)
-        neighbor-tweets (->> (mc/find-maps
-                              @db
-                              "tweets"
-                              {$and [{$or [{"retweeted_status.id_str" tweet-id}
-                                           {"in_reply_to_status_id_str" tweet-id}]}
-                                     {:created_at {$gt (t/date-time 2014 7 1)}}]}))]
-    (Reaction. tweet (vec (doall (pmap spread neighbor-tweets))))))
+        neighbor-tweets (mc/find-maps
+                         @db
+                         "tweets"
+                         {$and [{$or [{"retweeted_status.id_str" tweet-id}
+                                      {"in_reply_to_status_id_str" tweet-id}]}
+                                {:created_at {$gt (t/date-time 2014 7 1)}}]})]
+    (Reaction. tweet (vec (pmap spread neighbor-tweets)))))

 (defn compute-impact-tree
   "Create the impact tree using clojure zippers"
   [origin]
   (let [article (if (:article origin)
-                      (mc/find-map-by-id @db "articles" (:article origin))
+                  (mc/find-map-by-id @db "articles" (:article origin))
                       nil)
         tweet (mc/find-map-by-id @db "tweets" (:tweet origin))]
     (let [related-origins (if article
@@ -117,12 +115,12 @@
                                   (pmap #(mc/find-map-by-id @db "tweets" %))
                                   (filter #(or (nil? (-> % :retweeted_status :id_str)) (= (-> % :retweeted_status :id_str) (:id_str tweet)))))
                              nil)
-          related-tweets (->> (mc/find-maps
-                                @db
-                                "tweets"
-                                {$and [{$or [{"retweeted_status.id_str" (:id_str tweet)}
-                                             {"in_reply_to_status_id_str" (:id_str tweet)}]}
-                                       {:created_at {$gt (t/date-time 2014 7 1)}}]}))
+          related-tweets (mc/find-maps
+                          @db
+                          "tweets"
+                          {$and [{$or [{"retweeted_status.id_str" (:id_str tweet)}
+                                       {"in_reply_to_status_id_str" (:id_str tweet)}]}
+                                 {:created_at {$gt (t/date-time 2014 7 1)}}]})
           merged-articles (into related-origins related-tweets)]
       (zip/zipper
        (fn [node] true)
@@ -141,7 +139,8 @@
 (defn compute-impact-forest
   "Compute article impact forest of given news source"
   [source]
-  (let [source-origins (mc/find-maps @db "origins" {:source source})]
+  (let [source-origins (mc/find-maps @db "origins" {:source source :ts {$gt (t/date-time 2014 7 1)
+                                                                        $lt (t/date-time 2014 8 1)}})]
     (vec (pmap compute-impact-tree source-origins))))

@@ -195,6 +194,7 @@
          delays)
        (zip/next loc)))))

+
 (defn build-tree-from-source [id]
   (let [origin (mc/find-map-by-id @db "origins" id)
         tree (compute-impact-tree origin)]
@@ -202,6 +202,7 @@
      :tree tree
      :analysis (analyze-tree tree)}))

+
 (defn random-tree []
   (let [origin (rand-nth (mc/find-maps @db "origins" {:source {$in news-accounts}}))
         tree (compute-impact-tree origin)]
@@ -212,7 +213,7 @@

 (defn compute-summary [source]
   (let [impact-forest (compute-impact-forest source)
-        analytics (map analyze-tree impact-forest)
+        analytics (pmap analyze-tree impact-forest)
         sizes (map :size analytics)
         pub-times (map :pub-times analytics)
         heights (map :height analytics)
@@ -255,6 +256,7 @@
         "--query" (str "{" (if (= coll "tweets") "created_at" "ts") " : {$gte : new Date(" (c/to-long date) "), $lt : new Date(" (c/to-long day-after) ")}}")
         "--out" file-path)))

+
 (defn backup-yesterday
   "Write last day's collection to specific folder"
   [database coll folder-path]
@@ -272,13 +274,20 @@
       (:_id x)
       (update-in x [:created_at] #(f/parse custom-formatter (:created_at %))) )))

+  (mc/indexes-on @db "tweets")

   (def some-tree (build-tree-from-source (ObjectId. "53fcc425e4b09b711bdec9a9" )))

   ;; "53fcc425e4b09b711bdec9a9" "53fe02bbe4b09b711bdf26f2" "53f33d9ee4b0c2a12eb4a339" "53ff738fe4b09b711bdfa9c7"

-
-  (def rand-tree (random-tree))
+  (def rand-tree (time (random-tree)))
+
+  (loop [counter 10]
+    (if (= counter 0)
+      :true
+      (do (time (random-tree))
+          (recur (dec counter)))))
+

   (-> rand-tree :analysis :height)

@@ -290,7 +299,7 @@

   (def g
     (let [vertices (loop [nodes []
-                          loc (:tree some-tree)]
+                          loc (:tree rand-tree)]
                      (if (zip/end? loc)
                        nodes
                        (recur
@@ -314,7 +323,7 @@

-  (def sum-tagesschau (compute-summary "tagesschau"))
+  (def sum-tagesschau (time (compute-summary "tagesschau")))

   (def sum-faz (compute-summary "FAZ_NET"))

@@ -362,7 +371,7 @@

   ;; tweet counts
-  (let [days-running (t/in-days (t/interval (t/date-time 2014 7 2) (t/date-time 2014 9 15)))
+  (let [days-running (t/in-days (t/interval (t/date-time 2014 7 2) (t/date-time 2014 10 12)))
         dates (take days-running (p/periodic-seq (t/date-time 2014 7 2) (t/days 1)))
         sz-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "SZ" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
         spon-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "SPIEGELONLINE" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
@@ -377,7 +386,7 @@
     (view (line-chart days-since-start tweet-counts :legend true :group-by grouping)))

-  (let [days-running (t/in-hours (t/interval (t/date-time 2014 7 2) (t/date-time 2014 9 12)))
+  (let [days-running (t/in-hours (t/interval (t/date-time 2014 7 2) (t/date-time 2014 10 12)))
         dates (take days-running (p/periodic-seq (t/date-time 2014 7 2) (t/hours 1)))
         tweet-count (map #(mc/count @db "tweets" {:created_at {$gte % $lt (t/plus % (t/hours 1))}}) dates)
         time (range days-running)
@@ -391,22 +400,30 @@
     (view (line-chart (range 24) avg-tweets-per-hour)))

-  (let [days-running (t/in-days (t/interval (t/date-time 2014 7 2) (t/date-time 2014 9 22)))
+  (let [days-running (t/in-days (t/interval (t/date-time 2014 7 2) (t/date-time 2014 10 13)))
         dates (take days-running (p/periodic-seq (t/date-time 2014 7 2) (t/days 1)))
         tweet-count (map #(mc/count @db "tweets" {:created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
         days (range  2 (inc (inc days-running)))]
-    (view (line-chart days tweet-count :title "tweet counts" :y-label "Tweet Count" :x-label "Day")))
+    (view (scatter-plot days tweet-count :title "tweet counts" :y-label "Tweet Count" :x-label "Day")))

   ;; user posts distribution
   (let [users (->> (mc/find-maps
                     @db "tweets"
-                    {:created_at {$gt (t/date-time 2014 7 2)}}
-                    ["user.screen_name"])
+                    {$and
+                     [
+                      {:created_at {$gt (t/date-time 2014 7 1)
+                                    $lt (t/date-time 2014 10 1)}}
+                      {:user.screen_name {$ne news-accounts}}]
+                     ["user.screen_name"]})
                    (pmap #(-> % :user :screen_name))
                    frequencies)
-        unique-posters #(float (/ (count %) (count users)))]
-    (view (histogram (filter #(< % 51) (vals users)) :nbins 50)))
+        unique-posters #(float (/ (count %) (count users)))
+        post-counter (frequencies (vals users))]
+    (->> users
+         (sort-by second >)
+         (take 10)
+         aprint))

   ;; news posts fraction
@@ -416,9 +433,29 @@
                                         {:user.screen_name {$in news-accounts} }]})]
     (aprint (float (/ news-count overall-count))))

-
-
-
+  (def origin (time (rand-nth (mc/find-maps @db "origins" {:source {$in news-accounts}}))))
+
+  (println "\n")
+
+  (def tree (time (compute-impact-tree origin)))
+
+  (def dpa-sum (time (compute-summary "dpa")))
+
+  (aprint (keys dpa-sum))
+
+  (def tagesschau-sum (time (compute-summary "tagesschau")))
+
+  (aprint (dissoc dpa-sum :heights :sizes :users :hashtags :pub-times :no-reactions :delays))
+
+
+  (->> (mc/find-maps @db "tweets" {:created_at {$gt (t/date-time 2014 7 1)
+                                                $lt (t/date-time 2014 10 1)}}
+                     [:user.id_str])
+       (pmap #(-> % :user :id_str))
+       (into #{})
+       count
+       aprint
+       time)

   )


* src/clj/cljs/compiler.clj: :name-sym -> :name

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -350,7 +350,7 @@
             (vary-meta n
               (fn [m]
                 (merge m {:line (:line env)
-                          :name (:name-sym info)})))
+                          :name (:name info)})))
             n)]
     (emit-wrap env (emits n))))


Clean.

Clean.

--- src/clj/minijava/tree.clj
+++ src/clj/minijava/tree.clj
@@ -10,8 +10,7 @@
 (def *methods* (atom (hash-map)))

 (defn addMethod [name method frame]
-  (reset! *methods* (assoc @*methods* name {:ir method :frame frame}))
-)
+  (reset! *methods* (assoc @*methods* name {:ir method :frame frame})))

 (defn binop
   "Quick BinaryOp for objects with e1 and e2 fields."
@@ -21,15 +20,13 @@

 (defn apply-tree [prog]
   (tree prog nil)
-  @*methods*
-)
+  @*methods*)

 (defn tree-prog
   "Walks through a program, applying tree."
   [seq]
   (let [frame (new-x86 0 [] nil)]
-    (for [s seq] (tree s frame)))
-)
+    (for [s seq] (tree s frame))))

 (defmacro deftree [type [obj frame] & body]
   `(extend-class ~type
@@ -99,8 +96,7 @@
                 frame (new-x86 0 (cons "obj" args) obj)
                 name (str (.name x) "_" (.name i))
                 ir (Seq (cons (Label name) (tree i frame)))]
-(addMethod name ir frame)
-))))})
+            (addMethod name ir frame)))))})


c3p0 pool

c3p0 pool

--- src/clojure/nossal/db.clj
+++ src/clojure/nossal/db.clj
@@ -5,7 +5,6 @@
             [jdbc.pool.c3p0 :as pool]
             [environ.core :refer [env]]
             [heroku-database-url-to-jdbc.core :as hdu]))
-

 (def db
   (pool/make-datasource-spec


Add evaluation of case statement

Add evaluation of case statement

--- src/clojure_ruby/core.clj
+++ src/clojure_ruby/core.clj
@@ -122,6 +122,17 @@
     (if predicate
       (mapv evaluate body))))

+(defmethod evaluate-one :case [stmt]
+  (let [[_ predicate & whens] stmt
+        predicate (evaluate predicate)]
+    (loop [whens whens]
+      (if-let [[when & whens] (seq whens)]
+        (let [[_ matcher & body] when
+              matcher (evaluate matcher)]
+          (if (rb-send predicate "===" [matcher])
+            (mapv evaluate body)
+            (recur whens)))))))
+
 (defn evaluate [stmt]
   (prn stmt)
   (try


Resolve merge conflict.

Resolve merge conflict.

--- src/clu/server/sounds.clj
+++ src/clu/server/sounds.clj
@@ -4,31 +4,33 @@

 (def msg-queue (chan 32))

-(defn basic-handler
-  [x y]
-  (println "hey hey hey")
-  {:data {:x x
-          :y y}})
-
-(def dispatch
-  {[1 1] #'basic-handler})
+(def dispatch (atom {}))

 (defn listen!
   []
   (do
     (async/go-loop []
       (let [{:keys [x y] :as msg} (<! msg-queue)]
-        (when-let [handler-fn (get dispatch [x y])]
+        (when-let [handler-fn (-> dispatch deref (get [x y]))]
           (handler-fn x y)))
       (recur))
     :ok))

 (defn handle-message
   [{:keys [x y] :as params}]
-  (def params params)
   (go
     (>! msg-queue {:x x
                    :y y})))
+
+(defmacro register
+  [x y & handler-fn]
+  `(swap! dispatch assoc [~x ~y] (fn [~'x ~'y]
+                                   ~@handler-fn)))
+
+(register
+ 1 1
+ {:data {:x x
+         :y y}})

 (o/definst bell
   [freq 440]


corrected runner start up functionality based on repl (user.clj) behavior.

--- src/cmr/ingest/runner.clj
+++ src/cmr/ingest/runner.clj
@@ -38,5 +38,5 @@
         db (metadata-db/create)
         idx-db (indexer/create)
         log (log/create-logger)
-        system (system/start (system/create-system log db web-server))]
+        system (system/start (system/create-system log db idx-db web-server))]
     (info "Running...")))


write-problem-* tests added

write-problem-* tests added

--- test/lein_fore_prob/test/core.clj
+++ test/lein_fore_prob/test/core.clj
@@ -271,10 +271,27 @@
   (is (= (with-redefs [slurp (constantly "xY3")] (#'fp/get-src {:title "yo"})))
       "xY3"))

-;; TODO
-
-(deftest write-problem-tests)
-(deftest write-problem-src)
+(deftest write-problem-tests
+  (with-redefs [spit (fn [f code & _]
+                       (is (= "test/foo/core_test.clj" (. f getPath)))
+                       (is (= (str "\n\n"
+                                   "(deftest can-foo-bar\n"
+                                   "  (is (= (foo-bar-solution 42) 21))\n"
+                                   "  (is (= (foo-bar-solution 21) 42)))\n")
+                              code)))]
+    (#'fp/write-problem-tests {:group "foo"} "" prob1)))
+
+(deftest write-problem-src
+  (with-redefs [spit (fn [f code & _]
+                       (is (= "src/foo/core.clj" (. f getPath)))
+                       (is (= (str "\n\n"
+                                   "(defn foo-bar-solution\n"
+                                   "  [& args] ;; update args as needed\n"
+                                   "  ;; write a foo bar\n"
+                                   "  nil)\n")
+                              code)))]
+    (#'fp/write-problem-src {:group "foo"} prob1)))

 (deftest write-prob)
+
 (deftest fore-prob)


remove unnecessary definition of reduce*

--- src/eulalie/platform.cljs
+++ src/eulalie/platform.cljs
@@ -7,7 +7,7 @@
             [eulalie.platform.util :refer [channel-fn]]
             [eulalie.util.service :refer [concretize-port]]
             [glossop.core :as glossop :refer-macros [go-catching <?]]
-            [glossop.util :refer [close-with!]]))
+            [glossop.util :as glossop.util :refer [close-with!]]))

 (def http  (nodejs/require "http"))
 (def https (nodejs/require "https"))
@@ -41,20 +41,12 @@
     (.end node-req body)
     ch))

-(defn reduce* [f init ch]
-  (go-catching
-    (loop [ret init]
-      (let [v (<? ch)]
-        (if (nil? v)
-          ret
-          (recur (f ret v)))))))
-
 (defn channel-request! [req]
   (go-catching
     (try
       (let [ch    (request! req)
             resp  (<? ch)
-            body  (<? (reduce* str "" ch))]
+            body  (<? (glossop.util/reduce str "" ch))]
         (assoc resp :body body))
       (catch js/Error e
         {:error e}))))


Adding addtl arg to the create-feed example

--- src/foreclojure/feeds.clj
+++ src/foreclojure/feeds.clj
@@ -43,5 +43,6 @@
         (create-feed  "Recent Problems"
                       "http://4clojure.com"
                       "Recent problems at 4clojure"
+                      "http://4clojure.com/problems/rss"
                       (problem-feed 20))))


Fixing a bug where a user would try to lookup a non-existing user's profile and in return would get a empty profile. Now the returned page is a 404 with an error message.

--- src/foreclojure/users.clj
+++ src/foreclojure/users.clj
@@ -3,7 +3,7 @@
             [clojure.string           :as string]
             [sandbar.stateful-session :as session]
             [cheshire.core            :as json])
-  (:use     [foreclojure.utils        :only [from-mongo row-class rank-class get-user if-user with-user]]
+  (:use     [foreclojure.utils        :only [from-mongo row-class rank-class get-user if-user with-user flash-error ]]
             [foreclojure.template     :only [def-page content-page]]
             [foreclojure.ring-utils   :only [*http-scheme* static-url]]
             [foreclojure.config       :only [config repo-url]]
@@ -164,7 +164,7 @@
        :heading-note [:span#all-users-link]
        :sub-heading (list (format-user-ranking user-ranking)
                           [:span.contributor "*"] " "
-                          (link-to repo-url "4clojure contributor"))
+                          (link-to repo-url "4clojure contributor") [:br])
        :main (generate-user-list top-100 "user-table")})}))

 ;; TODO: this is snagged from problems.clj but can't be imported due to cyclic dependency, must refactor this out.
@@ -294,7 +294,10 @@
 (defroutes users-routes
   (GET  "/users" [] (top-users-page))
   (GET  "/users/all" [] (all-users-page))
-  (GET  "/user/:username" [username] (user-profile username))
+  (GET  "/user/:username" [username]
+    (if (nil? (get-user username))
+      {:status 404 :headers {"Content-Type" "text/plain"} :body "Error: This user does not exist, nice try though."}
+      (user-profile username)))
   (POST "/user/follow/:username" [username] (static-follow-user username true))
   (POST "/user/unfollow/:username" [username] (static-follow-user username false))
   (POST "/rest/user/follow/:username" [username] (rest-follow-user username true))


Add some documentation

Add some documentation

--- src/foreclojure/utils.clj
+++ src/foreclojure/utils.clj
@@ -33,8 +33,17 @@
      ~fail-expr
      ~body))

-(defn image-builder [data & {:keys [alt src] :or {alt identity,
-                                                  src identity}}]
+(defn image-builder
+  "Return a function for constructing an [:img] element from a keyword.
+
+  data should be a map from image \"names\" to pairs [src, alt]. The function
+  returned by image-builder will look up its argument as an image name, and
+  return an img element with the appropriate src and alt attributes.
+
+  Optionally, additional keyword arguments :alt and :src may be supplied to
+  image-builder - these functions will be called to transform the alt and src
+  attributes of the returned img."
+  [data & {:keys [alt src] :or {alt identity, src identity}}]
   (fn [key]
     (let [[src-prop alt-prop] (get data key)]
       [:img {:src (src src-prop)
@@ -109,18 +118,24 @@
        (>= (count (get-solved username))
            (:advanced-user-count config))))

+
 (defprotocol PageWriter
+  "Specify how an object should be converted to the {:title \"foo\" :content
+  [:div ...] :baz-attr true} format used by def-page for rendering pages."
   (page-attributes [this]))

 (extend-protocol PageWriter
   clojure.lang.IPersistentMap
+  ;; Supplied map should be used verbatim
   (page-attributes [this] this)

   Object
+  ;; User probably just returned a Hiccup structure; shove it into :content
   (page-attributes [this]
     {:content this})

   nil
+  ;; Allow to return nothing at all so Compojure keeps looking
   (page-attributes [this] nil))

 (let [defaults {:content nil


swap out TTLCachedMap for CachedMap

swap out TTLCachedMap for CachedMap

--- src/hambo/trident/cql.clj
+++ src/hambo/trident/cql.clj
@@ -8,8 +8,7 @@
             TransactionalMap
             OpaqueMap
             CachedMap
-            SnapshottableMap]
-           [calculon.storm.trident.state LRUCachedMap]))
+            SnapshottableMap]))

 (defn mk-map-state [state-type backing-map]
   (case state-type
@@ -36,5 +35,5 @@
         conn (cc/connect (s/split (get hambo-config conf/HAMBO-HOSTS) #",") {:keyspace keyspace})
         instrumented-map (backing-hof conn table)
         _ (.registerMetrics instrumented-map conf metrics prefix-name (int bucket-size))
-        cached-map (LRUCachedMap. instrumented-map cache-size)]
+        cached-map (CachedMap. instrumented-map cache-size)]
     (mk-map-state state-type cached-map)))


Fix getting episode url from addicted

Fix getting episode url from addicted

--- src/subman/sources/addicted.clj
+++ src/subman/sources/addicted.clj
@@ -47,12 +47,19 @@

 (defn- is-episode?
   "Is line a episode"
-  [line] (some-> line
-                 :content
-                 first
-                 :attrs
-                 :align
-                 (= "left")))
+  [line] (let [content (:content line)]
+           (and (some-> content
+                        first
+                        :attrs
+                        :align
+                        (= "left"))
+                (some-> content
+                        vec
+                        (get 10)
+                        :content
+                        first
+                        :tag
+                        (= :a)))))

 (defn- get-season-number
   "Get season number from line"
@@ -70,7 +77,7 @@
   "Get episode name holder element"
   [line] (-> line
              :content
-             (nth 6)
+             last
              :content
              first))

@@ -89,7 +96,8 @@
           :url (-> line
                    get-episode-name-element
                    :attrs
-                   :href)})
+                   :href
+                   make-url)})

 (defn- get-seasons
   "Get season with episodes"


remove comment

remove comment

--- src/synthesis_crawlers/core.clj
+++ src/synthesis_crawlers/core.clj
@@ -27,7 +27,6 @@
   [extractor crawled-set]
   (crawled-set extractor))

-;; TODO return nil if it failed to access the specifined url
 (defn get-page
   "gets the specified web page and return its body"
   [url]
@@ -109,6 +108,9 @@
   [url root-url pattern to-be-crawled crawled-pages]
   (lazy-seq
     (cons
-      (let [matched-links  (filter some? (map #(let [found (re-seq pattern %)] (when found (first found))) (extract-links root-url (get-page url))))]
-        matched-links)
+      (let [matched-links  (filter some? (map #(let [found (re-seq pattern %)] (when found (first found))) (extract-links root-url (get-page url))))
+            uncrawled-links (filter #(not (crawled-pages %)) matched-links)]
+        uncrawled-links)
       nil)))
+
+#_(filter #(#{2} %)  [2 45 5])