Tweak news about 0.6.0

Tweak news about 0.6.0

--- demo/reagentdemo/news/news060.cljs
+++ demo/reagentdemo/news/news060.cljs
@@ -12,10 +12,8 @@
   (:require [reagent.core :as r]))"))

 (defonce app-state (r/atom {:people
-                            {1 {:name "John Smith"
-                                :title "Manager"}
-                             2 {:name "Maggie Johnson"
-                                :title "Senior Executive Manager"}}}))
+                            {1 {:name "John Smith"}
+                             2 {:name "Maggie Johnson"}}}))

 (defn people []
   (:people @app-state))
@@ -118,256 +116,23 @@
    [:h1 [link {:href url} title]]
    [:div.demo-text
     [:p "Reagent 0.6.0-alpha contains new reactivity helpers, better
-    integration with native React components, a new version of React,
-    and much more. "]
+    integration with native React components, a new version of
+    React (0.14.3), new React dependencies ("[:code "react-dom"]"
+    and "[:code "react-dom-server"]"), better performance, and much
+    more. "]
+
+    [:p "This is a quite big release, so it probably contains a fair
+    amount of bugs as well…"]

     (if summary
       [link {:href url :class 'news-read-more} "Read more"]
       [:div.demo-text
-       [:h2 "Use any function as a reactive value"]
-
-       [:p [:code "reagent.core/track"] " takes a function, and
-       optional arguments for that function, and gives a
-       derefable (i.e ”atom-like”) value, containing whatever is
-       returned by that function. If the tracked function depends on a
-       Reagent atom, the function is called again whenever that atom
-       changes – just like a Reagent component function. If the value
-       returned by " [:code "track"] " is used in a component, the
-       component is re-rendered when the value returned by the
-       function changes. "]
-
-       [:p "In other words, " [:code "@(r/track foo x)"] " gives the
-       same result as " [:code "(foo x)"] " – but in the first case,
-       foo is only called again when the atom(s) it depends on
-       changes."]
-
-       [:p "Here's an example: "]
-
-       [demo-component {:comp name-list
-                        :src [:pre ns-src
-                              (s/src-of [:app-state
-                                         :people
-                                         :person-keys
-                                         :person
-                                         :name-comp
-                                         :name-list])]}]
-
-       [:p "Here, the " [:code "name-list"] " component will only be
-       re-rendered if the keys of the " [:code ":people"] " map
-       changes. Every " [:code "name-comp"] " only renders again when
-       needed, etc."]
-
-       [:p "Use of " [:code "track"] " can improve performance in
-       three ways:" ]
-
-       [:ul
-        [:li "It can be used as a cache for an expensive function,
-        that is automatically updated if that function depends on Reagent
-        atoms (or other tracks, cursors, etc)."]
-
-        [:li "It can also be used to limit the number of times a
-        component is re-rendered. The user of " [:code "track"] " is
-        only updated when the function’s result changes. In other
-        words, you can use track as a kind of generalized, read-only
-        cursor."]
-
-        [:li "Every use of " [:code "track"] " with the same arguments
-        will only result in one execution of the function. E.g the two
-        uses of " [:code "@(r/track people)"] " in the example above
-        will only result in one call to the " [:code "people"] "
-        function (both initially, and when the state atom changes)."]]
-
-       [:h2 "track!"]
-
-       [:p [:code "track!"]" is another new function. It works just
-       like "[:code "track"]", except that the function passed is
-       invoked immediately, and continues to be invoked whenever any
-       atoms used within it changes."]
-
-       [:p "For example, given this function:"]
-
-       [demo-component {:src (s/src-of [:log-app-state])}]
-
-       [:p "you could use " [:code "(defonce logger (r/track!
-       log-app-state))"]" to monitor changes
-       to "[:code "app-state"]". "[:code "log-app-state"]" would
-       continue to run until you stop it, using "[:code "(r/dispose!
-       logger)"]"."]
-
-       [:h2 "Handling destruction"]
-
-       [:p "Reagent now has a new way of writing components that need
-       to do something when they are no longer around:
-       the "[:code "with-let"]" macro. It looks just
-       like " [:code "let"] " – but the bindings only execute once,
-       and it takes an optional " [:code "finally"] " clause, that
-       runs when the component is no longer rendered."]
-
-       [:p "For example: here's a component that sets up an event
-       listener for mouse moves, and stops listening when the
-       component is removed."]
-
-       [demo-component {:comp mouse-pos-comp
-                        :src (s/src-of [:mouse-pos-comp])}]
-
-       [:p "The same thing could of course be achieved with React
-       lifecycle methods, but that would be a lot more verbose."]
-
-       [:p [:code "with-let"] " can also be combined with " [:code "track"] ". For
-       example, the component above could also be written as: "]
-
-       [demo-component {:comp tracked-pos
-                        :src (s/src-of [:mouse-pos
-                                        :tracked-pos])}]
-
-       [:p "The " [:code "finally"] " clause will run
-       when " [:code "mouse-pos"] " is no longer tracked anywhere, i.e
-       in this case when " [:code "tracked-pos"] "is unmounted."]
-
-
-       [:section.demo-text
-        [:h2 "Event handling with rswap!"]
-
-        [:p [:code "rswap!"] " is another new function in 0.6.0. It
-        works like standard "[:code "swap!"]" except that it"]
-
-        [:ul
-         [:li "always returns nil"]
-         [:li "allows recursive applications of "[:code "rswap!"]" on the same
-         atom."]]
-
-        [:p "Here’s an example that uses event handling
-        with "[:code "rswap!"]" to edit the data introduced in the
-        section about "[:code "track"]" above:"]
-
-        [demo-component {:comp edit-fields
-                         :src (s/src-of [:event-handler
-                                         :dispatch
-                                         :name-edit
-                                         :edit-fields])}]
-
-        [:p "All events are passed through the "[:code "dispatch"]"
-        function, consisting of a trivial application
-        of "[:code "rswap!"]" and some optional logging. This is the
-        only place where application state actually changes – the rest
-        is pure functions."]
-
-        [:p "The actual event handling is done
-        in "[:code "event-handler"]", which takes state and event as
-        parameters, and returns a new state (events are represented by
-        vectors, with an event name in the first position)."]
-
-        [:p "All the UI components have to do is then just to return
-        some markup, and set up routing of events through the dispatch
-        function. "]
-
-        [:p "This architecture basically divides the application into
-        two logical functions: "]
-
-        [:ul
-         [:li "The first takes state and an event as input, and returns
-         the next state."]
-         [:li "The other takes state as input, and returns a UI
-         definition."]]
-
-        [:p "This simple application could probably just as well use
-        the common "[:code "swap!"]" instead of "[:code "rswap!"]",
-        but using "[:code "swap!"]" in React’s event handlers may
-        trigger warnings due to unexpected return values, and may
-        cause severe headaches if an event handler called by dispatch
-        itself dispatches a new event (that would result in lost
-        events, and much confusion)."]]
-
-       [:section.demo-text
-        [:h2 "New React version and new namespaces"]
-
-        [:p "Reagent now depends on React version 0.14.3. React itself
-        is now split into three parts, with separate packages for
-        browser specific code, and HTML generation respectively."]
-
-        [:p "To reflect that, two new namespaces have been introduced
-        in Reagent as well: "[:code "reagent.dom"]"
-        and "[:code "reagent.dom.server"]". They contain functions
-        that used to be in "[:code "reagent.core"]". "]
-
-        [:p [:code "reagent.dom"]" contains: "]
-
-        [:ul
-         [:li [:code "render"]]
-         [:li [:code "unmount-component-at-node"]]
-         [:li [:code "dom-node"]]
-         [:li [:code "force-update-all"]]]
-
-        [:p [:code "reagent.dom.server"]" contains: "]
-
-        [:ul
-         [:li [:code "render-to-string"]]
-         [:li [:code "render-to-static-markup"]]]
-
-        [:p "These functions are still available
-        in "[:code "reagent.core"]" in this release (for backward
-        compatibility reasons), but they may be deprecated in the
-        future."]
-
-        [:p "The changes in React also mean that if you specify the
-        React version to use in your project.clj,
-        with "[:code "cljsjs/react"]" in the "[:code ":dependencies"]"
-        section, you now have to specify "[:code "cljsjs/react-dom"]"
-        and "[:code "cljsjs/react-dom-server"]" instead."]]
-
-       [:section.demo-text
-        [:h2 "Better interop with native React"]
-
-        [:p "The output of "[:code "create-class"]" can now be used
-        directly in JSX."]
-
-        [:p "”Native React components” can now be used directly in
-        Reagent’s hiccup forms, using this syntax: "[:code "[:>
-        nativeComp {:key \"value\"}]"]". This might sometimes be more
-        convenient than using "[:code "adapt-react-class"]". "]
-
-        [:p "Reagent should now also be a bit easier to use in
-        node.js. If global React is not
-        defined (i.e "[:code "React"]", "[:code "ReactDOM"]"
-        and "[:code "ReactDOMServer"]"), Reagent tries to
-        use "[:code "require"]" instead, to get react, react-dom and
-        react-dom/server from npm."]]
-
-       [:section.demo-text
-        [:h2 "Better cursor"]
-
-        [:p "Cursors are now cached, which should make them a bit
-        easier to use. Previously, every instance
-        of "[:code "cursor"]" had its own state.
-        Now "[:code "cursor"]"s called with the same arguments share
-        data, which means that components like this now make sense: "]
-
-        [demo-component {:comp cursor-example
-                         :src (s/src-of [:cursor-example])}]
-
-        [:p "Previously cursors were really only useful (in the sense
-        that unnecessary re-renderings were avoided) when passed as
-        arguments to child components."]]
-
-       [:section.demo-text
-        [:h2 "Tapping into the rendering loop"]
-
-        [:p "The "[:code "next-tick"]" function now has a more
-        predictable timing. The function passed
-        to "[:code "next-tick"]" is now invoked immediately before the
-        next rendering (which is in turn triggered
-        using "[:code "requestAnimationFrame"]")."]
-
-        [:p [:code "after-update"]" works just
-        like "[:code "next-tick"]", except that the function given is
-        invoked immediately "[:b "after"]" the next rendering."]]
-
        [:section.demo-text
         [:h2 "Breaking changes"]

         [:ul
          [:li "Reagent now depends on "[:code "cljsjs/react-dom"]"
-         and "[:code "cljsjs/react-dom-server"]" (see above)."]
+         and "[:code "cljsjs/react-dom-server"]" (see below)."]

          [:li "The javascript interop macros "[:code ".'"]"
          and "[:code ".!"]", in the "[:code "reagent.interop"]"
@@ -390,7 +155,258 @@
          [:li "Reactions now only trigger updates of dependent
          components and other reactions if they produce a new result,
          compared with "[:code "="]".
-         Previously, "[:code "identical?"]" was used."]]]
+         Previously, "[:code "identical?"]" was used."]
+
+         [:li [:code "next-tick"]" is now guaranteed to execute its
+         argument before the next render (more on that below.)"]]]
+
+       [:h2 "track: Use any function as a reactive value"]
+
+       [:p [:code "reagent.core/track"] " takes a function, and
+       optional arguments for that function, and gives a
+       derefable (i.e ”atom-like”) value, containing whatever is
+       returned by that function. If the tracked function depends on a
+       Reagent atom, it is called again whenever that atom changes –
+       just like a Reagent component function. If the value returned
+       by " [:code "track"] " is used in a component, the component is
+       re-rendered when the value returned by the function changes. "]
+
+       [:p "In other words, " [:code "@(r/track foo x)"] " gives the
+       same result as " [:code "(foo x)"] " – but in the first case,
+       foo is only called again when the atom(s) it depends on
+       changes."]
+
+       [:p "Here's an example: "]
+
+       [demo-component {:comp name-list
+                        :src [:pre ns-src
+                              (s/src-of [:app-state
+                                         :people
+                                         :person-keys
+                                         :person
+                                         :name-comp
+                                         :name-list])]}]
+
+       [:p "Here, the " [:code "name-list"] " component will only be
+       re-rendered if the keys of the " [:code ":people"] " map
+       changes. Every " [:code "name-comp"] " only renders again when
+       needed, etc."]
+
+       [:p "Use of " [:code "track"] " can improve performance in
+       three ways:" ]
+
+       [:ul
+        [:li "It can be used as a cache for an expensive function,
+        that is automatically updated if that function depends on Reagent
+        atoms (or other tracks, cursors, etc)."]
+
+        [:li "It can also be used to limit the number of times a
+        component is re-rendered. The user of " [:code "track"] " is
+        only updated when the function’s result changes. In other
+        words, you can use track as a kind of generalized, read-only
+        cursor."]
+
+        [:li "Every use of " [:code "track"] " with the same arguments
+        will only result in one execution of the function. E.g the two
+        uses of " [:code "@(r/track people)"] " in the example above
+        will only result in one call to the " [:code "people"] "
+        function (both initially, and when the state atom changes)."]]
+
+       [:p [:b "Note: "] "The first argument to "[:code "track"]"
+       should be a named function, i.e not an anonymous one. Also,
+       beware of lazy data sequences: don’t use deref (i.e ”@”) with
+       the "[:code "for"]" macro, unless wrapped
+       in "[:code "doall"]" (just like in Reagent components). "]
+
+       [:h2 "track!"]
+
+       [:p [:code "track!"]" is another new function. It works just
+       like "[:code "track"]", except that the function passed is
+       invoked immediately, and continues to be invoked whenever any
+       atoms used within it changes."]
+
+       [:p "For example, given this function:"]
+
+       [demo-component {:src (s/src-of [:log-app-state])}]
+
+       [:p "you could use " [:code "(defonce logger (r/track!
+       log-app-state))"]" to monitor changes
+       to "[:code "app-state"]". "[:code "log-app-state"]" would
+       continue to run until you stop it, using "[:code "(r/dispose!
+       logger)"]"."]
+
+       [:h2 "with-let: Handling destruction"]
+
+       [:p "Reagent now has a new way of writing components that need
+       to do something when they are no longer around:
+       the "[:code "with-let"]" macro. It looks just
+       like " [:code "let"] " – but the bindings only execute once,
+       and it takes an optional " [:code "finally"] " clause, that
+       runs when the component is no longer rendered."]
+
+       [:p "For example: here's a component that sets up an event
+       listener for mouse moves, and stops listening when the
+       component is removed."]
+
+       [demo-component {:comp mouse-pos-comp
+                        :src (s/src-of [:mouse-pos-comp])}]
+
+       [:p "The same thing could of course be achieved with React
+       lifecycle methods, but that would be a lot more verbose."]
+
+       [:p [:code "with-let"] " can also be combined with " [:code "track"] ". For
+       example, the component above could also be written as: "]
+
+       [demo-component {:comp tracked-pos
+                        :src (s/src-of [:mouse-pos
+                                        :tracked-pos])}]
+
+       [:p "The " [:code "finally"] " clause will run
+       when " [:code "mouse-pos"] " is no longer tracked anywhere, i.e
+       in this case when " [:code "tracked-pos"] "is unmounted."]
+
+
+       [:section.demo-text
+        [:h2 "Event handling with rswap!"]
+
+        [:p [:code "rswap!"] " is another new function in 0.6.0. It
+        works like standard "[:code "swap!"]" except that it"]
+
+        [:ul
+         [:li "always returns nil"]
+         [:li "allows recursive applications of "[:code "rswap!"]" on the same
+         atom."]]
+
+        [:p "That makes "[:code "rswap!"]" especially suited for event
+        handling."]
+
+        [:p "Here’s an example that uses event handling
+        with "[:code "rswap!"]" to edit the data introduced in the
+        section about "[:code "track"]" above:"]
+
+        [demo-component {:comp edit-fields
+                         :src (s/src-of [:event-handler
+                                         :dispatch
+                                         :name-edit
+                                         :edit-fields])}]
+
+        [:p "All events are passed through the "[:code "dispatch"]"
+        function, consisting of a trivial application
+        of "[:code "rswap!"]" and some optional logging. This is the
+        only place where application state actually changes – the rest
+        is pure functions."]
+
+        [:p "The actual event handling is done
+        in "[:code "event-handler"]", which takes state and event as
+        parameters, and returns a new state (events are represented by
+        vectors, with an event name in the first position)."]
+
+        [:p "All the UI components have to do is then just to return
+        some markup, and set up routing of events through the dispatch
+        function. "]
+
+        [:p "This architecture basically divides the application into
+        two logical functions: "]
+
+        [:ul
+         [:li "The first takes state and an event as input, and returns
+         the next state."]
+         [:li "The other takes state as input, and returns a UI
+         definition."]]
+
+        [:p "This simple application could probably just as well use
+        the common "[:code "swap!"]" instead of "[:code "rswap!"]",
+        but using "[:code "swap!"]" in React’s event handlers may
+        trigger warnings due to unexpected return values, and may
+        cause severe headaches if an event handler called by dispatch
+        itself dispatches a new event (that would result in lost
+        events, and much confusion)."]]
+
+       [:section.demo-text
+        [:h2 "New React version and new namespaces"]
+
+        [:p "Reagent now depends on React version 0.14.3. React itself
+        is now split into three parts, with separate packages for
+        browser specific code, and HTML generation respectively."]
+
+        [:p "To reflect that, two new namespaces have been introduced
+        in Reagent as well: "[:code "reagent.dom"]"
+        and "[:code "reagent.dom.server"]". They contain functions
+        that used to be in "[:code "reagent.core"]". "]
+
+        [:p [:code "reagent.dom"]" contains: "]
+
+        [:ul
+         [:li [:code "render"]]
+         [:li [:code "unmount-component-at-node"]]
+         [:li [:code "dom-node"]]
+         [:li [:code "force-update-all"]]]
+
+        [:p [:code "reagent.dom.server"]" contains: "]
+
+        [:ul
+         [:li [:code "render-to-string"]]
+         [:li [:code "render-to-static-markup"]]]
+
+        [:p "These functions are still available
+        in "[:code "reagent.core"]" in this release (for backward
+        compatibility reasons), but they may be deprecated in the
+        future."]
+
+        [:p "The changes in React also mean that if you specify the
+        React version to use in your project.clj,
+        with "[:code "cljsjs/react"]" in the "[:code ":dependencies"]"
+        section, you now have to specify "[:code "cljsjs/react-dom"]"
+        and "[:code "cljsjs/react-dom-server"]" instead."]]
+
+       [:section.demo-text
+        [:h2 "Better interop with native React"]
+
+        [:p "The output of "[:code "create-class"]" can now be used
+        directly in JSX."]
+
+        [:p "”Native React components” can now be used directly in
+        Reagent’s hiccup forms, using this syntax: "[:code "[:>
+        nativeComp {:key \"value\"}]"]". This might sometimes be more
+        convenient than using "[:code "adapt-react-class"]". "]
+
+        [:p "Reagent should now also be a bit easier to use in
+        node.js. If global React is not
+        defined (i.e "[:code "React"]", "[:code "ReactDOM"]"
+        and "[:code "ReactDOMServer"]"), Reagent tries to
+        use "[:code "require"]" instead, to get react, react-dom and
+        react-dom/server from npm."]]
+
+       [:section.demo-text
+        [:h2 "Better cursor"]
+
+        [:p "Cursors are now cached, which should make them a bit
+        easier to use. Previously, every instance
+        of "[:code "cursor"]" had its own state.
+        Now "[:code "cursor"]"s called with the same arguments share
+        data, which means that components like this now make sense: "]
+
+        [demo-component {:comp cursor-example
+                         :src (s/src-of [:cursor-example])}]
+
+        [:p "Previously cursors were really only useful (in the sense
+        that unnecessary re-renderings were avoided) when passed as
+        arguments to child components."]]
+
+       [:section.demo-text
+        [:h2 "Tapping into the rendering loop"]
+
+        [:p "The "[:code "next-tick"]" function now has a more
+        predictable timing. The function passed
+        to "[:code "next-tick"]" is now invoked immediately before the
+        next rendering (which is in turn triggered
+        using "[:code "requestAnimationFrame"]")."]
+
+        [:p [:code "after-update"]" works just
+        like "[:code "next-tick"]", except that the function given is
+        invoked immediately "[:b "after"]" the next rendering."]]
+
+

        ])]])


improve error msg

improve error msg

--- src/java_time/defconversion.clj
+++ src/java_time/defconversion.clj
@@ -90,9 +90,9 @@
 (defmacro deffactory [nm docstring returnskw tp implicit-arities-kw implicit-arities & fn-bodies]
   (assert (= :returns returnskw))
   (assert (= :implicit-arities implicit-arities-kw))
-  (let [tp (resolve tp)
-        _ (assert (class? tp) (str tp " is not resolvable"))
-        tp (-> ^Class tp .getName symbol)
+  (let [^Class tpcls (resolve tp)
+        _ (assert (class? tpcls) (str tp " is not resolvable"))
+        tp (-> ^Class tpcls .getName symbol)
         fn-name (with-meta nm {:tag tp})
         explain-fn-name (symbol (str "path-to-" nm))
         predicate-name (symbol (str nm "?"))]


update for release

update for release

--- kafka-clj/project.clj
+++ kafka-clj/project.clj
@@ -1,4 +1,4 @@
-(defproject kafka-clj "3.6.6-SNAPSHOT"
+(defproject kafka-clj "3.6.7"
   :description "fast kafka library implemented in clojure"
   :url "https://github.com/gerritjvv/kafka-fast"
   :license {:name "Eclipse Public License"


Marker protocols for Keywords and Symbols

--- lib/shin/cljs/cljs/core.cljs
+++ lib/shin/cljs/cljs/core.cljs
@@ -1139,7 +1139,11 @@

 ;; Keyword

+(defprotocol IKeyword) ; Marker protocol for mimics
+
 (deftype Keyword [_name]
+  IKeyword
+
   IPrintable
   (-pr-str [_]
     (str ":" _name))
@@ -1151,7 +1155,7 @@
   IEquiv
   (-equiv [_ other]
     (cond
-      (instance? Keyword other)
+      (keyword? other)
       (= (name _) (name other))
       :else false))

@@ -1167,11 +1171,15 @@
   (Keyword. x))

 (defn keyword? [x]
-  (instance? Keyword x))
+  (satisfies? IKeyword x))

 ;; Symbol

+(defprotocol ISymbol) ; Marker protocol for mimics
+
 (deftype Symbol [_name]
+  ISymbol
+
   IPrintable
   (-pr-str [_]
     _name)
@@ -1199,7 +1207,7 @@
   (Symbol. x))

 (defn symbol? [x]
-  (instance? Symbol x))
+  (satisfies? ISymbol x))

 ;; LazySeq


util/to-target-file needs to account for macro files

--- src/main/clojure/cljs/util.cljc
+++ src/main/clojure/cljs/util.cljc
@@ -74,14 +74,21 @@
   ([parts sep]
     (apply str (interpose sep parts))))

+(declare ext)
+
 (defn ^File to-target-file
   ([target-dir ns-info]
     (to-target-file target-dir ns-info "js"))
-  ([target-dir ns-info ext]
-    (let [relative-path (string/split (munge-path (str (:ns ns-info))) #"\.")
-          parents (cond-> (butlast relative-path)
+  ([target-dir {:keys [ns source-file] :as ns-info} ext]
+    (let [src-ext (cljs.util/ext source-file)
+          ns      (if (or (= src-ext "clj")
+                          (and (= ns 'cljs.core) (= src-ext "cljc")))
+                    (symbol (str ns "$macros"))
+                    ns)
+          relpath (string/split (munge-path (str ns)) #"\.")
+          parents (cond-> (butlast relpath)
                     target-dir (conj target-dir))]
-      (cond->> (io/file (str (last relative-path) (str "." ext)))
+      (cond->> (io/file (str (last relpath) (str "." ext)))
         (seq parents)
         (io/file (to-path parents))))))

@@ -181,4 +188,4 @@
    (if (try (eval exp)
             (catch Throwable _ false))
      `(do ~then)
-     `(do ~else))))+     `(do ~else))))


Add tests for replication behavior.

Add tests for replication behavior.

--- test/blocks/store/replica_test.clj
+++ test/blocks/store/replica_test.clj
@@ -1,5 +1,6 @@
 (ns blocks.store.replica-test
   (:require
+    [blocks.core :as block]
     (blocks.store
       [memory :refer [memory-store]]
       [replica :refer [replica-store]]
@@ -7,9 +8,29 @@
     [clojure.test :refer :all]))

-; TODO: test that writes actually populate all backing stores.
-; TODO: test that removing blocks from one store still returns all blocks.
-; TODO: test that listing provides merged block list.
+(deftest replica-behavior
+  (let [replica-1 (memory-store)
+        replica-2 (memory-store)
+        store (replica-store [replica-1 replica-2])
+        a (block/read! "foo bar baz")
+        b (block/read! "abracadabra")
+        c (block/read! "123 xyz")]
+    (block/put! store a)
+    (block/put! store b)
+    (block/put! store c)
+    (is (= 3 (count (block/list replica-1))))
+    (is (every? (partial block/get replica-1)
+                (map :id [a b c]))
+        "all blocks are stored in replica-1")
+    (is (= 3 (count (block/list replica-2))))
+    (is (every? (partial block/get replica-2)
+                (map :id [a b c]))
+        "all blocks are stored in replica-2")
+    (is (= 3 (count (block/list store))))
+    (block/delete! replica-1 (:id a))
+    (block/delete! replica-2 (:id c))
+    (is (= 3 (count (block/list store)))
+        "replica lists all available blocks")))

 (deftest ^:integration test-replica-store


Fix up one bar sequencer

Fix up one bar sequencer

--- test/example/one_bar_sequencer.clj
+++ test/example/one_bar_sequencer.clj
@@ -1,5 +1,6 @@
 (ns example.one-bar-sequencer
-  (:use overtone.live))
+  (:use [overtone.live]
+        [overtone.inst drum]))

 (def metro (metronome 128))

@@ -13,14 +14,14 @@
           2.5 [c-hat]
           3   [kick snare]
           3.5 [c-hat]})
-
+
 ; For every tick of the metronome, we loop through all our beats
 ; and find the apropriate one my taking the metronome tick mod 4.
 ; Then we play all the instruments for that beat.

-(defn player
+(defn player
   [tick]
-  (dorun
+  (dorun
     (for [k (keys bar)]
       (let [beat (Math/floor k)
             offset (- k beat)]
@@ -28,4 +29,19 @@
                (let [instruments (bar k)]
                     (dorun
                       (for [instrument instruments]
-                         (at (metro (+ offset tick)) (instrument))))))))))
+                        (at (metro (+ offset tick)) (instrument))))))))))
+
+;; define a run fn which will call our player fn for each beat and will schedule
+;; itself to be called just before the next beat
+
+(defn run
+  [m]
+  (let [beat (m)]
+    (player beat)
+    (apply-at (m (inc beat))  #'run [m])))
+
+;; make beats!
+(run metro)
+
+;; stop
+(stop)


add imperfect exceptions to lexicon

add imperfect exceptions to lexicon

--- src/babel/italiano/morphology.cljc
+++ src/babel/italiano/morphology.cljc
@@ -1458,6 +1458,54 @@
                                {:italiano {:infl :past
                                            :italiano (get-in val [:italiano :passato] :nothing)}})}

+                            ;; 1.5 imperfect
+                            {:path [:italiano :imperfect :1sing]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :imperfect
+                                           :italiano (get-in val [:italiano :imperfect :1sing] :nothing)
+                                           :agr {:number :sing
+                                                 :person :1st}}})}
+                            {:path [:italiano :imperfect :2sing]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :imperfect
+                                           :italiano (get-in val [:italiano :imperfect :2sing] :nothing)
+                                           :agr {:number :sing
+                                                 :person :2nd}}})}
+
+                            {:path [:italiano :imperfect :3sing]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :imperfect
+                                           :italiano (get-in val [:italiano :imperfect :3sing] :nothing)
+                                           :agr {:number :sing
+                                                 :person :3rd}}})}
+
+                            {:path [:italiano :imperfect :1plur]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :imperfect
+                                           :italiano (get-in val [:italiano :imperfect :1plur] :nothing)
+                                           :agr {:number :plur
+                                                 :person :1st}}})}
+
+                            {:path [:italiano :imperfect :2plur]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :imperfect
+                                           :italiano (get-in val [:italiano :imperfect :2plur] :nothing)
+                                           :agr {:number :plur
+                                                 :person :2nd}}})}
+
+                            {:path [:italiano :imperfect :3plur]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :imperfect
+                                           :italiano (get-in val [:italiano :imperfect :3plur] :nothing)
+                                           :agr {:number :plur
+                                                 :person :3rd}}})}
+
                             ;; 2. present-tense exceptions
                             {:path [:italiano :present :1sing]
                              :merge-fn


namespace ergonomics

namespace ergonomics

--- src/babel/italiano/vocabcoach.cljc
+++ src/babel/italiano/vocabcoach.cljc
@@ -6,15 +6,16 @@
    #?(:cljs [babel.logjs :as log])
    [babel.engine :as engine]
    [babel.italiano.grammar :refer [medium]]
-   [babel.italiano.lexicon :refer [lexicon]]
+   [babel.italiano.lexicon :as main-lexicon]
    [babel.italiano.morphology :as morph :refer [fo]]
    [babel.italiano.workbook :refer [analyze parse]]
    [babel.lexiconfn :refer [filter-keys filter-vals]]
+   [babel.over :refer [over]]
    [babel.ug :refer [head-principle]]
    [dag_unify.core :refer [fail? get-in merge strip-refs unifyc unify]]))

-(def vc-lex
-  (-> lexicon
+(def lexicon
+  (-> main-lexicon/lexicon
       (filter-keys
        #(or
          (= % "a")
@@ -25,26 +26,25 @@
          (= % "mezzogiorno")
          (= % "sono")))))

-(def vc-model
+(def model
   (merge (into {}
                (map (fn [k]
                       [k (get medium k)])
                     (filter #(and (not (= % :lexicon))
                                   (not (= % :index)))
                             (keys medium))))
-         {:lexicon vc-lex}
-         {:index (create-index (:grammar medium)
-                               (flatten (vals vc-lex))
+         {:lexicon lexicon
+          :index (create-index (:grammar medium)
+                               (flatten (vals lexicon))
                                head-principle)}))
-
 (defn generate
   ([]
-   (let [result (engine/generate :top vc-model)]
+   (let [result (engine/generate :top model)]
      (if result
        (conj {:surface (fo result)}
              result))))
   ([spec]
-   (let [result (engine/generate spec vc-model)]
+   (let [result (engine/generate spec model)]
      (if result
        (conj {:surface (fo result)}
              result)))))


ghost-city: addressing case in which tribe is removed from game

--- src/civs/model/core.clj
+++ src/civs/model/core.clj
@@ -167,7 +167,9 @@
   (let [settlement (get-settlement game settlement-id)
         owner (.owner settlement)
         tribe (get-tribe game owner)]
-    (not (alive? tribe))))
+    (if (nil? tribe)
+      true
+      (not (alive? tribe)))))

 (defn update-tribe
   "Return the game, updated"


init mongo in worker proc

init mongo in worker proc

--- src/clj/inky/worker.clj
+++ src/clj/inky/worker.clj
@@ -1,12 +1,18 @@
 (ns inky.worker
   (:require [inky.compile :as comp]
-            [inky.env :as env]))
+            [inky.env :as env]
+            [somnium.congomongo :as mon]))

 (defn spawn-workers [num-workers]
   (doseq [id (repeatedly num-workers #(str (java.util.UUID/randomUUID)))]
     (println "Spawning worker" id)
     (future
-      (comp/run-worker! id))))
+      (try
+        (comp/run-worker! id)
+        (catch Exception e
+          (println e)
+          (.printStackTrace e))))))

 (defn -main []
+  (mon/set-connection! (mon/make-connection (env/str :mongo-url "mongodb://localhost:27017/inky")))
   (spawn-workers (env/int :num-workers 2)))


nesting

nesting


* src/cljs/cljs/core.cljs: hash now uses type-hinted arg for check-cache

--- src/cljs/cljs/core.cljs
+++ src/cljs/cljs/core.cljs
@@ -848,9 +848,8 @@

 (defn hash
   ([o] (hash o true))
-  ([o check-cache]
-     (if (and ^boolean (goog/isString o)
-              (not (false? check-cache)))
+  ([o ^boolean check-cache]
+     (if (and ^boolean (goog/isString o) check-cache)
        (check-string-hash-cache o)
        (-hash o))))


suppress docs for generated functions

suppress docs for generated functions

--- src/clj/com/rpl/specter/macros.clj
+++ src/clj/com/rpl/specter/macros.clj
@@ -32,7 +32,7 @@
           ~@t-body)))))

 (defn- helper-name [name method-name]
- (symbol (str name "-" method-name)))
+ (with-meta (symbol (str name "-" method-name)) {:no-doc true}))

 (defmacro defnav [name params & impls]
  ;; remove the "this" param for the helper


ddfs ready to test

ddfs ready to test

--- src/clj/morpheus/traversal/dfs.clj
+++ src/clj/morpheus/traversal/dfs.clj
@@ -2,21 +2,24 @@
   (:require [morpheus.messaging.core :as msg]
             [morpheus.models.edge.core :as edges]
             [neb.base :as nb]
-            [cluster-connector.sharding.DHT :as dht]))
+            [clojure.core.async :as a]
+            [neb.core :as neb]))

 ;; Distributed deepeth first search divised by S.A.M. Makki and George Havas

 ;; Message schama [vertex-id stack filter max-deepth]

-(defn send-stack [task-id action vertex-id stack {:keys [filter max-deepeth]}]
+(def pending-tasks (atom {}))
+
+(defn send-stack [task-id action vertex-id stack {:keys [filter max-deepth]}]
   (let [server-name (nb/locate-cell-by-id vertex-id)]
     (case action
-      :DFS-FORWARD (msg/send-msg server-name action [vertex-id stack filter max-deepeth] :task-id task-id)
+      :DFS-FORWARD (msg/send-msg server-name action [vertex-id stack filter max-deepth] :task-id task-id)
       :DFS-RETURN  (msg/send-msg server-name action stack :task-id task-id))))

 (defn proc-forward-msg [task-id data]
-  (let [[vertex-id stack filter max-deepth] data
-        neighbours (apply edges/neighbours vertex-id filter)
+  (let [[vertex-id stack filters max-deepth] data
+        neighbours (apply edges/neighbours vertex-id filters)
         current-vertex-stat (atom nil)
         proced-stack (map (fn [v]
                             (let [[svid] v]
@@ -26,20 +29,39 @@
                                 v)))
                           stack)
         deepth (@current-vertex-stat 2)
-        ]
-    (if (> deepth (or max-deepth Long/MAX_VALUE))
+        next-depth (inc deepth)
+        stack-verteics (set (map first stack))
+        neighbour-oppisites (->> (map (fn [{:keys [*start* *end*]}]
+                                        (let [opptsite-id (cond (and (= vertex-id *start*) (not= vertex-id *end*))   *end*
+                                                                (and (= vertex-id *end*)   (not= vertex-id *start*)) *start*)]
+                                          (when (and opptsite-id (not (stack-verteics opptsite-id)))
+                                            [opptsite-id 0 next-depth vertex-id])))
+                                      neighbours)
+                                 (filter identity))
+        final-stack (concat neighbour-oppisites proced-stack)
+        unvisited-id (first (first (filter (fn [[_ flag]] (= flag 0)) final-stack)))
+        all-visted? (nil? unvisited-id)]
+    (if (or all-visted? (> deepth (or max-deepth Long/MAX_VALUE)))
       (let [root-id (first (last stack))]
-        #_(send-stack :DFS-RETURN root-id (map first stack) deepth {}))
-      (if (or (empty? neighbours) )
-        #_(send-stack )
-        ()))))
+        (send-stack task-id :DFS-RETURN root-id stack {}))
+      (send-stack task-id :DFS-FORWARD unvisited-id final-stack {:filter filters :max-deepth max-deepth}))))

 (defn proc-return-msg [task-id data]
-  )
+  (let [feedback-chan (get @pending-tasks task-id)]
+    (a/>!! feedback-chan data)))

-(defn dfs [vertex-id & {:keys [filter max-deepeth] :as extra-params}]
-  ;;                                   [svid      flag depth parent]
-  (send-stack nil :DFS-FORWARD vertex-id `([vertex-id 0    0     nil]) extra-params))
+(defn dfs [vertex-id & {:keys [filter max-deepeth timeout] :as extra-params
+                        :or {timeout 60000}}]
+  (let [task-id (neb/rand-cell-id)
+        feedback-chan (a/chan 1)]
+    (swap! pending-tasks assoc task-id feedback-chan)
+    ;;                                           [svid      flag depth parent]
+    (send-stack task-id :DFS-FORWARD vertex-id `([vertex-id 0    0     nil])
+                (dissoc extra-params :timeout))
+    (let [feedback (a/alts!! [(a/timeout timeout) feedback-chan])]
+      (swap! pending-tasks dissoc task-id feedback-chan)
+      (a/close! feedback-chan)
+      feedback)))

 (msg/register-action :DFS-FORWARD proc-forward-msg)
 (msg/register-action :DFS-RETURN  proc-return-msg)


fix arity error that snuck in during a rebase

--- src/clj/runbld/hosting/aws_ec2.clj
+++ src/clj/runbld/hosting/aws_ec2.clj
@@ -42,7 +42,7 @@

 (s/defn this-host? :- s/Bool
   "Is this host in AWS EC2?"
-  []
+  [_]
   (boolean (ec2-meta "/ami-id")))

 (defrecord AwsEc2Hosting [facts]


partial pdgms now merged

partial pdgms now merged

--- src/clj/webapp/routes/listvlcl.clj
+++ src/clj/webapp/routes/listvlcl.clj
@@ -1,5 +1,5 @@
 (ns webapp.routes.listvlcl
- (:refer-clojure :exclude [filter concat group-by max min  replace])
+ (:refer-clojure :exclude [filter group-by max min  replace])
   (:require [compojure.core :refer :all]
             [webapp.views.layout :as layout]
             [webapp.models.sparql :as sparql]
@@ -75,25 +75,6 @@
 ))

 (defn req2vlist2
-  [vlist]
-  (let [vlist1 (replace vlist #"\n$" "")
-        reqq (split vlist1 #"\n")
-        ;;reqqa (first reqq)
-        reqqb (rest reqq)
-        ;; make joint key of pdigmID and pdgmType
-        reqqc (for [req reqqb] (replace req #"^(.*?)," "$1+"))
-        vvec (for [req reqqc] (split req #","))
-        vmap (for [vvc vvec] (apply hash-map vvc))
-        vmerge (apply merge-with str vmap)
-        reqq2 (into [] (for [vm vmerge] (join "," vm)))
-        ;; This works because earlier split mention only '\n'
-        reqq3 (for [r2 reqq2] (replace r2 #"[\r\+]" ","))
-        reqq4 (for [r2 reqq3] (replace r2 #",$" ""))]
-
-    (join "\n" reqq4)
-))
-
-(defn req2vlist3
   "For pro: Takes off header row, deletes interior brackets and quotes, deletes line-final ','"
   [vlist]
   (let [reqq (split vlist #"\n" 2)
@@ -103,6 +84,41 @@
         reqqc (split reqqb #"\r")
         reqqd (for [req reqqc] (replace req #"\B,|[\(\)\]\[\"]" ""))]
     (for [req reqqd] (replace req #",$" ""))))
+
+(defn req2vlist3
+  [vlist]
+  (let [vlist1 (replace vlist #"\n$" "")
+        reqq (split vlist1 #"\n")
+        ;;reqqa (first reqq)
+        reqqb (rest reqq)
+        ;; make joint key of pdgmID and pdgmType
+        reqqc (for [req reqqb] (replace req #"^(.*?)," "$1+"))
+        ;; split off the property
+        vvec (for [req reqqc] (split req #","))
+        ;; make a hash-map of ':pdgmID+pdgmType property'
+        vmap (for [vvc vvec] (apply hash-map vvc))
+        ;; merge maps with identical key
+        vmerge (apply merge-with str vmap)
+        reqq2 (into [] (for [vm vmerge] (join "," vm)))
+        ;; This works because earlier split mention only '\n'
+        reqq3 (for [r2 reqq2] (replace r2 #"[\r\+]" ","))
+        reqq4 (for [r2 reqq3] (replace r2 #",$" ""))]
+    (join "\n" reqq4)))
+
+(defn propmerge
+  "Takes list with 'pdgmType,prop1,prop2,...,propn' makes  map {{:pdgmType [prop1,...]}...{ and then does (merge-with into). Cf. req2vlist3."
+  [vlist]
+  (let [;; split into pdgmType (key) and  property-list
+        vvec (for [vl vlist] (split vl #"," 2))
+        ;; make a hash-map of 'pdgmType property-list'
+        vmap (for [vec vvec] (hash-map (first vec) (split (last vec) #",")))
+        ;; merge maps with identical key
+        vmerge1 (apply merge-with into  vmap)
+        ;; put it back into a list
+        ;;vmerge2 (for [vm vmerge1] (into [] vm))
+        ]
+    ;; make key ('pdgmType') and property-list back into a string
+    (join "\n" (for [vm vmerge1] (str (first vm) "," (join "," (set (last vm))))))))

 (defn compact-list
 "Takes string representing sorted bipartite list of dataID and pdgm value-cluster, with divider ',', and builds up list with single mention of dataID (key) paired with space-separated sting  of comma-separated value sub-strings."
@@ -197,9 +213,9 @@
                           (req2vlist1 req2-body)
                           (= pos "pro")
                           ;;(rest req2-body)
-                          (req2vlist3 req2-body)
+                          (req2vlist2 req2-body)
                           ;; listvlclplex.clj has req2vlist2, investigate
-                          :else (req2vlist2 req2-body))
+                          :else (req2vlist3 req2-body))
               req3-out (apply str req2-out)
               req4-out (if (re-find #"\w" req3-out)
                          (replace req3-out #"^\s*\n" "")
@@ -210,7 +226,9 @@
               req-vlcllst (sort (for [rq4 req4-vec] (replace rq4 #"^.*?," "")))
               ;; use req-vlcllist if want to see partial pdgms (usually one token)
               ;; otherwise req-vlcllist2 [or use 'remove'?]
-              req-vlcllist (join "\n"  req-vlcllst)
+              req-vlcllist (if (= pos "nfv")
+                             (propmerge req-vlcllst)
+                             (join "\n"  req-vlcllst))
               ;;req-vlcllist2 (clojure.string/replace req-vlcllist #"Partial.*?\n" "")
               ]
           (log/info "sparql result status: " (:status req2))
@@ -229,8 +247,8 @@
           ;;)))
             [:div
              [:p [:b "Language: "] language]
+             [:p [:b "File vlcl-lst:    "] [:pre req-vlcllst]]
              [:p [:b "File vlcl-list:    "] [:pre req-vlcllist]]
-             ;;[:p [:b "req-vlcllist:    "] [:pre req-vlcllist]]
              [:p [:b "File data-vlcl:     "] [:br] req-dataIDvlcl]
              [:p [:b "File vlcl-data:     "] [:br] req-vlcldataID]
              [:p [:b "POS: " ] pos]
@@ -238,15 +256,15 @@
              [:p [:b "Propstring: "] propstring]
              [:p [:b "Normstring: "] normstring]
              [:h4 "======= Debug Info: ======="]
-             [:h4  "Value Clusters: " ]
-             [:p "req4-out: " [:pre req4-out]]
-             [:p "req4-vec: " [:p req4-vec]]
              ;;[:hr]
              ;;[:p "propstring: " [:pre propstring]]
              [:h3#clickable "Query:"]
              [:pre query-sparql2-pr]
              [:hr]
-             [:p "Query Output: " [:pre (:body req2)]]
+             [:p "Query Output (:body req2): " [:pre (:body req2)]]
+             [:h4  "Value Clusters: " ]
+             [:p "req4-out: " [:pre req4-out]]
+             [:p "req4-vec: " [:p req4-vec]]
              [:p "==========================="]]))
         ;; ) [this is the parens for posvec]
         )


update schema

update schema

--- src/cljc/salava/badge/schemas.cljc
+++ src/cljc/salava/badge/schemas.cljc
@@ -66,6 +66,8 @@
    (s/optional-key :message_count)       {:new-messages (s/maybe s/Int)
                                           :all-messages (s/maybe s/Int)}
    (s/optional-key :tags)                (s/maybe [s/Str])
+   (s/optional-key :user_endorsements_count) (s/maybe s/Int)
+   (s/optional-key :endorsement_count) (s/maybe s/Int)
    })

 (s/defschema BadgesToExport (select-keys Badge [:id :name :description :image_file


fix: [bug] reset! g/app-page not working

--- src/cljs/expense_tracker/menu.cljs
+++ src/cljs/expense_tracker/menu.cljs
@@ -1,5 +1,8 @@
 (ns expense-tracker.menu
   (:require [expense-tracker.globals :as g]))
+
+;; reset-app
+(defn ra [e m] (reset! g/app-page m) nil)

 (defn c-menu []
   [:div.navbar.navbar-default
@@ -8,8 +11,8 @@
      [:a.navbar-brand {:href "#"} "Expense Tracker"]]
     [:div.collapse.navbar-collapse
      [:ul.nav.navbar-nav
-      [:li [:a {:href "#" :onClick #(reset! g/app-page {:page :home})} "Home"]]
-      [:li [:a {:href "#" :onClick #(reset! g/app-page {:page :trans-add})} "Add Transaction"]]
+      [:li [:a {:href "#" :onClick #(ra % {:page :home})} "Home"]]
+      [:li [:a {:href "#" :onClick #(ra % {:page :trans-add})} "Add Transaction"]]
       [:li.dropdown [:a.dropdown-toggle {:href "#"
                                          :data-toggle "dropdown"
                                          :role "button"
@@ -17,8 +20,8 @@
                                          :aria-expanded "false"}
                      "Accounts" [:span.caret]]
        [:ul.dropdown-menu
-        [:li [:a {:href "#" :onClick #(reset! g/app-page {:page :acc-view})} "View"]]
-        [:li [:a {:href "#" :onClick #(reset! g/app-page {:page :acc-add})} "Add New"]]]]
+        [:li [:a {:href "#" :onClick #(ra % {:page :acc-view})} "View"]]
+        [:li [:a {:href "#" :onClick #(ra % {:page :acc-add})} "Add New"]]]]
       [:li.dropdown [:a.dropdown-toggle {:href "#"
                                          :data-toggle "dropdown"
                                          :role "button"
@@ -26,6 +29,6 @@
                                          :aria-expanded "false"}
                      "Reports by" [:span.caret]]
        [:ul.dropdown-menu
-        [:li [:a {:href "#" :onClick #(reset! g/app-page {:page :rep-pie})} "Time Period"]]
+        [:li [:a {:href "#" :onClick #(ra % {:page :rep-pie})} "Time Period"]]
         #_[:li.divider {:role "separator"}]
-        [:li [:a {:href "#" :onClick #(reset! g/app-page {:page :rep-bar})} "Account"]]]]]]]])
+        [:li [:a {:href "#" :onClick #(ra % {:page :rep-bar})} "Account"]]]]]]]])


simplify same-owner

simplify same-owner

--- src/cljs/tictactoe/logic/turn.cljs
+++ src/cljs/tictactoe/logic/turn.cljs
@@ -25,10 +25,7 @@
   "Indicates whether all positions are owned by the same player"
   [board positions]
   (let [owners (set (map #(board/get-owner-at board %) positions))]
-    (or
-      (= owners #{:owner/circle})
-      (= owners #{:owner/cross})
-      )))
+    (contains? #{#{:owner/circle} #{:owner/cross}} owners)))

 (defn- has-winner?
   "There is a winner if some winning line is owned by the same player"


add links + tracking + copy change

add links + tracking + copy change

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -81,21 +81,38 @@
   (reify
     om/IRender
     (render [_]
-      (html
-        [:div.build-queue.active
-         [:div.queue-message
-          [:p
-           "Avoid queues by "
-           [:a {:href "/"} "adding containers"]
-           ", skipping redundant builds (through "
-           [:a {:href "/"} "project settings"]
-           " or "
-           [:a {:href "/"} "configuring your yml"]
-           ")"]
-          [:p "NOTE: Showing queued builds can cause page performance issues."]]
-         (button/link {:kind :secondary
-                       :href "#usage-queue"}
-                      "Show Queued Builds")]))))
+      (let [project (:project data)
+            org-name (project-model/org-name project)
+            repo-name (project-model/repo-name project)]
+        (html
+          (if project
+            [:div.build-queue.active
+             [:div.queue-message
+              [:p
+               "Avoid queues by "
+               [:a {:href (routes/v1-org-settings-path {:org org-name
+                                                        :vcs_type (project-model/vcs-type project)
+                                                        :_fragment "linux-pricing"})
+                    :on-click #((om/get-shared owner :track-event) {:event-type :add-more-containers-clicked
+                                                                    :properties {:is-upsell-text false
+                                                                                :button-text "adding containers"}})} "adding containers"]
+               ", skipping redundant builds (through "
+               [:a {:href (routes/v1-project-settings-path {:org org-name
+                                                            :repo repo-name})
+                    :on-click #((om/get-shared owner :track-event) {:event-type :project-settings-clicked
+                                                                    :properties {:org org-name
+                                                                                :repo repo-name}
+                                                                    :project (:vcs_url project)})}
+                "project settings"]
+               " or "
+               [:a {:href "https://circleci.com/docs/skip-a-build/"
+                    :target "_blank"} "configuring your yml"]
+               ")"]
+              [:p "NOTE: Showing queued builds can slow down the page."]]
+             (button/link {:kind :secondary
+                           :href "#usage-queue"}
+                          "Show Queued Builds")]
+            (spinner)))))))

 (defn build-queue [data owner]
   (reify
@@ -812,7 +829,7 @@

              :build-parameters (om/build build-parameters {:build-parameters build-params})

-             :queue-placeholder (om/build build-queue-placeholder {})
+             :queue-placeholder (om/build build-queue-placeholder {:project project})

              :usage-queue (om/build build-queue {:build build
                                                  :builds (:builds usage-queue-data)


Added alias for escape-html

Added alias for escape-html

--- src/hiccup.clj
+++ src/hiccup.clj
@@ -21,6 +21,8 @@
     (replace "<"  "<")
     (replace ">"  ">")
     (replace "\"" """)))
+
+(def h escape-html)   ;; alias for escape-html

 (defn- format-attr
   "Turn a name/value pair into an attribute stringp"


Remove debug code

Remove debug code

--- src/dfgm/services/game/service.clj
+++ src/dfgm/services/game/service.clj
@@ -68,7 +68,7 @@
                                (swap! game core/stop-game)
                                (cmd/notify-drones @game {:type :ended
                                                          :game-id game-id
-                                                         :winner (:winner #spy/p @game)
+                                                         :winner (:winner @game)
                                                          :result (into {} (map (juxt first (comp :score last))
                                                                                (:drones @game)))})))]
                   (swap! game assoc :timer timer))))


context.clj: removed internal-uri and internal-db

--- src/org/altlaw/util/context.clj
+++ src/org/altlaw/util/context.clj
@@ -18,20 +18,6 @@
   []
   (get-property "org.altlaw.env"))

-(defn internal-uri
-  "The base URI of the internal.altlaw.org server.  String, includes
-  the scheme and host name, but not the initial slash."
-  []
-  (get-property "org.altlaw.internal.uri"))
-
-(defn internal-db
-  "The DB description for clojure.contrib.sql/with-connection"
-  []
-  {:classname "org.apache.derby.jdbc.EmbeddedDriver"
-   :subprotocol "derby"
-   :subname (java.io.File. (str (altlaw-home) "/var/db/" (altlaw-env)))
-   :create true})
-
 (defn www-content-dir
   "Root directory for markdown content files for 'about' pages on
   www.altlaw.org" []


crawler.clj: handle responses with no entity at all

--- src/org/altlaw/util/crawler.clj
+++ src/org/altlaw/util/crawler.clj
@@ -72,11 +72,11 @@
   "Returns the response entity as a Base64-encoded string, or nil if
   no response entity."
   [response]
-  (when (.isAvailable (.. response getEntity))
-    (String. (Base64/encodeBase64Chunked
-              (IOUtils/toByteArray
-               (.. response getEntity getStream)))
-             "US-ASCII")))
+  (when-let [entity (.. response getEntity)]
+    (when (.isAvailable entity)
+     (String. (Base64/encodeBase64Chunked
+               (IOUtils/toByteArray (.getStream entity)))
+              "US-ASCII"))))

 (defn- headers-vec [message]
   (when (.. message getAttributes (get "org.restlet.http.headers"))


Changed results directory name to "results" (was "results-francis") in analysis code. And saving the whole results in one file.

--- tp1/analysis/src/analysis/core.clj
+++ tp1/analysis/src/analysis/core.clj
@@ -18,7 +18,7 @@

 ;; List all the result files.
 ;; (It will list _all_ file (recursivly) in the specified directory)
-(def all-result-files (doall (remove #(io/.isDirectory %) (file-seq (io/file "../results-francis")))))
+(def all-result-files (doall (remove #(io/.isDirectory %) (file-seq (io/file "../results")))))

 ;;;; Define some functions

@@ -58,6 +58,8 @@
 ;; Create a bar chart for a specified N, one bar per threshold.
 ;; Save the chart as chart1.svg
 (defn main []
+	(save results "results.csv")
+
   (let [n 500000
         chart (bar-chart :threshold :time
                          :data ($order :threshold :asc ($where {:n {:eq n}} results))


Corrected session access in do-post

Corrected session access in do-post

--- src/portal_clj/routes/admin.clj
+++ src/portal_clj/routes/admin.clj
@@ -14,7 +14,7 @@

 (defn do-post [req]
   (-> (layout/common (admin/post-post))
-      (with-session session)))
+      (with-session (get req :session))))

 (defroutes admin-routes
   (GET "/admin/home" {session :session} (home session))


rename model* endpoints to type*

rename model* endpoints to type*

--- src/semtag_web/client/main.cljs
+++ src/semtag_web/client/main.cljs
@@ -182,7 +182,7 @@

 (defn ^:export model-show []
   (let [model (util/match-from-current-uri #"[^\/]+$")]
-    (backend-request (path-to "/model")
+    (backend-request (path-to "/type")
       (fn [data]
         (create-sort-table ($ :#model_show_box)
               (generate-table "model_show_table" data
@@ -190,10 +190,10 @@
                               :caption (str "Total: " (count data))
                               :fields [:name :url :desc :tags]))
         (make-table-editable))
-      :data {:model model})))
+      :data {:name model})))

 (defn ^:export model-stats []
-  (backend-request (path-to "/models")
+  (backend-request (path-to "/types")
     #(create-sort-table ($ :#model_stats_box)
             (generate-table "model_stats_table" %
                             :row-partial view/model-stats-row


Something happens

Something happens

--- 6clojure/day3.clj
+++ 6clojure/day3.clj
@@ -2,22 +2,55 @@
   "TODO(rkj): write a description of the package!")

 (def queue-chairs (atom []))
-(def barber-char (atom []))
+(def barber-chair (atom []))
+(def barber (agent []))
+(def shop (agent []))
+(def counter (atom 0))
+(def customer-cut (atom 0))
+(def HAIRCUT-TIME 2500)
+(def SPAWN-TIME 1000)

-(defn add-customer [customer]
-  (if (< (count @queue-chairs) 3)
-    (swap! queue-chairs conj customer)
-    @queue-chairs))
+(def printer (agent []))

-(def spawner (agent 1000))
+(defn err-handler-fn [ag ex]
+  (println "error occured: " ex " and we still have value " @ag))
+(set-error-handler! printer err-handler-fn)
+
+(defn get-haircut [customer]
+  (send printer println customer " is getting haircut")
+  (swap! barber-chair conj customer)
+  (Thread/sleep HAIRCUT-TIME)
+  (send printer println customer " got haircut")
+  (reset! barber-chair [])
+  (swap! customer-cut inc))
+
+(defn wait-for-haircut [customer]
+  )
+
+(defn customer-action [customer]
+  (if (= 0 (count @barber-chair))
+    (get-haircut customer)
+    (wait-for-haircut customer)))
+
+(defn add-customer [state]
+  (let [customer (agent (str "Customer " (swap! counter inc)))]
+    (set-error-handler! customer err-handler-fn)
+    (send-off customer customer-action)
+    []))

 (defn spawn [time]
-  (println "Spawning")
+  (send printer println "Spawning")
   (Thread/sleep time)
-  (add-customer 1)
+  (send shop add-customer)
   time)

-(loop [nothing nil]
-  (send spawner spawn)
-  (println @queue-chairs)
-  (recur nil))
+(defn print-world [who]
+  (println "\n**********")
+  (println "Barber: " @barber-chair)
+  (println "Queue: " @queue-chairs)
+  (printf "Customer visited: %d, cut: %d\n" @counter @customer-cut)
+  (println "=============\n"))
+
+(while true
+  (spawn SPAWN-TIME)
+  (send printer print-world))


Add debug-form macro, which expands and pretty-prints an unevaluated form.

--- src/main/clojure/cascade/utils.clj
+++ src/main/clojure/cascade/utils.clj
@@ -12,7 +12,9 @@
 ; implied. See the License for the specific language governing permissions
 ; and limitations under the License.

-(ns cascade.utils)
+(ns cascade.utils
+	(:use
+		(clojure.contrib pprint macro-utils)))

 (defmacro lcond
 	"A reimplementation of Clojure's cond, with the addition of a special :let
@@ -29,4 +31,7 @@
 				 	`(let [~@expr] (lcond ~@rst))
 				 	`(if ~tst ~expr (lcond ~@rst))))))

-
+(defmacro debug-form
+	"Expands all macros in a form, recursively, and prints the result. Returns nil."
+	[form]
+	`(pprint (mexpand-all '~form)))


LocalCluster: got rid of unneccasary methods

--- storm-multicore/src/clj/backtype/storm/LocalCluster.clj
+++ storm-multicore/src/clj/backtype/storm/LocalCluster.clj
@@ -15,7 +15,8 @@
 ;; limitations under the License.

 (ns backtype.storm.LocalCluster
-  (:use [backtype.storm testing config])
+  (:use [backtype.storm util config])
+  (:require [backtype.storm.daemon.nimbus :as nimbus])
   (:import [java.util Map])
   (:gen-class
     :init init
@@ -23,65 +24,49 @@
     :constructors {[] [] [java.util.Map] []}
     :state state))

+
+(defnk mk-local-cluster
+  "Reads the daemon config, creates a nimbus thread."
+  [:daemon-conf {} :inimbus nil]
+  (let [daemon-conf (merge (read-storm-config)
+                      {TOPOLOGY-ENABLE-MESSAGE-TIMEOUTS false
+                       TOPOLOGY-TRIDENT-BATCH-EMIT-INTERVAL-MILLIS 50}
+                      daemon-conf)
+        nimbus (nimbus/service-handler
+                 daemon-conf
+                 (if inimbus inimbus (nimbus/standalone-nimbus)))
+        cluster-map {:nimbus nimbus
+                     :daemon-conf daemon-conf}]
+    (.addShutdownHook (Runtime/getRuntime) (Thread. (fn [] (.shutdown nimbus))))
+    cluster-map))
+
+
 (defn -init
   ([]
-   (let [ret (mk-local-storm-cluster
+   (let [ret (mk-local-cluster
                :daemon-conf
                {TOPOLOGY-ENABLE-MESSAGE-TIMEOUTS true})]
      [[] ret]))
   ([^Map stateMap]
    [[] stateMap]))

+
 (defn -submitTopology
   [this name conf topology]
-  (submit-local-topology
-    (:nimbus (. this state)) name conf topology))
+  (.submitTopology (:nimbus (. this state)) name conf topology))

-(defn -submitTopologyWithOpts
-  [this name conf topology submit-opts]
-  (submit-local-topology-with-opts
-    (:nimbus (. this state)) name conf topology submit-opts))

 (defn -shutdown
   [this]
-  (kill-local-storm-cluster (. this state)))
+  (.shutdown (:nimbus (. this state))))
+

 (defn -killTopology
   [this name]
   (.killTopology (:nimbus (. this state)) name))

-(defn -getTopologyConf
-  [this id]
-  (.getTopologyConf (:nimbus (. this state)) id))
-
-(defn -getTopology
-  [this id]
-  (.getTopology (:nimbus (. this state)) id))
-
-;(defn -getClusterInfo
-;  [this]
-;  (.getClusterInfo (:nimbus (. this state))))
-;
-;(defn -getTopologyInfo
-;  [this id]
-;  (.getTopologyInfo (:nimbus (. this state)) id))
-
-(defn -killTopologyWithOpts
-  [this name opts]
-  (.killTopologyWithOpts (:nimbus (. this state)) name opts))
-
-(defn -activate
-  [this name]
-  (.activate (:nimbus (. this state)) name))
-
-(defn -deactivate
-  [this name]
-  (.deactivate (:nimbus (. this state)) name))
-
-;(defn -rebalance
-;  [this name opts]
-;  (.rebalance (:nimbus (. this state)) name opts))

 (defn -getState
   [this]
   (.state this))
+


In macros-test, rename `x` -> `x-in-def`.

--- test/com/nomistech/clojure_the_language/macros_test.clj
+++ test/com/nomistech/clojure_the_language/macros_test.clj
@@ -1,17 +1,17 @@
 (ns com.nomistech.clojure-the-language.macros-test
   (:require [midje.sweet :refer :all]))

-(defmacro do-things-with-symbols [x]
-  `(list   x
-          'x
-         ~'x
-          ~x
-         '~x))
+(defmacro do-things-with-symbols [x-in-def]
+  `(list   x-in-def
+          'x-in-def
+         ~'x-in-def
+          ~x-in-def
+         '~x-in-def))

 (fact
   (macroexpand-1 '(do-things-with-symbols x-in-call))
-  => '(clojure.core/list com.nomistech.clojure-the-language.macros-test/x
-                         'com.nomistech.clojure-the-language.macros-test/x
-                         x
+  => '(clojure.core/list com.nomistech.clojure-the-language.macros-test/x-in-def
+                         'com.nomistech.clojure-the-language.macros-test/x-in-def
+                         x-in-def
                          x-in-call
                          'x-in-call))


Remove some dead code

Remove some dead code

--- src/mdr2/production_monitoring.clj
+++ src/mdr2/production_monitoring.clj
@@ -13,9 +13,8 @@

 (defn audio-length [production]
   ;; as it happens the function that calculates the audio-length for a
-  ;; DTB is so flexible that it can be reused as-is for obi projects
+  ;; DTB is so generic that it can be reused as-is for obi projects
   (let [path (path/recording-path production)]
-        ;; length (if (nio/exists? path) (dtb/audio-length path) 0)]
     (assoc production :audio-length (dtb/audio-length path))))

 (defn last-modified [production]


Fix clean-input function for board resource.

--- src/oc/storage/resources/board.clj
+++ src/oc/storage/resources/board.clj
@@ -35,13 +35,13 @@
   reserved-properties)

 (defn- clean-input [board-data]
-  (->> board-data b
-       (if (:name b)
-         (update b :name #(lib-html/strip-xss-tags (or % "")))
-         b)
-       (if (:description b)
-         (update b :description #(lib-html/strip-xss-tags (or % "")))
-         b)))
+  (as-> board-data b
+    (if (:name b)
+      (update b :name #(lib-html/strip-xss-tags (or % "")))
+      b)
+    (if (:description b)
+      (update b :description #(lib-html/strip-xss-tags (or % "")))
+      b)))

 ;; ----- Data Defaults -----


more debug logging

more debug logging

--- src/clj/backtype/storm/daemon/supervisor.clj
+++ src/clj/backtype/storm/daemon/supervisor.clj
@@ -259,16 +259,17 @@
           storm-code-map (read-storm-code-locations storm-cluster-state sync-callback)
           assigned-storm-ids (set (keys storm-code-map))
           downloaded-storm-ids (set (read-downloaded-storm-ids conf))
-          new-assignment (->>
-                          (read-assignments
+          all-assignment (read-assignments
                            storm-cluster-state
                            (:supervisor-id supervisor)
                            sync-callback)
-                          (filter-key #(.confirmAssigned isupervisor %)))
+          new-assignment (->> all-assignment
+                              (filter-key #(.confirmAssigned isupervisor %)))
           existing-assignment (.get local-state LS-LOCAL-ASSIGNMENTS)]
       (log-debug "Synchronizing supervisor")
       (log-debug "Storm code map: " storm-code-map)
       (log-debug "Downloaded storm ids: " downloaded-storm-ids)
+      (log-debug "All assignment: " all-assignment)
       (log-debug "New assignment: " new-assignment)
       ;; download code first
       ;; This might take awhile


make query date range extraction reusable

--- src/clj_money/models/storage/sql_storage.clj
+++ src/clj_money/models/storage/sql_storage.clj
@@ -294,19 +294,20 @@
       (h/join [:transactions :t] [:= :t.id :i.transaction_id])
       (h/left-join [:reconciliations :r] [:= :r.id :i.reconciliation_id])))

-(defn- extract-trade-dates
-  "Extracts a start and end trade date from the
+(defn- extract-date-range
+  "Extracts a start and end dates
   specified search criteria. The valid shapes are

     {:trade-date (t/local-date 2017 3 2)} - searches for the specified date
     {:trade-date [:between (t/local-date 2017 1 1) (t/local-date 2017 131)]} - searches the specified range, inclusively
     {:trade-date [:between nil (t/local-date 2017 3 2)]} - searches from the first available date to the specified date"
-  [{trade-date :trade-date} earliest-fn]
-  (if (sequential? trade-date)
-    (-> trade-date
-        (update-in [1] #(or % (to-sql-date (earliest-fn))))
-        rest)
-    [trade-date trade-date]))
+  [criteria key-fn earliest-fn]
+  (let [date (key-fn criteria)]
+    (if (sequential? date)
+      (-> date
+          (update-in [1] #(or % (earliest-fn)))
+          rest)
+      [date date])))

 (defn- descending-sort?
   "Returns a boolean value indicating whether or not
@@ -540,7 +541,7 @@
   (select-prices
     [this {trade-date :trade-date :as criteria} options]
     (validate-criteria criteria ::price-criteria)
-    (let [[start end] (extract-trade-dates criteria (fn []
+    (let [[start end] (extract-date-range :trade-date criteria (fn []
                                                       (or (when-let [v (.get-setting this "earliest-partition-date")]
                                                             (read-string v))
                                                           (t/local-date 2000 1 1))))


Abstract cljs-nusmods.module-array-repr/get-module-lecture-timings

We create a function maker in
`module-lesson-timings-for-exhibit-filter-fn-maker`, which takes in a
single String parameter for the lesson type. The returned function does
the same thing as `get-module-lecture-timings`, with the difference of
that the lesson type String is supplied instead of hardcoded as
'Lecture'.

This is to prepare for the upcoming patch where we will implement a
`get-module-tutorial-timings` function for retrieving a Module object's
tutorial timings.

Signed-off-by: Pang Yan Han <22594c345857f664c61cd411f607c4d40a9d4af9@gmail.com>

--- src/cljs/cljs_nusmods/module_array_repr.cljs
+++ src/cljs/cljs_nusmods/module_array_repr.cljs
@@ -40,16 +40,24 @@
   [moduleArrayRepr]
   (nth moduleArrayRepr 4))

-(defn get-module-lecture-timings
-  "Retrieves a JavaScript array of strings of the lecture timings of a module
-   from its array representation"
-  [lessonTypesHash lessonTypesStringsArray moduleArrayRepr]
-  (let [timetable (get-module-timetable moduleArrayRepr)]
-    (clj->js
-      (map lesson-array-repr/get-lesson-start-time-string-for-exhibit-filter
-           (filter
-             (fn [lessonArrayRepr]
-               (= "Lecture"
-                  (lesson-array-repr/get-lesson-type-string
-                    lessonTypesHash lessonTypesStringsArray lessonArrayRepr)))
-             timetable)))))
+(defn- module-lesson-timings-for-exhibit-filter-fn-maker
+  "Given a lesson type (the string 'Lecture' or 'Tutorial'), returns a function
+   which when given the array representation of a Module, returns a JavaScript
+   array of strings of lesson timings for that type of lesson"
+  [lessonType]
+  (fn [lessonTypesHash lessonTypesStringsArray moduleArrayRepr]
+    (let [timetable (get-module-timetable moduleArrayRepr)]
+      (clj->js
+        (map lesson-array-repr/get-lesson-start-time-string-for-exhibit-filter
+             (filter
+               (fn [lessonArrayRepr]
+                 (= lessonType
+                    (lesson-array-repr/get-lesson-type-string
+                      lessonTypesHash lessonTypesStringsArray lessonArrayRepr)))
+               timetable))))))
+
+(def
+  ^{:doc "Returns a JavaScript array of strings of Lecture timings of a module
+          from its array representation"}
+  get-module-lecture-timings
+  (module-lesson-timings-for-exhibit-filter-fn-maker "Lecture"))


cleanup dashboard screenshot animation styles

--- frontend/components/landing_b.cljs
+++ frontend/components/landing_b.cljs
@@ -121,16 +121,7 @@
                   [:p
                    [:a.shopify-link
                     "See how Shopify does it"
-                    (common/ico :slim-arrow-right)]]
-                  [:div.quote-card
-                   [:div.avatar]
-                   [:p "\"CircleCI has significantly improved our testing infrastructure. We add new projects rapidly and continuous integration happens from the get-go.\""]
-                   [:footer
-                    [:cite
-                     "John Collison"
-                     [:br]
-                     "Founder at Stripe"]
-                    [:div.brand]]]]]]
+                    (common/ico :slim-arrow-right)]]]]]
                [:section.home-practice
                 [:div.practice-tools
                  [:article


(PDB-700) Apply max-frame-size to consumer

The command consumer worker threads don't currently apply the
max-frame-size parameter, so the AMQ default of 100MB is used.

--- src/com/puppetlabs/puppetdb/cli/services.clj
+++ src/com/puppetlabs/puppetdb/cli/services.clj
@@ -246,8 +246,8 @@

 (defn add-max-framesize
   "Add a maxFrameSize to broker url for activemq."
-  [config url]
-  (format "%s&wireFormat.maxFrameSize=%s&marshal=true" url (:max-frame-size config)))
+  [max-frame-size url]
+  (format "%s&wireFormat.maxFrameSize=%s&marshal=true" url max-frame-size))

 (defn start-puppetdb
   [context config service-id add-ring-handler shutdown-on-error]
@@ -272,9 +272,10 @@
         dlo-compression-threshold                  (get command-processing :dlo-compression-threshold)
         mq-dir                                     (str (file (:vardir global) "mq"))
         discard-dir                                (file mq-dir "discarded")
+        command-mq-connection-string               (add-max-framesize (:max-frame-size command-processing) mq-addr)
         globals                                    {:scf-read-db          read-db
                                                     :scf-write-db         write-db
-                                                    :command-mq           {:connection-string (add-max-framesize command-processing mq-addr)
+                                                    :command-mq           {:connection-string command-mq-connection-string
                                                                            :endpoint          mq-endpoint}
                                                     :update-server        update-server
                                                     :product-name         product-name
@@ -315,7 +316,7 @@
                                  (future (shutdown-on-error
                                            service-id
                                            #(load-from-mq
-                                             mq-addr
+                                             command-mq-connection-string
                                              mq-endpoint
                                              discard-dir
                                              {:db                     write-db


Make parse-hexapod-description

Make parse-hexapod-description

--- src/fp_contest_data_transformations/core.clj
+++ src/fp_contest_data_transformations/core.clj
@@ -8,7 +8,6 @@
   (let [lines  (split-lines desc)
         hexapod-name (first lines)
         hexapod-info (remove blank? (rest lines))]
-    [hexapod-name hexapod-info]
     {hexapod-name
      (into {}
            (for [stats hexapod-info


:by-id sort order

:by-id sort order

--- Clojure-Websockets/MainApp/src/cljs/birdwatch/state.cljs
+++ Clojure-Websockets/MainApp/src/cljs/birdwatch/state.cljs
@@ -21,7 +21,7 @@
    :search "*"
    :users-count 0
    :total-tweet-count 0
-   :sorted :by-rt-since-startup
+   :sorted :by-id
    :by-followers (priority-map-by >)
    :by-retweets (priority-map-by >)
    :by-favorites (priority-map-by >)
@@ -42,3 +42,4 @@

 (defn append-search-text [s]
   (swap! app assoc :search-text (str (:search-text @app) " " s)))
+


[PDOK-1592 fix: closed with attributes

[PDOK-1592 fix: closed with attributes

--- src/main/clojure/pdok/featured/processor.clj
+++ src/main/clojure/pdok/featured/processor.clj
@@ -131,20 +131,23 @@
   (process-new-feature processor (assoc feature :action :change)))

 (defn- process-close-feature [{:keys [persistence projectors] :as processor} feature]
-  (let [change-before-close (when-not (empty? (:attributes feature))
-                               (process-change-feature processor
-                                                       (-> feature
-                                                           (transient)
-                                                           (assoc! :action :change)
-                                                           (dissoc! :src)
-                                                           (assoc! :version (random/ordered-UUID))
-                                                           (persistent!))))
-        enriched-feature (->> feature (with-current-version persistence))]
-    (append-feature persistence enriched-feature)
-    (doseq [p projectors] (proj/close-feature p enriched-feature))
-    (if change-before-close
-      (list change-before-close enriched-feature)
-      (list enriched-feature))))
+  (if (empty? (:attributes feature))
+    (let [enriched-feature (->> feature (with-current-version persistence))]
+      (append-feature persistence enriched-feature)
+      (doseq [p projectors] (proj/close-feature p enriched-feature))
+      (list enriched-feature))
+    (let [change-feature (with-current-version persistence
+                                               (-> feature
+                                               (transient)
+                                               (assoc! :action :change)
+                                               (dissoc! :src)
+                                               (assoc! :version (:version feature))
+                                               (persistent!)))
+          _ (process-change-feature processor change-feature)
+          close-feature (with-current-version persistence (assoc feature :version (random/ordered-UUID)))]
+      (append-feature persistence close-feature)
+      (doseq [p projectors] (proj/close-feature p close-feature))
+      (list change-feature close-feature))))

 (defn- process-nested-close-feature [processor feature]
   (let [nw (process-new-feature processor (assoc feature :action :new))


CMR-3639: Change index recently replicated job to retrieve provider list from source database and ignore all providers which only exist in the target database for testing.

--- bootstrap-app/src/cmr/bootstrap/services/replication.clj
+++ bootstrap-app/src/cmr/bootstrap/services/replication.clj
@@ -38,34 +38,10 @@
    [cmr.common.jobs :refer [def-stateful-job]]
    [cmr.common.log :refer [debug info warn error]]
    [cmr.metadata-db.data.oracle.concept-tables :as concept-tables]
-   [cmr.metadata-db.data.providers :as providers]
+   [cmr.metadata-db.data.oracle.providers :as providers]
    [cmr.metadata-db.services.concept-service :as s]
    [cmr.oracle.connection :as oracle]
    [cmr.oracle.sql-utils :as su :refer [select from]]))
-
-;; ----------------------------
-;; Helper for querying the METADATA_DB tables
-;; Code taken from mdb-migrate-helper
-
-(defn get-concept-tablenames
-  "Returns a sequence of table names for the given concept types, or all concept types
-  if none are specified, for all the existing providers."
-  ([db]
-   ;; use all concept types
-   (apply get-concept-tablenames db (keys s/num-revisions-to-keep-per-concept-type)))
-  ([db & concept-types]
-   (distinct
-    (->
-     (for [provider (providers/get-providers db)
-           concept-type concept-types]
-       (concept-tables/get-table-name provider concept-type))
-      ;; Ensure that we return the small provider tables even if there are no providers in our
-      ;; system yet.
-     (into (when (contains? (set concept-types) :collection) ["small_prov_collections"]))
-     (into (when (contains? (set concept-types) :granule) ["small_prov_granules"]))
-     (into (when (contains? (set concept-types) :service) ["small_prov_services"]))
-     (into (when (contains? (set concept-types) :access-group) ["cmr_groups"]))
-     (into (when (contains? (set concept-types) :tag) ["cmr_tags"]))))))

 (def replication-status-table
   "The name of the database table where replication status is stored."
@@ -89,6 +65,32 @@
 (defconfig tables-with-null-blobs
   "Configuration with additional tables that contain NULL BLOBs."
   {:default #{} :type :edn})
+
+;; ----------------------------
+;; Helper for querying the METADATA_DB tables
+;; Code taken from mdb-migrate-helper
+
+(defn get-concept-tablenames
+  "Returns a sequence of table names for the given concept types, or all concept types
+  if none are specified, for all the existing providers."
+  ([db]
+   ;; use all concept types
+   (apply get-concept-tablenames db (keys s/num-revisions-to-keep-per-concept-type)))
+  ([db & concept-types]
+   (distinct
+    (->
+     (for [provider (map providers/dbresult->provider
+                         (j/query db [(format "SELECT * FROM providers@%s" (source-database-link))]))
+           concept-type concept-types]
+       (concept-tables/get-table-name provider concept-type))
+      ;; Ensure that we return the small provider tables even if there are no providers in our
+      ;; system yet.
+     (into (when (contains? (set concept-types) :collection) ["small_prov_collections"]))
+     (into (when (contains? (set concept-types) :granule) ["small_prov_granules"]))
+     (into (when (contains? (set concept-types) :service) ["small_prov_services"]))
+     (into (when (contains? (set concept-types) :access-group) ["cmr_groups"]))
+     (into (when (contains? (set concept-types) :tag) ["cmr_tags"]))))))
+

 (defn fix-null-replicated-concepts-query-str
   "Query to fix the NULL replicated concepts. Takes the table name and revision date-time string."


Modified handling of decode statistics.

Modified handling of decode statistics.

--- src/mavlink/core.clj
+++ src/mavlink/core.clj
@@ -347,19 +347,19 @@

 (defn update-decode-statistics
   [system-id sequence-id statistics]
-  ; messages-decoded and messages-skipped per system id stored as array
-  ; FIXME need to go fix all updates to messages-decoded
   (let [{:keys [last-seq-ids messages-decoded messages-skipped]} @statistics
-        last-seq-id (aget ^ints last-seq-ids system-id)
-        difference (- sequence-id (mod (inc last-seq-id) 256))
-        skipped (if (neg? last-seq-id)
+        last-sys-seq-id (aget ^longs last-seq-ids system-id)
+        last-sys-decoded (aget ^longs messages-decoded system-id)
+        last-sys-skipped (aget ^longs messages-skipped system-id)
+        difference (- sequence-id (mod (inc last-sys-seq-id) 256))
+        skipped (if (neg? last-sys-seq-id)
                   0
                   (if (neg? difference)
                     (+ difference 255)
                     difference))]
-    (aset ^ints last-seq-ids system-id (int sequence-id))
-    (swap! statistics assoc :messages-decoded (inc messages-decoded)
-                            :messages-skipped (+ skipped messages-skipped))))
+    (aset ^longs last-seq-ids system-id sequence-id)
+    (aset ^longs messages-decoded system-id (inc last-sys-decoded))
+    (aset ^longs messages-skipped system-id (+ last-sys-skipped skipped))))

 (defn- decode-mavlink1
   "Decode a MAVLink 1.0 message in the channel's buffer Return a message
@@ -1081,9 +1081,9 @@
   (let [buffer (ByteBuffer/allocate BUFFER-SIZE)
         statistics (atom {:bytes-read 0
                           :bytes-decoded 0
-                          :messages-decoded 0
-                          :last-seq-ids (int-array 256 -1)
-                          :messages-skipped 0
+                          :messages-decoded (long-array 256 0)
+                          :last-seq-ids (long-array 256 -1)
+                          :messages-skipped (long-array 256 0)
                           :messages-encoded 0
                           :encode-failed 0
                           :bad-checksums 0


Comment the routes

Comment the routes

--- src/mdr2/handler.clj
+++ src/mdr2/handler.clj
@@ -31,6 +31,7 @@
         (friend/authenticated (views/production-add-xml r id file)))
   (POST "/production/:id/state" [id state :as r]
         (friend/authenticated (views/production-set-state r id state)))
+  ;; catalog
   (GET "/catalog" request
        (friend/authenticated (views/catalog request)))
   (POST "/catalog/:id" [id library_signature :as r]


draft docstrings for macros

draft docstrings for macros

--- src/mireact/core.clj
+++ src/mireact/core.clj
@@ -46,6 +46,57 @@
             ~@fn-body)))]))

 (defmacro genspec
+  "Generate a spec suitable for React.createClass.
+
+  (genspec prop-binding options* specs*)
+
+  prop-binding - A binding form which is available in all direct
+  function definitions
+
+  the following options are available:
+
+  :state - A binding form for the component local state, available in
+  all direct function defintions
+
+  :this-as - A symbol bound to the React component in all direct
+  function definitions
+
+  A spec consists of either of a symbol value pair:
+
+  Defines a field in the generated spec named symbol and definition.
+
+  See https://facebook.github.io/react/docs/component-specs.html for
+  available properties.
+
+  The following properties are augmented:
+
+  mixins - If a vector is passed, the mireact default mixin is
+  prepended and it is cast to a js-array.  The default mixin can be
+  disabled by associating :no-default on the vectors metadata map.
+  NOTE: If no mixins are passed, the mireact default mixin is used as
+  well.
+
+  Alternatively, a single literal function definition can be passed as
+  follows
+
+  (fn modifiers* name arg positional-params body)
+
+  These function definitions are transformed so that state and props
+  bindings are available.
+
+  The following fn names are augmented:
+
+  componentWillReceiveProps
+  shouldComponentUpdate
+  componentWillUpdate
+  componentDidUpdate
+
+  For these, the props and state arguments passed by react are rebound
+  to their mireact properties.  You can disable this behavior by
+  specifying the symbol \"raw\" as a modifier.
+
+  Note that this behavior can be avoided completely by specifiyng the
+  function as a symbol definition pair."
   [prop-binding & spec]
   (let [[opts spec] (extract-opts spec)
         spec (cond-> spec
@@ -77,6 +128,13 @@
             result)))))

 (defmacro defreact
+  "Define a variadic factory function according to spec. varargs
+  become the components props.
+
+  The component is available under the same name as the component.
+  This can be overriden via the :this-as option in spec.
+
+  See also: genspec."
   [name prop-binding & spec]
   (assert (vector? prop-binding))
   `(def ~name


fix tformat

fix tformat

--- src/neuseg/train.clj
+++ src/neuseg/train.clj
@@ -2,8 +2,7 @@
   (:use [clj-tuple]
         [clojure.core.matrix :only [dot zero-vector]]
         [neuseg.db]
-        [com.guokr.nlp.seg]
-        [clojure.string :only [join]])
+        [com.guokr.nlp.seg])
   (:import (com.guokr.neuseg.util NGram
                                   NeighborSlider)))

@@ -13,11 +12,10 @@
     (map (partial dot mid-vec) (concat (take mid vecs) (drop (inc mid) vecs)))))

 (defn- zip [& colls]
-  (partition (count colls) (apply interleave colls)))
+  (map flatten (partition (count colls) (apply interleave colls))))

 (defn- tformat [coll]
-  (let [row (flatten coll)]
-    (str (join " " (take 32 row)) "\n" (join " " (nthrest row 32)) "\n")))
+  (clojure.string/join "\n" (map (partial clojure.string/join " ") (split-at 32 coll))))

 (defn tagging [text]
   (let [seged (seg text)]
@@ -30,8 +28,9 @@
           (recur (rest raw) (nthrest sgd 2) (conj ret 1 1)))))))

 (defn gen-case [text]
-  (map tformat (zip (map ndot (NeighborSlider. 4 (get-vector " ") (map get-vector (iterator-seq (NGram/unigram text)))))
-                    (map ndot (NeighborSlider. 4 (get-vector "  ") (map get-vector (iterator-seq (NGram/bigram text)))))
-                    (map ndot (NeighborSlider. 4 (get-vector "   ") (map get-vector (iterator-seq (NGram/trigram text)))))
-                    (map ndot (NeighborSlider. 4 (get-vector "    ") (map get-vector (iterator-seq (NGram/quadgram text)))))
-                    (partition 2 (tagging text)))))
+  (clojure.string/join "\n"
+    (map tformat (zip (map ndot (NeighborSlider. 4 (get-vector " ") (map get-vector (iterator-seq (NGram/unigram text)))))
+                      (map ndot (NeighborSlider. 4 (get-vector "  ") (map get-vector (iterator-seq (NGram/bigram text)))))
+                      (map ndot (NeighborSlider. 4 (get-vector "   ") (map get-vector (iterator-seq (NGram/trigram text)))))
+                      (map ndot (NeighborSlider. 4 (get-vector "    ") (map get-vector (iterator-seq (NGram/quadgram text))))))
+                      (partition 2 (tagging text)))))


Une solution à l'exercice "Complex Numbers" de Exercism dans la track Clojure

--- exercism/clojure/complex-numbers/src/complex_numbers.clj
+++ exercism/clojure/complex-numbers/src/complex_numbers.clj
@@ -1,33 +1,23 @@
 (ns complex-numbers)

-(defn real [[a b]] ;; <- arglist goes here
-  ;; your code goes here
-)
+(defn real [[a _]] a)

-(defn imaginary [[a b]] ;; <- arglist goes here
-  ;; your code goes here
-)
+(defn imaginary [[_ b]] b)

-(defn abs [[a b]] ;; <- arglist goes here
-  ;; your code goes here
-)
+(defn abs [[a b]]
+  (Math/sqrt (+ (* a a) (* b b))))

-(defn conjugate [[a b]] ;; <- arglist goes here
-  ;; your code goes here
-)
+(defn conjugate [[a b]]
+  [a (- b)])

-(defn add [[a b] [c d]] ;; <- arglist goes here
-  ;; your code goes here
-)
+(defn add [[a b] [c d]]
+  [(+ a c) (+ b d)])

-(defn sub [[a b] [c d]] ;; <- arglist goes here
-  ;; your code goes here
-)
+(defn sub [[a b] [c d]]
+  [(- a c) (- b d)])

-(defn mul [[a b] [c d]] ;; <- arglist goes here
-  ;; your code goes here
-)
+(defn mul [[a b] [c d]]
+  [(- (* a c) (* b d)) (+ (* b c) (* a d))])

-(defn div [[a b] [c d]] ;; <- arglist goes here
-  ;; your code goes here
-)
+(defn div [[a b] [c d]]
+  (let [divisor (+ (* c c) (* d d))] [(double (/ (+ (* a c) (* b d)) divisor)) (double (/ (- (* b c) (* a d)) divisor))]))


simple fix for adzerk/boot-cljs#44 attempt #2

--- src/adzerk/boot_cljs/middleware.clj
+++ src/adzerk/boot_cljs/middleware.clj
@@ -145,7 +145,8 @@
       (update-in ctx [:opts :preamble] (comp vec distinct into) incs))

     :else
-    (let [shim-path   (:output-to opts)
+    (let [base-name   (-> main core/tmpfile .getName deps/strip-extension)
+          shim-path   (:output-to opts)
           shim-name   (util/get-name shim-path)
           output-to   (output-path-for shim-path)
           output-dir  (util/get-name (:output-dir opts))
@@ -155,7 +156,7 @@
                           (->> (mapv rooted-path))
                           (conj (io/file output-dir "goog" "base.js"))
                           (conj (util/get-name output-to)))]
-      (->> (write-body (file->goog "boot/cljs/main"))
+      (->> (write-body (file->goog (str "boot/cljs/" base-name)))
            (format shim-js shim-name (apply str (map write-src scripts)))
            (spit shim-path))
       (assoc-in ctx [:opts :output-to] output-to))))


Actually catch assertion errors in straight-jacket.

--- src/circle/util/straight_jacket.clj
+++ src/circle/util/straight_jacket.clj
@@ -1,23 +1,26 @@
 (ns circle.util.straight-jacket
   (:use [clojure.tools.logging :only (errorf )])
+  (:use [slingshot.slingshot])
   (:require [circle.airbrake :as airbrake]))
+
+

 (defmacro straight-jacket*
   [& body]
-  `(try
-     (try
-       (try
+  `(try+
+     (try+
+       (try+
          (do
            ~@body)
-         (catch Exception e#
+         (catch (or (instance? Exception ~'%) (instance? AssertionError ~'%)) e#
            (println "1")
            (airbrake/airbrake :exception e#
                               :data {:cmd (str (quote ~body))})))
-       (catch Exception e#
+       (catch (or (instance? Exception ~'%) (instance? AssertionError ~'%)) e#
          (.printStackTrace e#)
          (println "2")
          (errorf e# "straight-jacket")))
-     (catch Exception e#
+     (catch (or (instance? Exception ~'%) (instance? AssertionError ~'%)) e#
        (println "3")
        (println "*** Straight Jacket WTF ***"))))


Add fullscreen mode on apple devices

Add fullscreen mode on apple devices

--- src/clj/clojuredocs/site/common.clj
+++ src/clj/clojuredocs/site/common.clj
@@ -107,6 +107,7 @@
   [:html5
    [:head
     [:meta {:name "viewport" :content "width=device-width, maximum-scale=1.0"}]
+    [:meta {:name "apple-mobile-web-app-capable" :content "yes"}]
     [:title (or title "Community-Powered Clojure Documentation and Examples | ClojureDocs")]
     font-awesome-link
     bootstrap-link
@@ -166,7 +167,27 @@
     clojuredocs-script
     (when (env/bool :cljs-dev)
       [:script "goog.require(\"clojuredocs.main\");"])
-    ($ga-script-tag config/ga-tracking-id)]])
+    ($ga-script-tag config/ga-tracking-id)
+    [:script
+     "if((\"standalone\" in window.navigator) && window.navigator.standalone){
+var noddy, remotes = false;
+
+document.addEventListener('click', function(event) {
+
+noddy = event.target;
+
+while(noddy.nodeName !== \"A\" && noddy.nodeName !== \"HTML\") {
+noddy = noddy.parentNode;
+}
+
+if('href' in noddy && noddy.href.indexOf('http') !== -1 && (noddy.href.indexOf(document.location.host) !== -1 || remotes))
+{
+event.preventDefault();
+document.location.href = noddy.href;
+}
+
+},false);
+}"]]])

 (defn $avatar [{:keys [email login avatar-url] :as user}]
   [:a {:href (str "/u/" login)}


candidate fix for debug's un-grouping

candidate fix for debug's un-grouping

--- src/clj/marceline/storm/trident.clj
+++ src/clj/marceline/storm/trident.clj
@@ -437,7 +437,10 @@
 (defn debug
   [stream & [name]]
   (condp isa? (class stream)
-    GroupedStream (debug (.toStream stream) name)
+    GroupedStream
+    (let [grouped-fields (.getGroupFields stream)]
+      (.groupBy (debug (.toStream stream) name)
+                grouped-fields))
     TridentState (do (debug (.newValuesStream stream) name) stream)
     (.each stream
            (.getOutputFields stream)


pass debug name into recursive debug class invocations

--- src/clj/marceline/storm/trident.clj
+++ src/clj/marceline/storm/trident.clj
@@ -437,8 +437,8 @@
 (defn debug
   [stream & [name]]
   (condp isa? (class stream)
-    GroupedStream (debug (.toStream stream))
-    TridentState (do (debug (.newValuesStream stream)) stream)
+    GroupedStream (debug (.toStream stream) name)
+    TridentState (do (debug (.newValuesStream stream) name) stream)
     (.each stream
            (.getOutputFields stream)
            (if (not (nil? name))


add comment

add comment

--- src/clj/org/openforis/ceo/views.clj
+++ src/clj/org/openforis/ceo/views.clj
@@ -37,7 +37,7 @@
        (getPage)
        (kebab->camel)))

-(def page->js
+(def page->js ; TODO add webpack bundles
   {"geo-dash"             ["js/highcharts.js" ; TODO use the npm version
                            "/js/respond.min.js" ; TODO I dont think this is used. Billy imports a grid manager now instead.
                            "/js/jquery-3.4.1.min.js" ; TODO remove jquery as a dependency


Support base64 encoded snapshot

Support base64 encoded snapshot

--- src/cljs/asciinema_player/core.cljs
+++ src/cljs/asciinema_player/core.cljs
@@ -17,11 +17,20 @@
           components (map * (reverse numbers) (iterate (partial * 60) 1))]
       (apply + components))))

+(defn parse-poster [poster]
+  (if (string? poster)
+    (when (= (.indexOf poster "data:application/json;base64,") 0)
+      (-> poster
+          (.substring 29)
+          js/atob
+          js/JSON.parse
+          (js->clj :keywordize-keys true)))
+    poster))

 (defn make-player
   "Builds initial player for given options."
   [asciicast-url {:keys [width height speed poster font-size theme start-at]
-                  :or {speed 1 poster [] font-size "small" theme "asciinema"}
+                  :or {speed 1 font-size "small" theme "asciinema"}
                   :as options}]
   (let [start-at (parse-npt (or start-at 0))]
     (merge {:width width
@@ -30,7 +39,7 @@
             :source {}
             :asciicast-url asciicast-url
             :speed speed
-            :lines poster
+            :lines (or (parse-poster poster) [])
             :font-size font-size
             :theme theme
             :cursor {:visible false}


Card browser: number of cards displayed initially limited and show more on scroll

--- src/cljs/netrunner/cardbrowser.cljs
+++ src/cljs/netrunner/cardbrowser.cljs
@@ -77,6 +77,14 @@
     "Type" (juxt :side :type)
     "Set number" :number))

+(defn handle-scroll [e owner {:keys [page]}]
+  (let [$cardlist (js/$ ".card-list")
+        height (- (.prop $cardlist "scrollHeight") (.innerHeight $cardlist))]
+    (when (> (.scrollTop $cardlist) (- height 600))
+      (om/set-state! owner :page (inc (om/get-state owner :page)))
+      ;; (om/update-state! owner :page inc)
+      )))
+
 (defn card-browser [cursor owner]
   (reify
     om/IInitState
@@ -87,6 +95,7 @@
        :type-filter "All"
        :side-filter "All"
        :faction-filter "All"
+       :page 1
        :filter-ch (chan)})

     om/IWillMount
@@ -122,7 +131,7 @@
                       :on-change #(om/set-state! owner (second filter) (.. % -target -value))}
              (options (last filter))]])]

-        [:div.card-list
+        [:div.card-list {:on-scroll #(handle-scroll % owner state)}
          (om/build-all card-view
                        (->> (:cards cursor)
                             (filter-cards (:set-filter state) :setname)
@@ -130,7 +139,8 @@
                             (filter-cards (:faction-filter state) :faction)
                             (filter-cards (:type-filter state) :type)
                             (match (.toLowerCase (:search-query state)))
-                            (sort-by (sort-field (:sort-field state)) ))
+                            (take (* (:page state) 55))
+                            (sort-by (sort-field (:sort-field state))))
                        {:key :code})]]))))

 (om/root card-browser app-state {:target (. js/document (getElementById "cardbrowser"))})


Fix issue with new deck being created when editing an existing one

--- src/cljs/netrunner/deckbuilder.cljs
+++ src/cljs/netrunner/deckbuilder.cljs
@@ -74,10 +74,13 @@
 (defn save-deck [owner]
   (end-edit owner)
   (let [deck (om/get-state owner :deck)
+        decks (:decks @app-state)
         cards (for [card (:cards deck)]
                 {:qty (:qty card) :card (get-in card [:card :title])})
         data (assoc deck :cards cards)]
-    (swap! app-state assoc :decks (conj (:decks @app-state) deck))
+    (if-let [id (:_id deck)]
+      (swap! app-state assoc :decks (map #(if (= id (:_id %)) deck %) decks))
+      (swap! app-state assoc :decks (conj decks deck)))
     (go (let [response (<! (POST "/data/decks/" data :json))]))))

 (defn handle-edit [owner]


fix typo bug

fix typo bug

--- clj-tcp/src/clj_tcp/client.clj
+++ clj-tcp/src/clj_tcp/client.clj
@@ -236,7 +236,7 @@

 (defn- get-default-threads []
   ;for threads we choose a reasonable default
-    (NioEventLoopGroup. (int (/ (-> (Runtime/getRuntime) .availableProcessors) 2))))
+    (int (/ (-> (Runtime/getRuntime) .availableProcessors) 2)))

 (defn client [host port {:keys [handlers
                                   channel-options ;io.netty.channel options a sequence of [option val] e.g. [[option val] ... ]


use thread instead of go

use thread instead of go

--- clj-tcp/src/clj_tcp/client.clj
+++ clj-tcp/src/clj_tcp/client.clj
@@ -341,7 +341,7 @@

      ;async read off write-ch
-     (go
+     (thread
 	      (loop [local-client client]
 	          (let [ write-ch (:write-ch local-client)
 	                 v (<! write-ch)]