add table description option in write-bq-table

--- src/clj/datasplash/bq.clj
+++ src/clj/datasplash/bq.clj
@@ -193,6 +193,8 @@
                                                                        (cheshire.core/encode sch)
                                                                        (cheshire.core/encode {"fields" sch}))]
                                                         (.withJsonSchema transform full-sch)))}
+    :table-description {:docstr "Specifies table description"
+                        :action (fn [transform description] (.withTableDescription transform description))}
     :write-disposition {:docstr "Choose write disposition."
                         :enum write-disposition-enum
                         :action (select-enum-option-fn


Small change from fn to map

Small change from fn to map

--- src/clojure/yaw/scene.clj
+++ src/clojure/yaw/scene.clj
@@ -9,24 +9,21 @@
   [[x y z]]
   (list :x x :y y :z z))

-(defn kw-rgb
-  "Returns a rgb tuple from a keyword color"
-  [color]
-  (case color
-    :black [0 0 0]
-    :red [1 0 0]
-    :blue [0 0 1]
-    :green [0 1 0]
-    :yellow [1 1 0]
-    :cyan [0 1 1]
-    :magenta [1 0 1]
-    :white [1 1 1]))
+(def kw-rgb
+  {:black [0 0 0]
+   :red [1 0 0]
+   :blue [0 0 1]
+   :green [0 1 0]
+   :yellow [1 1 0]
+   :cyan [0 1 1]
+   :magenta [1 0 1]
+   :white [1 1 1]})

 (defn color-rgb
   "Returns a rgb tuple from any sort of color"
   [[kw v]]
   (case kw
-    :kw (kw-rgb v)
+    :kw (get kw-rgb v)
     :rgb v))

 (def empty-item-map


small tweak to unit test to make sure we don't run into issues.

--- test/metabase/api/notify_test.clj
+++ test/metabase/api/notify_test.clj
@@ -17,8 +17,8 @@
 (expect
   {:status 404
    :body "Not found."}
-  (try (client/post ((resolve 'metabase.http-client/build-url) "notify/db/100" {}) {:accept :json
-                                                                                :headers {"X-METABASE-APIKEY" "test-api-key"}})
+  (try (client/post ((resolve 'metabase.http-client/build-url) "notify/db/10000" {}) {:accept :json
+                                                                                :headers {"X-METABASE-APIKEY" "test-api-key"}})
        (catch clojure.lang.ExceptionInfo e
          (-> (.getData ^clojure.lang.ExceptionInfo e)
              (:object)


Whitespace

Whitespace

--- core/src/test/clojure/vdx_test/handlers.clj
+++ core/src/test/clojure/vdx_test/handlers.clj
@@ -1,23 +1,23 @@
 (ns vdx-test.handlers
-    (:require [clojure.test :refer :all]
+  (:require [clojure.test :refer :all]
             [clojure.java.io :as io])
-    (:import (org.projectodd.vdx.core.handlers
-               DuplicateAttributeHandler
-               DuplicateElementHandler
-               InvalidAttributeValueHandler
-               RequiredAttributeMissingHandler
-               RequiredElementMissingHandler
-               RequiredElementsMissingHandler
-               UnexpectedAttributeHandler
-               UnexpectedElementEndHandler
-               UnexpectedElementHandler
-               UnsupportedElementHandler
-               UnknownErrorHandler)
-      (org.projectodd.vdx.core ValidationContext ValidationError ErrorType I18N$Key)
-      (org.projectodd.vdx.core.schema SchemaElement)
-      (javax.xml.stream Location)
-      (javax.xml.namespace QName)
-      (java.util List)))
+  (:import (org.projectodd.vdx.core.handlers
+             DuplicateAttributeHandler
+             DuplicateElementHandler
+             InvalidAttributeValueHandler
+             RequiredAttributeMissingHandler
+             RequiredElementMissingHandler
+             RequiredElementsMissingHandler
+             UnexpectedAttributeHandler
+             UnexpectedElementEndHandler
+             UnexpectedElementHandler
+             UnsupportedElementHandler
+             UnknownErrorHandler)
+           (org.projectodd.vdx.core ValidationContext ValidationError ErrorType I18N$Key)
+           (org.projectodd.vdx.core.schema SchemaElement)
+           (javax.xml.stream Location)
+           (javax.xml.namespace QName)
+           (java.util List)))

 (defn location [line col]
   (reify Location
@@ -36,146 +36,146 @@

 (deftest test-UnexpectedAttributeHandler
   (let [ctx (ValidationContext. (io/resource "handler-test.xml")
-                                [(io/resource "schemas/handler-test.xsd")])]
+              [(io/resource "schemas/handler-test.xsd")])]
     (testing "unmatchable attribute with no alternates"
       (let [res (.handle (UnexpectedAttributeHandler.)
-                         ctx
-                         (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
-                                               ""
-                                               (location 6 4))
-                             (.element (QName. "urn:vdx:test" "ham"))
-                             (.attribute (QName. "biscuit"))))]
+                  ctx
+                  (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
+                        ""
+                        (location 6 4))
+                    (.element (QName. "urn:vdx:test" "ham"))
+                    (.attribute (QName. "biscuit"))))]
         (is (= 6 (.line res)))
         (is (= 8 (.column res)))
         (assert-message (.message res)
-                        I18N$Key/ATTRIBUTE_NOT_ALLOWED
-                        "biscuit" "ham")
+          I18N$Key/ATTRIBUTE_NOT_ALLOWED
+          "biscuit" "ham")
         (is (nil? (.extraMessage res)))))

     (testing "unmatchable attribute with schema alternatives"
       (let [res (.handle (UnexpectedAttributeHandler.)
-                         ctx
-                         (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
-                                               ""
-                                               (location 4 4))
-                             (.element (QName. "urn:vdx:test" "bar"))
-                             (.attribute (QName. "blahblahblah"))))]
+                  ctx
+                  (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
+                        ""
+                        (location 4 4))
+                    (.element (QName. "urn:vdx:test" "bar"))
+                    (.attribute (QName. "blahblahblah"))))]
         (assert-message (.extraMessage res)
-                        I18N$Key/ATTRIBUTES_ALLOWED_HERE
-                        ["attr1" "some-attr"])))
+          I18N$Key/ATTRIBUTES_ALLOWED_HERE
+          ["attr1" "some-attr"])))

     (testing "unmatchable attribute with provided alternatives"
       (let [res (.handle (UnexpectedAttributeHandler.)
-                         ctx
-                         (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
-                                               ""
-                                               (location 4 4))
-                             (.element (QName. "urn:vdx:test" "bar"))
-                             (.attribute (QName. "blahblahblah"))
-                             (.alternatives #{"abc"})))]
+                  ctx
+                  (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
+                        ""
+                        (location 4 4))
+                    (.element (QName. "urn:vdx:test" "bar"))
+                    (.attribute (QName. "blahblahblah"))
+                    (.alternatives #{"abc"})))]
         (assert-message (.extraMessage res)
-                        I18N$Key/ATTRIBUTES_ALLOWED_HERE
-                        ["abc"])))
+          I18N$Key/ATTRIBUTES_ALLOWED_HERE
+          ["abc"])))

     (testing "misspelled attribute with schema alternatives"
       (let [res (.handle (UnexpectedAttributeHandler.)
-                         ctx
-                         (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
-                                               ""
-                                               (location 4 4))
-                             (.element (QName. "urn:vdx:test" "bar"))
-                             (.attribute (QName. "attr2"))))]
+                  ctx
+                  (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
+                        ""
+                        (location 4 4))
+                    (.element (QName. "urn:vdx:test" "bar"))
+                    (.attribute (QName. "attr2"))))]
         (is (= 18 (.column res)))
         (assert-message (.extraMessage res)
-                        I18N$Key/DID_YOU_MEAN
-                        "attr1")))
+          I18N$Key/DID_YOU_MEAN
+          "attr1")))

     (testing "misspelled attribute with provided alternatives"
       (let [res (.handle (UnexpectedAttributeHandler.)
-                         ctx
-                         (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
-                                               ""
-                                               (location 4 4))
-                             (.element (QName. "urn:vdx:test" "bar"))
-                             (.attribute (QName. "attr2"))
-                             (.alternatives #{"attrx"})))]
+                  ctx
+                  (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
+                        ""
+                        (location 4 4))
+                    (.element (QName. "urn:vdx:test" "bar"))
+                    (.attribute (QName. "attr2"))
+                    (.alternatives #{"attrx"})))]
         (is (= 18 (.column res)))
         (assert-message (.extraMessage res)
-                        I18N$Key/DID_YOU_MEAN "attrx")))
+          I18N$Key/DID_YOU_MEAN "attrx")))

     (testing "matchable attribute"
       (let [res (.handle (UnexpectedAttributeHandler.)
-                         ctx
-                         (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
-                                               ""
-                                               (location 4 4))
-                             (.element (QName. "urn:vdx:test" "bar"))
-                             (.attribute (QName. "attr3"))))]
+                  ctx
+                  (-> (ValidationError. ErrorType/UNEXPECTED_ATTRIBUTE
+                        ""
+                        (location 4 4))
+                    (.element (QName. "urn:vdx:test" "bar"))
+                    (.attribute (QName. "attr3"))))]
         (is (= 28 (.column res)))
         (assert-message (.extraMessage res)
-                        I18N$Key/ATTRIBUTE_IS_ALLOWED_ON
-                        "attr3" [["foo"]])))))
+          I18N$Key/ATTRIBUTE_IS_ALLOWED_ON
+          "attr3" [["foo"]])))))

 (deftest test-UnexpectedElementHandler
   (let [ctx (ValidationContext. (io/resource "handler-test.xml")
-                                [(io/resource "schemas/handler-test.xsd")])]
+              [(io/resource "schemas/handler-test.xsd")])]
     (testing "unmatchable element with no alternates"
       (let [res (.handle (UnexpectedElementHandler.)
-                         ctx
-                         (-> (ValidationError. ErrorType/UNEXPECTED_ELEMENT
-                                               ""
-                                               (location 6 4))
-                             (.element (QName. "urn:vdx:test" "ham"))))]
+                  ctx
+                  (-> (ValidationError. ErrorType/UNEXPECTED_ELEMENT
+                        ""
+                        (location 6 4))
+                    (.element (QName. "urn:vdx:test" "ham"))))]
         (is (= 6 (.line res)))
         (is (= 4 (.column res)))
         (assert-message (.message res)
-                        I18N$Key/ELEMENT_NOT_ALLOWED
-                        "ham")
+          I18N$Key/ELEMENT_NOT_ALLOWED
+          "ham")
         (is (nil? (.extraMessage res)))))

     (testing "unmatchable element with provided alternatives"
       (let [res (.handle (UnexpectedElementHandler.)
-                         ctx
-                         (-> (ValidationError. ErrorType/UNEXPECTED_ELEMENT
-                                               ""
-                                               (location 6 4))
-                             (.element (QName. "urn:vdx:test" "ham"))
-                             (.alternatives #{"abcdefg"})))]
+                  ctx
+                  (-> (ValidationError. ErrorType/UNEXPECTED_ELEMENT
+                        ""
+                        (location 6 4))
+                    (.element (QName. "urn:vdx:test" "ham"))
+                    (.alternatives #{"abcdefg"})))]
         (assert-message (.extraMessage res)
-                        I18N$Key/ELEMENTS_ALLOWED_HERE
-                        ["abcdefg"])))
+          I18N$Key/ELEMENTS_ALLOWED_HERE
+          ["abcdefg"])))

     (testing "misspelled element with provided alternatives"
       (let [res (.handle (UnexpectedElementHandler.)
-                         ctx
-                         (-> (ValidationError. ErrorType/UNEXPECTED_ELEMENT
-                                               ""
-                                               (location 6 4))
-                             (.element (QName. "urn:vdx:test" "ham"))
-                             (.alternatives #{"abc"})))]
+                  ctx
+                  (-> (ValidationError. ErrorType/UNEXPECTED_ELEMENT
+                        ""
+                        (location 6 4))
+                    (.element (QName. "urn:vdx:test" "ham"))
+                    (.alternatives #{"abc"})))]
         (assert-message (.extraMessage res)
-                        I18N$Key/DID_YOU_MEAN
-                        "abc")))
+          I18N$Key/DID_YOU_MEAN
+          "abc")))

     (testing "matchable element"
       (let [res (.handle (UnexpectedElementHandler.)
-                         ctx
-                         (-> (ValidationError. ErrorType/UNEXPECTED_ELEMENT
-                                               ""
-                                               (location 7 4))
-                             (.element (QName. "urn:vdx:test" "sandwich"))))]
+                  ctx
+                  (-> (ValidationError. ErrorType/UNEXPECTED_ELEMENT
+                        ""
+                        (location 7 4))
+                    (.element (QName. "urn:vdx:test" "sandwich"))))]
         (assert-message (.extraMessage res)
-                        I18N$Key/ELEMENT_IS_ALLOWED_ON
-                        "sandwich" [["foo" "bar" "sandwiches"] ["omelet" "sandwiches"]])))))
+          I18N$Key/ELEMENT_IS_ALLOWED_ON
+          "sandwich" [["foo" "bar" "sandwiches"] ["omelet" "sandwiches"]])))))

 (deftest test-UnknownErrorHandler
-         (let [ctx (ValidationContext. (io/resource "handler-test.xml")
-                                       [(io/resource "schemas/handler-test.xsd")])]
-              (let [res (.handle (UnknownErrorHandler.)
-                                 ctx
-                                 (-> (ValidationError. ErrorType/UNKNOWN_ERROR
-                                                       "foo"
-                                                       (location 1 1))
-                                     (.fallbackMessage "bar")))]
-                   (assert-message (.message res)
-                                    I18N$Key/PASSTHRU "bar"))))
+  (let [ctx (ValidationContext. (io/resource "handler-test.xml")
+              [(io/resource "schemas/handler-test.xsd")])]
+    (let [res (.handle (UnknownErrorHandler.)
+                ctx
+                (-> (ValidationError. ErrorType/UNKNOWN_ERROR
+                      "foo"
+                      (location 1 1))
+                  (.fallbackMessage "bar")))]
+      (assert-message (.message res)
+        I18N$Key/PASSTHRU "bar"))))


Added wrap-params middle-ware

Added wrap-params middle-ware

--- src/cylon/impl/oauth2.clj
+++ src/cylon/impl/oauth2.clj
@@ -62,26 +62,27 @@
   WebService
   (request-handlers [this]
     {::authorize
-     (fn [req]
-       ;; TODO Establish whether the user-agent is already authenticated.
-       ;; If not, create a session with client-id, scope and state and redirect to the login form
-       (if-let [session
-                (get-session
-                 (:session-store this)
-                 (-> req cookies-request :cookies (get "session-id") :value))]
-         ;; TODO Obey the 'prompt' value in OpenID/Connect
-         {:status 200 :body (str "Hi - it appears you're already logged in, session is " (pr-str session))}
-
-         (let [session (create-session!
-                        (:session-store this)
-                        {:client-id (-> req :query-params (get "client_id"))
-                         :scope (-> req :query-params (get "scope"))
-                         :state (-> req :query-params (get "state"))
-                         })]
-           (cookies-response
-            {:status 200
-             :body "Hi - it appears you're not already logged in, so I'm going to create a session for you and redirect you"
-             :cookies {"session-id" (->cookie session)}}))))
+     (-> (fn [req]
+        ;; TODO Establish whether the user-agent is already authenticated.
+        ;; If not, create a session with client-id, scope and state and redirect to the login form
+        (if-let [session
+                 (get-session
+                  (:session-store this)
+                  (-> req cookies-request :cookies (get "session-id") :value))]
+          ;; TODO Obey the 'prompt' value in OpenID/Connect
+          {:status 200 :body (str "Hi - it appears you're already logged in, session is " (pr-str session))}
+
+          (let [session (create-session!
+                         (:session-store this)
+                         {:client-id (-> req :query-params (get "client_id"))
+                          :scope (-> req :query-params (get "scope"))
+                          :state (-> req :query-params (get "state"))
+                          })]
+            (cookies-response
+             {:status 200
+              :body "Hi - it appears you're not already logged in, so I'm going to create a session for you and redirect you"
+              :cookies {"session-id" (->cookie session)}}))))
+         wrap-params)

      ::get-authenticate-form
      (->


Support other named channel functions.

Support other named channel functions.

--- src/afterglow/fixtures/qxf.clj
+++ src/afterglow/fixtures/qxf.clj
@@ -46,6 +46,14 @@
   (when (and (= "Intensity" (:group specs)) (re-find #"(?i)dimmer" (:name specs)))
     (str "(chan/dimmer " offset (when fine-offset (str " " fine-offset)) ")")))

+(defn- define-named-channel
+  "If the supplied channel specification map seems to be another type
+  we have a special name for, emit a function which defines it at the
+  specified offsets."
+  [specs offset fine-offset type-name]
+  (when (re-find (re-pattern (str "(?i)" type-name)) (:name specs))
+    (str "(chan/" type-name " " offset (when fine-offset (str " " fine-offset)) ")")))
+
 (defn- define-pan-tilt-channel
   "If the supplied channel specification map seems to be a pan or tilt
   channel, emit a function which defines it at the specified offsets."
@@ -65,6 +73,7 @@
       (or (define-color-channel specs offset fine-offset)
           (define-dimmer-channel specs offset fine-offset)
           (define-pan-tilt-channel specs offset fine-offset)
+          (some (partial define-named-channel specs offset fine-offset) ["focus" "frost" "iris" "zoom"])
           (str "(chan/fine-channel " (keyword (sanitize-name (:name specs))) " " offset
                (when fine-offset (str " :fine-offset " fine-offset))
                "\n                                 :function-name \"" (:name specs)
@@ -271,7 +280,6 @@
   "Converts a map read by [[convert-qxf]] into an Afterglow fixture
   definition."
   [qxf]
-  (clojure.pprint/pprint qxf)
   (parser/render-file "fixture-definition.clj" qxf))

 (defn parse-qxf


Future test

Future test

--- test/structural_typing/f_type.clj
+++ test/structural_typing/f_type.clj
@@ -105,3 +105,4 @@
         (meta new-even?) => (contains {:optional true
                                        :default-message-format "derp!"})))))

+(future-fact "confirm defrecord works")


Made `render` a local function.

Made `render` a local function.

--- lein-lambda-blog/src/leiningen/new/lambda_blog.clj
+++ lein-lambda-blog/src/leiningen/new/lambda_blog.clj
@@ -1,8 +1,6 @@
 (ns leiningen.new.lambda-blog
   (:require [leiningen.new.templates :refer [renderer name-to-path ->files]]
             [leiningen.core.main :as main]))
-
-(def render (renderer "lambda-blog"))

 (defn lambda-blog
   "Creates a λ-blog blog named `name`."
@@ -10,7 +8,8 @@
   (let [data {:author "me"
               :name name
               :now (java.util.Date.)
-              :sanitized (name-to-path name)}]
+              :sanitized (name-to-path name)}
+        render (renderer "lambda-blog")]
     (main/info "Generating fresh 'lein new' lambda-blog project.")
     (->files data
              ["project.clj" (render "project.clj" data)]


working on simplifying grammar by using few rules and defaults applied at each point of adding children to the (generic) rule

--- src/babel/italiano/grammar.cljc
+++ src/babel/italiano/grammar.cljc
@@ -16,14 +16,21 @@
                      subcat-1-1-principle subcat-2-principle
                      subcat-1-1-principle-comp-subcat-1
                      subcat-2-2-principle
-                     subcat-5-principle verb-default?]
+                     subcat-5-principle]
     :as ug]
    #?(:clj [clojure.tools.logging :as log])
    #?(:cljs [babel.logjs :as log])
    [clojure.core.cache :as cache]
    [clojure.pprint :refer (pprint)]
    [clojure.repl :refer (doc)]
-   [dag_unify.core :refer (fail? get-in remove-matching-keys strip-refs unify)]))
+   [dag_unify.core :as u :refer [fail? get-in remove-matching-keys strip-refs unify]]))
+
+(defn verb-default? [tree]
+  (and (= :verb (u/get-in tree [:synsem :cat]))
+       (or (= :top (u/get-in tree [:synsem :sem :tense] :top))
+           (= :top (u/get-in tree [:synsem :infl] :top))
+           (= {:not :infinitive}
+              (u/strip-refs (u/get-in tree [:synsem :infl] :top))))))

 (defn default-fn [tree]
   (let [result
@@ -375,49 +382,21 @@
                                :rule "s-aux"
                                :synsem {:cat :verb}})

-                       ;; TODO: consolidate s-future-(non)phrasal,s-conditional-(non)phrasal,etc
-                       ;; into fewer rules and use a default rule to choose among them.
                        (unify c10
                               root-is-head-root
-                              {:rule "s-future-phrasal"
+                              {:rule "sentence-phrasal-head"
                                :head {:phrasal true}
                                :synsem {:aux false
-                                        :infl :future
-                                        :cat :verb
-                                        :sem {:tense :future}}})
-                       (unify c10
-                              root-is-head-root
-                              {:rule "s-conditional-phrasal"
-                               :head {:phrasal true}
-                               :synsem {:aux false
-                                        :infl :conditional
-                                        :cat :verb
-                                        :sem {:tense :conditional}}})
-                       (unify c10
-                              root-is-head-root
-                              {:rule "s-imperfetto-phrasal"
-                               :head {:phrasal true}
-                               :synsem {:aux false
-                                        :infl :imperfetto
-                                        :cat :verb
-                                        :sem {:aspect :progressive
-                                              :tense :past}}})
+                                        :infl {:not :infinitive}}})

                        (unify c10
                               root-is-head
                               {:rule "sentence-nonphrasal-head"
                                :head {:phrasal false}
-                               :synsem {:cat :verb}})
-
-                       (unify c10
-                              root-is-head-root
-                              {:rule "s-present-phrasal"
-                               :head {:phrasal true}
                                :synsem {:aux false
-                                        :infl :present
                                         :cat :verb
-                                        :sem {:aspect :simple
-                                              :tense :present}}})
+                                        :infl {:not :infinitive}}})
+
                        (unify h21
                               root-is-head
                               {:rule "vp-infinitive"
@@ -486,17 +465,8 @@

                        (unify h21
                               root-is-head
-                              {:rule "vp-future"
+                              {:rule "vp"
                                :synsem {:aux false
-                                        :infl :future
-                                        :cat :verb}}
-                              vp-non-pronoun)
-
-                       (unify h21
-                              root-is-head
-                              {:rule "vp-imperfetto"
-                               :synsem {:aux false
-                                        :infl :imperfetto
                                         :cat :verb}}
                               vp-non-pronoun)

@@ -532,8 +502,7 @@
                                :comp {:synsem {:cat :noun
                                                :pronoun true}}
                                :rule "vp-pronoun-phrasal"
-                               :synsem {:cat :verb
-                                        :infl {:not :passato}}})
+                               :synsem {:cat :verb}})

                        (unify c21
                               root-is-head
@@ -544,8 +513,7 @@
                                                  :reflexive reflexive?
                                                  :pronoun true}}
                                  :rule "vp-pronoun-nonphrasal"
-                                 :synsem {:cat :verb
-                                          :infl {:not :passato}}}))
+                                 :synsem {:cat :verb}}))

                        ;; e.g. used as: "io mi chiamo Luisa" -
                        ;; [s-present-phrasal 'io' [vp-pronoun-phrasal 'mi' [vp-32 'chiamo' 'Luisa']]]
@@ -555,7 +523,6 @@
                                :head {:phrasal false
                                       :synsem {:aux false}}
                                :synsem {:aux false
-                                        :infl {:not :passato}
                                         :cat :verb}})
                        (unify h10
                               root-is-comp


use :agr for number and person where needed

--- src/babel/italiano/lexicon.cljc
+++ src/babel/italiano/lexicon.cljc
@@ -37,22 +37,21 @@
                              :subcat '()
                              :sem location}
                          :2 '()}}})
-
-       {:synsem {:cat :prep
-             :sem {:pred :in}
-             :subcat {:1 {:cat :noun
-                          :sem {:city true}}}}}
-
-       ;; e.g. "a ridere": tu hai fatto bene a ridere (you did well to laugh)"
-       (let [complement-semantics (atom {:pred :a
-                                        :mod {:pred :a}})]
-         {:synsem {:cat :prep
-                   :sem complement-semantics
-                   :subcat {:1 {:cat :verb
-                                :sem complement-semantics
+    {:synsem {:cat :prep
+              :sem {:pred :in}
+              :subcat {:1 {:cat :noun
+                           :sem {:city true}}}}}
+
+    ;; e.g. "a ridere": tu hai fatto bene a ridere (you did well to laugh)"
+    (let [complement-semantics (atom {:pred :a
+                                      :mod {:pred :a}})]
+      {:synsem {:cat :prep
+                :sem complement-semantics
+                :subcat {:1 {:cat :verb
+                             :sem complement-semantics
                                 :subcat {:1 :top
                                          :2 '()}}
-                            :2 '()}}})]
+                         :2 '()}}})]

    "abbandonare" {:synsem {:cat :verb
                            :sem {:pred :abandon}}}
@@ -657,17 +656,20 @@
                    (merge common
                           {:synsem {:cat :verb
                                     :sem {:pred :strike}}})])
-      "cominciare"
-      [{:synsem {:essere false
-                          :sem {:activity true
-                                :discrete false
-                                :pred :begin
-                                :subj {:animate true}}}}
-       {:synsem {:essere false
-                 :sem {:activity true
-                       :discrete false
-                       :pred :start
-                       :subj {:animate true}}}}]
+              "cominciare"
+              [{:synsem {:cat :verb
+                         :essere false
+                         :sem {:activity true
+                               :discrete false
+                               :pred :begin
+                               :subj {:animate true}}}}
+               {:synsem {:cat :verb
+                         :essere false
+                         :sem {:activity true
+                               :discrete false
+                               :pred :start
+                               :subj {:animate true}}}}]
+
       "compito"
       (unify agreement-noun
              common-noun
@@ -788,19 +790,17 @@
       "dei"
       {:synsem {:cat :det
                 :def :partitivo
-                :number :plur
-                :gender :masc}}
-
+                :agr {:number :plur
+                      :gender :masc}}}
       "delle"
       {:synsem {:cat :det
                 :def :partitivo
-                :number :plur
-                :gender :fem}}
-
-
+                :agr {:number :plur
+                      :gender :fem}}}
       "deludere"
        {:italiano {:passato "deluso"}
-        :synsem {:essere false
+        :synsem {:cat :Verb
+                 :essere false
                  :sem {:deliberate false
                        :discrete true
                        :activity false
@@ -830,23 +830,20 @@
       "di la"
       {:synsem {:cat :det
                 :def :partitivo
-                :number :sing
-                :mass true
-                :gender :fem}}
-
+                :agr {:number :sing
+                      :gender :fem}
+                :mass true}}
       "di le"
       {:synsem {:cat :det
                 :def :partitivo
-                :number :plur
-                :gender :fem}}
-
+                :agr {:number :plur
+                      :gender :fem}}}
       "di il"
       {:synsem {:cat :det
                 :def :partitivo
-                :number :sing
                 :mass true
-                :gender :masc}}
-
+                :agr {:number :sing
+                      :gender :masc}}}
       "difficile"
       ;; non-comparative
       ;; TODO: add comparative
@@ -1080,9 +1077,9 @@
                                   :2plur "fate"
                                   :3plur "fanno"}}}]
         [(merge shared-part-of-fare
-                {:synsem {:pred :do}})
+                {:synsem {:sem {:pred :do}}})
          (merge shared-part-of-fare
-                {:synsem {:pred :make}})
+                {:synsem {:sem {:pred :make}}})
          (merge shared-part-of-fare
                 (let [subject-semantics (atom {:human true})
                       subject-agr (atom :top)]
@@ -1169,17 +1166,17 @@
       (unify determiner
              {:synsem {:cat :det
                        :def :def
-                       :gender :masc
-                       :number :plur}})
+                       :agr {:gender :masc
+                             :number :plur}}})

       "il"
       (unify determiner
               {:synsem {:cat :det
                         :def :def
-                        :gender :masc
-                        :number :sing}})
-
+                        :agr {:gender :masc
+                              :number :sing}}})
+
       "imparare"  {:synsem {:cat :verb
                             :sem {:pred :learn}}}

@@ -1265,30 +1262,30 @@
        ;; 3. article
        {:synsem {:cat :det
                  :def :def
-                 :gender :fem
-                 :number :sing}}]
+                 :agr {:gender :fem
+                       :number :sing}}}

       "la loro"
       {:synsem {:cat :det
                 :def :possessive
-                :gender :fem
-                :number :sing
+                :agr {:gender :fem
+                      :number :sing}
                 :sem {:number :plur
                       :person :3rd}}}

       "la mia"
       {:synsem {:cat :det
                 :def :possessive
-                :gender :fem
-                :number :sing
+                :agr {:gender :fem
+                      :number :sing}
                 :sem {:number :sing
                       :person :1st}}}

       "la nostra"
       {:synsem {:cat :det
                 :def :possessive
-                :gender :fem
-                :number :sing
+                :agr {:gender :fem
+                      :number :sing}
                 :sem {:number :plur
                       :person :1st}}}

@@ -1297,22 +1294,22 @@
    "la sua"
    {:synsem {:cat :det
              :def :possessive
-             :gender :fem
-             :number :sing
+             :agr {:gender :fem
+                   :number :sing}
              :sem {:number :sing
                    :person :3rd}}}
    "la tua"
    [{:synsem {:cat :det
               :def :possessive
-              :gender :fem
-              :number :sing
+              :agr {:gender :fem
+                    :number :sing}
               :sem {:number :sing
                     :person :2nd}}}

     {:synsem {:cat :det
               :def :possessive
-              :gender :fem
-              :number :sing
+              :agr {:gender :fem
+                    :number :sing}
                 :sem {:number :plur
                       :person :2nd}}}]

@@ -1337,8 +1334,8 @@
    "le"
    {:synsem {:cat :det
              :def :def
-             :gender :fem
-             :number :plur}}
+             :agr {:gender :fem
+                   :number :plur}}}
    "lei"
    (let [common {:synsem {:cat :noun
                           :pronoun true
@@ -1641,11 +1638,11 @@
                                :2plur "potete"
                                :3plur "possono"}}}]
      [(merge shared-part-of-potere
-             {:synsem {:pred :can}})
+             {:synsem {:sem {:pred :can}}})
       (merge shared-part-of-potere
-             {:synsem {:pred :may}})
+             {:synsem {:sem {:pred :may}}})
       (merge shared-part-of-potere
-             {:synsem {:pred :be-able-to}})])
+             {:synsem {:sem {:pred :be-able-to}}})])

    "prendere" {:synsem {:cat :verb :sem {:pred :grab}}
                :italiano {:passato "preso"}}
@@ -1669,8 +1666,8 @@
    "qualche"
    {:synsem {:cat :det
              :def :indef
-             :mass false
-             :number :sing}}
+             :agr {:mass false
+                   :number :sing}}}

    "racontare" {:synsem {:cat :verb
                          :sem {:pred :recount}}}
@@ -1925,17 +1922,17 @@
               :subcat '()}}]

    "un"
-   [{:synsem {:cat :det
+       {:synsem {:cat :det
+                 :def :indef
+                 :mass false
+                 :agr {:gender :masc
+                       :number :sing}}}
+   "una"
+    {:synsem {:cat :det
               :def :indef
               :mass false
-              :gender :masc
-              :number :sing}}]
-   "una"
-   [{:synsem {:cat :det
-              :def :indef
-              :mass false
-              :gender :fem
-              :number :sing}}]
+              :agr {:gender :fem
+                    :number :sing}}}

    "usare"  {:synsem {:cat :verb
                       :sem {:pred :usare}}}


:infinitive-for-conjugation

:infinitive-for-conjugation

--- src/babel/italiano/lexicon.cljc
+++ src/babel/italiano/lexicon.cljc
@@ -958,7 +958,7 @@

    "dire" (let [shared-part-of-dire
                 {:synsem {:cat :verb}
-                 :italiano {:infinitive "dicere"
+                 :italiano {:infinitive-for-conjugation "dicere"
                             :drop-e false
                             :passato "detto"
                             :future-stem "dir"


temp checkin

temp checkin

--- dada-core/src/main/clojure/org/dada/jms.clj
+++ dada-core/src/main/clojure/org/dada/jms.clj
@@ -30,51 +30,126 @@
   (writeMessage [_ message text]
 		(.setText ^TextMessage message text) nil))

-;;------------------------------------------------------------------------------
+;; ;;------------------------------------------------------------------------------

-(defprotocol MessageServer
-  (open [this])
-  (close [this])
-  (process [this message]))
+;; (defprotocol MessageServer
+;;   (open [this])
+;;   (close [this])
+;;   (receive-send [this message]))

-(deftype JMSMessageServer [target ^Session session message-strategy ^MessageProducer producer translator ^String end-point ^ExecutorService threads]
+;; (deftype JMSMessageServer [target ^Session session message-strategy ^MessageProducer producer translator ^String end-point ^ExecutorService threads]

-  MessageListener
+;;   MessageListener

-  (^void onMessage [this ^Message message]
-	 (.execute threads (fn [] (.process this message))))
+;;   (^void onMessage [this ^Message message]
+;; 	 (.execute threads (fn [] (.process this message))))

-  MessageServer
+;;   MessageServer

-  (open [this]
-	(let [ ;; we should be creatng our own thread pool here
-	      ^Destination destination (if end-point (.createQueue session end-point) (.createTemporaryQueue session))
-	      ^MessageConsumer consumer (.createConsumer session destination)]
-	  ;; we need to stash consumer and destination for later
-	  (.setMessageListener consumer this)))
+;;   (open [this]
+;; 	(let [ ;; we should be creatng our own thread pool here
+;; 	      ^Destination destination (if end-point (.createQueue session end-point) (.createTemporaryQueue session))
+;; 	      ^MessageConsumer consumer (.createConsumer session destination)]
+;; 	  ;; we need to stash consumer and destination for later
+;; 	  (.setMessageListener consumer this)))

-  (close [this]
-	 ;; shutdown our threads
-	 ;; close our consumer
-	 ;; if we are using a temporary queue - delete it
-	 )
+;;   (close [this]
+;; 	 ;; shutdown our threads
+;; 	 ;; close our consumer
+;; 	 ;; if we are using a temporary queue - delete it
+;; 	 )

-  (process [_ message]
-	   (let [^Message request message
-		 correlation-id (.getJMSCorrelationID request)
-		 reply-to (.getJMSReplyTo request)
-		 results
-		 (try
-		   ;; TODO - (AbstractClient/setCurrentSession session) ;; TODO - hacky - we should own this ThreadLocally
-		   (let [func (.foreign-to-native translator (.readMessage message-strategy request))]
-		     [true (apply func target)])
-		   (catch Throwable t
-		     [false t]))]
+;;   (receive [_ message]
+;; 	   (let [^Message request message
+;; 		 correlation-id (.getJMSCorrelationID request)
+;; 		 reply-to (.getJMSReplyTo request)
+;; 		 results
+;; 		 (try
+;; 		   ;; TODO - (AbstractClient/setCurrentSession session) ;; TODO - hacky - we should own this ThreadLocally
+;; 		   (let [func (.foreign-to-native translator (.readMessage message-strategy request))]
+;; 		     [true (apply func target)])
+;; 		   (catch Throwable t
+;; 		     [false t]))]

-	     (if (and correlation-id reply-to)
-	       (let [^Message response (.createMessage message-strategy session)]
-		 (.setJMSCorrelationID response correlation-id)
-		 (.writeMessage message-strategy response (.native-to-foreign translator results))
-		 (.send producer reply-to response)))))
+;; 	     (if (and correlation-id reply-to)
+;; 	       (let [^Message response (.createMessage message-strategy session)]
+;; 		 (.setJMSCorrelationID response correlation-id)
+;; 		 (.writeMessage message-strategy response (.native-to-foreign translator results))
+;; 		 (.send producer reply-to response)))))

-  )
+;;   )
+;; ;;------------------------------------------------------------------------------
+
+;; (defprotocol MessageClient
+;;   (open [this])
+;;   (close [this])
+;;   (receive [this])
+;;   (send [this]))
+
+
+;; ;; we should be able to abstract just client bits into an async client
+;; ;; from which a sync client could inherit and add exchange and
+;; ;; server-side resources
+
+;; (deftype JMSMessageClient [ ;;server
+;; 			   threads exchangers translator message-strategy
+;; 			   reply-to
+;; 			   ;; client
+;; 			   producer ;with implicit send-to destination
+;; 			   send-to
+;; 			   ids
+;; 			   timeout	;millis
+;; 			   ]
+
+
+;;   MessageListener
+
+;;   (^void onMessage [this ^Message message]
+;; 	 (.execute thread (fn [] (.receive this message))))
+
+;;   MessageClient
+
+;;   (open [this]
+;; 	;; create a temporary queue - reply-to
+;; 	;; or use a permanent topic
+;; 	(.setMessageListener reply-to this))
+
+;;   (close [this]
+;; 	 (.setMessageListener reply-to nil)
+;; 	 ;;if using a temporary queue, delete it
+;; 	 )
+
+;;   (receive [this ^Message message]
+;; 	   (let [id (.getJMSCorrelationID message)]
+;; 	     (if-let [^Exchanger exchanger (swap2! exchangers (fn [old id] [(dissoc old id)(old id)]) id)]
+;; 	       (do
+;; 		 ;; TODO - (AbstractClient/setCurrentSession session) ;; TODO - hacky - we should own this ThreadLocally
+;; 		 (.exchange exchanger (.foreign-to-native translator (.readMessage message-strategy message))))
+;; 	       (warn "no exchanger for message: " id))))
+
+;;   (send-async [_ invocation]
+;; 	      (let [^Message message (.createMessage strategy session)]
+;; 		(.writeMessage strategy message (.native-to-foreign translator invocation))
+;; 		(.send producer message)))
+
+;;   (send-sync [_ invocation]
+;; 	     (let [^Message message (.createMessage strategy session)
+;; 		   id (swap! ids inc)
+;; 		   exchanger (Exchanger.)]
+;; 	       (.setJMSCorrelationId message id)
+;; 	       (.setJMSReplyTo message reply-to)
+;; 	       (.writeMessage strategy message (.native-to-foreign translator invocation))
+;; 	       (swap! exchangers assoc id exchanger)
+;; 	       (.send producer message)
+;; 	       (let [[is-exception results]
+;; 		     (try
+;; 		       (.exchange exchanger nil timeout (TimeUnit/MILLISECONDS))
+;; 		       (catch Throwable t
+;; 			 (swap! exchanger dissoc id)
+;; 			 (throw t)))]
+;; 		 (if is-exception
+;; 		   (throw results)
+;; 		   results))))
+;;   )
+
+;; ;;------------------------------------------------------------------------------


fix "buscar"

fix "buscar"

--- src/babel/espanol/lexicon.cljc
+++ src/babel/espanol/lexicon.cljc
@@ -147,13 +147,10 @@
    "beber" {:synsem {:cat :verb
                      :sem {:pred :drink}}}

-   "buscar" (let [common {:espanol}]
-             [{:unify [common]
-               :synsem {:cat :verb
-                        :sem {:pred :look-for}}}
-              {:unify [common]
-               :synsem {:cat :verb
-                        :sem {:pred :look-up}}}])
+   "buscar" [{:synsem {:cat :verb
+                       :sem {:pred :look-for}}}
+             {:synsem {:cat :verb
+                       :sem {:pred :look-up}}}]
    "caber" {}
    "caerse" {}


More utilities in hash and block creation.

--- src/blocks/data.clj
+++ src/blocks/data.clj
@@ -1,4 +1,4 @@
-(ns blocks.data
+(ns ^:no-doc blocks.data
   "Block type and constructor functions.

   Blocks have two primary attributes, `:id` and `:size`. The block identifier
@@ -217,24 +217,36 @@
   (Instant/now))

+(defn hasher
+  "Return the hashing function for an algorithm keyword, or throw an exception
+  if no supported function is available."
+  [algorithm]
+  (or (multihash/functions algorithm)
+      (throw (IllegalArgumentException.
+               (str "No digest function found for algorithm "
+                    algorithm)))))
+
+
 (defn create-block
   "Create a block from a content reader. The simplest version is a no-arg
   function which should return a new `InputStream` to read the full block
   content. The block is given the id and size directly, without being checked."
-  [id size stored-at content]
-  (when-not (instance? Multihash id)
-    (throw (ex-info "Block id must be a multihash"
-                    {:id id, :size size, :stored-at stored-at})))
-  (when-not (pos-int? size)
-    (throw (ex-info "Block size must be a positive integer"
-                    {:id id, :size size, :stored-at stored-at})))
-  (when-not stored-at
-    (throw (ex-info "Block must have a stored-at instant"
-                    {:id id, :size size, :stored-at stored-at})))
-  (when-not content
-    (throw (ex-info "Block must have a content reader"
-                    {:id id, :size size, :stored-at stored-at})))
-  (Block. id size stored-at content nil 0))
+  ([id size content]
+   (create-block id size (now) content))
+  ([id size stored-at content]
+   (when-not (instance? Multihash id)
+     (throw (ex-info "Block id must be a multihash"
+                     {:id id, :size size, :stored-at stored-at})))
+   (when-not (pos-int? size)
+     (throw (ex-info "Block size must be a positive integer"
+                     {:id id, :size size, :stored-at stored-at})))
+   (when-not (instance? Instant stored-at)
+     (throw (ex-info "Block must have a stored-at instant"
+                     {:id id, :size size, :stored-at stored-at})))
+   (when-not content
+     (throw (ex-info "Block must have a content reader"
+                     {:id id, :size size, :stored-at stored-at})))
+   (Block. id size stored-at content nil 0)))

 (defn load-block
@@ -253,10 +265,7 @@
   "Create a block by reading the source into memory and hashing it."
   [algorithm source]
   ; OPTIMIZE: calculate the hash while reading the content in one pass.
-  (let [hash-fn (or (multihash/functions algorithm)
-                    (throw (IllegalArgumentException.
-                             (str "No digest function found for algorithm "
-                                  algorithm))))
+  (let [hash-fn (hasher algorithm)
         content (collect-bytes source)
         size (count content)]
     (when (pos? size)


added nacer

added nacer

--- src/babel/espanol/lexicon.cljc
+++ src/babel/espanol/lexicon.cljc
@@ -637,6 +637,11 @@
                                  :number :sing
                                  :def :def}}}})

+   "nacer" {:espanol  {:present {:1sing "nazco"}}
+            :synsem {:cat :verb
+                      :sem {:pred :be-born}}}
+
+
    "negar" {:espanol {:boot-stem "nieg"}
                 :synsem {:cat :verb
                          :sem {:pred :deny}}}


Remove refocus client stuff, change heading.

--- src/benjaminwarfield/views.clj
+++ src/benjaminwarfield/views.clj
@@ -11,8 +11,6 @@
     (include-css "/stylesheets/bootstrap-responsive.min.css")
     (include-js "/javascripts/analytics.js")
     (include-js "/javascripts/bootstrap.min.js")
-    (include-js "http://assets-staging.refocus.co/refocus.js")
-    (javascript-tag "ReFocus.init({ host: '//assets-staging.refocus.co', socketHost: 'refocus.staging.d-i.co'});")])

 (defhtml page-header []
   [:div.header
@@ -30,7 +28,7 @@
   [:p [:a.about {:href "/about"} "Who do I think I am?"]])

 (defhtml about-content []
-  [:h2 "Developer and Ops guy."]
+  [:h2 "Me, around the web."]
   [:div.around_the_web
     [:ul
       [:li [:a {:href "http://twitter.com/benjaminws"} "Twitter"]]


imports

imports

--- src/bitsplit_cli/commands.cljs
+++ src/bitsplit_cli/commands.cljs
@@ -1,15 +1,13 @@
 (ns bitsplit-cli.commands
     (:use [bitsplit.core :only (add-address! remove-address!)]
-          clojure.string
-          bitsplit.client.protocol
-          bitsplit.storage.protocol
-          bitsplit-cli.addresses
-          bitsplit-cli.display))
+          [bitsplit.storage.protocol :only (all)]
+          [bitsplit-cli.addresses :only (split-address sub-address)]
+          [bitsplit-cli.display :only (render)]))

 (defn split-cmd [command]
     (-> command
-        trim
-        (split #" +")))
+        (.trim)
+        (.split #" +")))

 (def last-rendered (atom nil))


bra va

bra va

--- src/epicea/typed/core.clj
+++ src/epicea/typed/core.clj
@@ -75,8 +75,6 @@

 (def primitive-values #{:double :float :long :int :bool :number})

-(declare compute-size)
-
 (defn size-op [f]
   (fn [a b]
     (if (and (number? a) (number? b))
@@ -84,6 +82,8 @@
 (def size-add +)
 (def size-mul *)
 (def size-max max)
+
+(declare compute-size)

 (defn compute-vec-size [x]
   (size-mul (compute-size (vec-type x))
@@ -103,7 +103,9 @@
       (= :record h) (compute-record-size b)
       :default nil)))

-(def compute-size-on (comp compute-size #(spec/conform ::type %)))
+(def parse-type #(spec/conform ::type %))
+
+(def compute-size-on (comp compute-size parse-type))

 ;;
 (assert (= 1 (compute-size-on 9)))
@@ -115,6 +117,48 @@
 (assert (spec/valid? ::type 9))
 (assert (= [:long [:value 9]] (spec/conform ::type 9)))
 (assert (spec/valid? ::type [:record :a [:constant 9] :b :double]))
+
+(declare visit-primitives)
+
+(defn visit-vec-primitives [b f]
+  (if (= (:type b) :vecdata)
+    (update-in b [:data]
+               (fn [fields]
+                 (map #(visit-primitives % f) fields)))
+    (update-in b [:value-type] #(visit-primitives % f))))
+
+(defn visit-record-primitives [b f]
+  (update-in b [:fields]
+             (fn [fields]
+               (map (fn [field]
+                      (update-in field [:value-type]
+                                 #(visit-primitives % f)))
+                    fields))))
+
+(defn visit-primitives [type f]
+  (let [h (access/getx type-head type)]
+    (cond
+      (contains? primitive-values h) (f type)
+      (= :vec h) (access/updatex type-body type
+                                 #(visit-vec-primitives % f))
+      (= :record h) (access/updatex type-body type
+                                 #(visit-record-primitives % f))
+      :default type)))
+
+(defn visit-primitive-on [x f]
+  (visit-primitives (parse-type x) f))
+
+(assert (= [:visited [:long [:value 9]]]
+           (visit-primitive-on 9 (fn [x] [:visited x]))))
+(assert (= [:vec {:type :vecdata, :data '([:visited [:long [:value 1]]]
+                                          [:visited [:long [:value 2]]]
+                                          [:visited [:long [:value 3]]])}]
+           (visit-primitive-on [:vecdata 1 2 3] (fn [x] [:visited x]))))
+(assert (= (visit-primitive-on [:record :a 1 :b 2 :c 3] (fn [x] [:visited x]))
+           [:record {:type :record,
+                     :fields '({:key :a, :value-type [:visited [:long [:value 1]]]}
+                               {:key :b, :value-type [:visited [:long [:value 2]]]}
+                               {:key :c, :value-type [:visited [:long [:value 3]]]})}]))

 (defn export-primitive [x]
   [:export x])


track status of gif rendering

track status of gif rendering

--- src/cellf/core.cljs
+++ src/cellf/core.cljs
@@ -227,6 +227,7 @@

 (defn make-gif [app ms]
+  (om/update! app :gif-building? true)
   (let [gif    (js/GIF. #js {:workerScript "/js/gif.worker.js" :quality 1})
         canvas (.-canvas playback-ctx)]
     (go
@@ -234,7 +235,9 @@
         (<! (paint-canvas! app idx))
         (.addFrame gif canvas #js {:delay ms :copy true}))
       (doto gif
-        (.on "finished" #(om/update! app :result-gif (.createObjectURL js/URL %)))
+        (.on "finished" (fn [data]
+          (om/update! app :result-gif (.createObjectURL js/URL data))
+          (om/update! app :gif-building? false)))
         (.render)))))


Restart the CLI when it accidently terminates.

--- src/cli4clj/cli.clj
+++ src/cli4clj/cli.clj
@@ -356,15 +356,17 @@
                   (async/<!! out-chan#))
          read-factory# (fn [opts#] (create-embedded-read-fn opts# in-chan#))]
      (doto
-       (Thread. #(binding [*read-factory* read-factory#]
-                   (utils/with-out-str-cb
-                     (fn [out#]
-                       (when
-                         (and
-                           (not (nil? out#))
-                           (not (-> (str out#) (.isEmpty))))
-                         (.write @out-wrtr# out#)))
-                     (start-cli adjusted-user-options#))))
+       (Thread. #(loop []
+                   (binding [*read-factory* read-factory#]
+                     (utils/with-out-str-cb
+                       (fn [out#]
+                         (when
+                           (and
+                             (not (nil? out#))
+                             (not (-> (str out#) (.isEmpty))))
+                           (.write @out-wrtr# out#)))
+                       (start-cli adjusted-user-options#)))
+                   (recur)))
        (.setDaemon true)
        (.start))
      in-fn#))


Extracting args for functions defined via defn works.

--- src/cli4clj/cli.clj
+++ src/cli4clj/cli.clj
@@ -163,16 +163,14 @@

 (defn add-args-info
   [opts]
-  (println opts)
   (reduce
     (fn [m k]
       (let [f (get-in opts [:cmds k :fn])
             args (cond
-                   (fn? f) (:args (get-defn-arglists f))
+                   (symbol? f) (map-quote-vec (get-defn-arglists (eval `(var ~f))))
                    (and (list? f)
                         (= 'fn (first f))) (:args (get-fn-arglists f))
                    :default nil)]
-        (println k f)
         (if (not (nil? args))
           (assoc-in m [:cmds k :fn-args] args)
           m)))


Deal with arguments on function.

Deal with arguments on function.

--- src/fnx/views/welcome.clj
+++ src/fnx/views/welcome.clj
@@ -35,16 +35,19 @@

 ;; A page to execute function
 (defpage "/xfn" {:keys [fun] :as user}
-  (let [g (fnx.meta.expose/resolve-str fun)]
+  (let [g (fnx.meta.expose/resolve-str fun)
+        k (dissoc user :fun)]
     (common/site-layout
      "eXecute"
      [:h1 (str "eXecute " g)]
-     [:p:#wrapper (str (g))])))
+     [:p#wrapper (str "function " g " args " k)]
+     [:p#wrapper (apply g (vals k))])))

 (defn input-fields-fn "Wrapper to expose an execute function button."
   [fun]
   (form-to [:get "/xfn"]
            (text-field "fun" fun)
+           (map #(text-field % "") (flatten (:arglists (meta fun))))
            (submit-button (str fun))))

 ;; A page to expose some functions from a namespace.


Simplify intent with destructuring

Simplify intent with destructuring

--- src/foreclojure/users.clj
+++ src/foreclojure/users.clj
@@ -74,9 +74,7 @@

 (def-page users-page []
   (let [username (session/session-get :user)
-        top-100-and-current-user (get-top-100-and-current-user username)
-        user-ranking (:user-ranking top-100-and-current-user)
-        top-100 (:top-100 top-100-and-current-user)]
+        {:keys [user-ranking top-100]} (get-top-100-and-current-user username)]
     {:title "Top 100 Users"
     :content
     (list


Replacing normal recursion with tail-recursion.

--- Clojure/mastermind.clj
+++ Clojure/mastermind.clj
@@ -91,7 +91,7 @@
                 (println "My guess: " my-guess " scored " my-guess-score)
                 (if (= my-guess solution-code)
                     my-guess
-                    (play-game
+                    (recur
                         all-codes
                         (filter (fn [p] (= (score p my-guess) my-guess-score)) possible-codes)
                         solution-code))))))


pass driver instead of gl

pass driver instead of gl

--- src/gamma_driver/api.cljs
+++ src/gamma_driver/api.cljs
@@ -113,7 +113,7 @@
        :bind-attribute       bind-attribute
        :bind-texture-uniform bind-texture-uniform
        :bind-uniform         bind-uniform}
-      (gdp/gl this) program spec)))
+      this program spec)))

 ;; IDraw


Switched CCW to Clojure 1.5.0

Switched CCW to Clojure 1.5.0

--- ccw.core/project.clj
+++ ccw.core/project.clj
@@ -2,11 +2,11 @@
   :description "Counterclockwise"
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
-  :dependencies [[org.clojure/clojure "1.5.0-RC6"]
+  :dependencies [[org.clojure/clojure "1.5.0"]
                  [org.clojure/clojure-contrib "1.2.0"]
                  [leiningen-core "2.0.0"]
                  [org.clojure/tools.nrepl "0.2.1"]
                  [org.clojure/core.incubator "0.1.0"]
                  [com.cemerick/drawbridge "0.0.6"]]
   :source-paths []
-  :plugins [[ccw/lein-ccw-deps "0.1.0"]])+  :plugins [[ccw/lein-ccw-deps "0.1.0"]])


poor merge-conflict fix corrected

poor merge-conflict fix corrected

--- src/crawler/dom.clj
+++ src/crawler/dom.clj
@@ -461,4 +461,3 @@
        (merge-with concat acc {(first v) [(second v)]}))
      {}
      xpath-nodes)))
->>>>>>> xpath_position_info


Split run-requests-constantly into two separate implementations.

One for fixed number of requests and one for fixed duration

--- src/clj_gatling/simulation.clj
+++ src/clj_gatling/simulation.clj
@@ -3,20 +3,6 @@
             [clj-time.core :as time]
             [clj-time.local :as local-time]
             [clojure.core.async :as async :refer [go go-loop put! <!! alts! <! >!]]))
-
-(defprotocol RunnerProtocol
-  (continue-run? [runner current-time i])
-  (runner-info [runner]))
-
-(deftype DurationRunner [duration]
-  RunnerProtocol
-  (continue-run? [_ start _] (time/before? (local-time/local-now) (time/plus start duration)))
-  (runner-info [_] (str "duration " duration)))
-
-(deftype FixedRequestNumberRunner [requests]
-  RunnerProtocol
-  (continue-run? [_ _ i] (< i requests))
-  (runner-info [_] (str "requests " requests)))

 (defn- now [] (System/currentTimeMillis))

@@ -24,9 +10,6 @@
   (if-let [url (:http request)]
     (partial http/async-http-request url)
     (:fn request)))
-
-(defn- request-result [id request-name success start]
-  {:id id :name request-name :result success :start start :end (now)})

 (defn async-function-with-timeout [request timeout user-id context result-channel]
   (let [start    (now)
@@ -67,17 +50,42 @@
    :end (:end (last result))
    :requests result})

-(defn- run-requests-constantly [runner cs timeout scenario scenario-start concurrency]
-  (let [requests (:requests scenario)
-        results (async/chan)]
-    (go-loop [^long i 0]
-      (let [[result c] (alts! cs)]
-        (when (continue-run? runner scenario-start (+ i concurrency))
-          (run-requests requests timeout (+ i concurrency) c))
-        (>! results (response->result scenario result))
-        (when (continue-run? runner scenario-start i)
-          (recur (inc i)))))
-    results))
+(defprotocol RunnerProtocol
+  (run-requests-constantly [runner cs timeout scenario scenario-start concurrency])
+  (runner-info [runner]))
+
+(deftype DurationRunner [duration]
+  RunnerProtocol
+  (run-requests-constantly [_ cs timeout scenario scenario-start concurrency]
+    (let [results (async/chan)
+          continue-run? #(time/before? (local-time/local-now) (time/plus scenario-start duration))]
+      (go-loop [^long i 0]
+        (let [[result c] (alts! cs)]
+          (when (continue-run?)
+            (run-requests (:requests scenario) timeout (+ i concurrency) c))
+          (>! results (response->result scenario result))
+          (when (continue-run?)
+            (recur (inc i)))))
+      results))
+  (runner-info [_] (str "duration " duration)))
+
+(deftype FixedRequestNumberRunner [^long number-of-requests]
+  RunnerProtocol
+  (run-requests-constantly [_ cs timeout scenario scenario-start concurrency]
+    (let [results (async/chan)]
+      (go-loop [^long i 0]
+        (let [[result c] (alts! cs)]
+          (when (< (+ i concurrency) number-of-requests)
+            (run-requests (:requests scenario) timeout (+ i concurrency) c))
+          (>! results (response->result scenario result))
+          (when (< i number-of-requests)
+            (recur (inc i)))))
+      results))
+  (runner-info [_] (str "requests " number-of-requests)))
+
+
+(defn- request-result [id request-name success start]
+  {:id id :name request-name :result success :start start :end (now)})

 (defn run-scenario [runner concurrency number-of-requests timeout scenario]
   (println (str "Running scenario " (:name scenario) " with " concurrency " concurrency and


Add the site tag to the img api call

Add the site tag to the img api call

--- src/cljs/comic_reader/api.cljs
+++ src/cljs/comic_reader/api.cljs
@@ -27,10 +27,11 @@
        :error-handler error-handler
        :response-format :edn}))

-(defn get-img-tag [page-url]
+(defn get-img-tag [site page-url]
   (POST "/api/v1/img"
       {:format :edn
-       :params {:url page-url}
+       :params {:site site
+                :url page-url}
        :handler #(dispatch [:next-image %])
        :error-handler error-handler
        :response-format :edn}))


remove "\n   " in from strings"

remove "\n   " in from strings"

--- src/cljs/html2hiccup/core.cljs
+++ src/cljs/html2hiccup/core.cljs
@@ -41,8 +41,11 @@
       str
       ;; remove outer parens ()
       (string/replace-first #"^\((.*)\)" "$1")
-      ;; remove weird "\n    "
+      ;; remove trailing "\n    "
       (string/replace #"\"(\s*\\n\s*(\w)*)*\"" "$2")
+      ;; remove in string "\n    "
+      (string/replace #"\"(\\n\s*)" "\"")
+      (string/replace #"(\\n\s*)\"" "\"")
       ;; start every opening [ on new line
       (string/replace #"\[" "\n[")
       ;; remove empty {}


Now supporting Clojure data structures outside Mithril

--- src/cljs/modern_cljs/core.cljs
+++ src/cljs/modern_cljs/core.cljs
@@ -3,17 +3,18 @@
   (:require [foo.bar] [m]))

 (def db
-  (js-obj "var" (str "tosi: " (rand-int 10))))
+  {:var (str "tosi:" (rand-int 10))})

 (defn ^:export ctrl []
   (println "Calling major Tom"))
-(defn ^:export viewer [arg]
+(defn ^:export viewer [c]
   (println "Seeing things")
-  (js/m "div" (.-var db)))
-(def app (js-obj "controller" ctrl "view" viewer))
+  (js/m "div" (.-var (clj->js db))))

-(defn ^:export updatedb [arg]
-  (set! (.-var db) arg)
+(def app {:controller ctrl :view viewer})
+
+(defn ^:export updatedb [fields value]
+  (set! db (assoc-in db fields value))
   (.redraw js/m true))

 (enable-console-print!)
@@ -21,4 +22,5 @@
 (js/foo)
 (.mount js/m
   (.getElementById js/document "app")
-  app)
+  (clj->js app))
+


fix get-latest-repo-tag to work regardless of current branch

--- src/cljs_api_gen/repo_cljs.clj
+++ src/cljs_api_gen/repo_cljs.clj
@@ -33,7 +33,7 @@

 (defn get-latest-repo-tag
   [repo]
-  (trim (:out (sh "git" "describe" "--abbrev=0" "--tags" :dir (str repo-dir "/" repo)))))
+  (trim (:out (sh "git" "describe" "--abbrev=0" "--tags" "master" :dir (str repo-dir "/" repo)))))

 (defn clj-tag->version
   [tag]


Work more on removing clisk from worldgen

--- src/cljx/robinson/worldgen.clj
+++ src/cljx/robinson/worldgen.clj
@@ -81,7 +81,61 @@
 (defn vectorize
   [& more]
   (vec more))
-
+
+(defn vsnoise
+  [noise]
+  (fn [[x y]]
+    (vectorize (snoise noise x y) (snoise noise (+ x 12.301) (+ y 70.261)))))
+
+(defn vnoise
+  [noise]
+  (fn [[x y]]
+    (vectorize (noise noise x y) (noise noise (+ x -78.678) (+ y 7.6789)))))
+
+(defn v+
+  [xy-or-fn-0 xy-or-fn-1]
+  (case
+    (and (vector xy-or-fn-0)
+         (vector xy-or-fn-1))
+      (mapv + xy-or-fn-0 xy-or-fn-1)
+    (and (vector? xy-or-fn-0)
+         (fn? xy-or-fn-1))
+      (fn [[xi yi]]
+        (let [[x0 y0] xy-or-fn-0
+              [x1 x1] (xy-or-fn-1 xi yi)]
+          [(+ x0 x1) (+ y0 y1)]))
+    (and (fn? xy-or-fn-0)
+         (vector? xy-or-fn-1))
+      (fn [[xi yi]]
+        (let [[x0 y0] (xy-or-fn-0 xi yi)
+              [x1 x1] xy-or-fn-1]
+          [(+ x0 x1) (+ y0 y1)]))
+    (and (fn? xy-or-fn-0)
+         (fn? xy-or-fn-1))
+      (fn [[xi yi]]
+        (let [[x0 y0] (xy-or-fn-0 xi yi)
+              [x1 x1] (xy-or-fn-1 xi yi)]
+          [(+ x0 x1) (+ y0 y1)]))))
+
+(defn v*
+  [s xy-or-f]
+  (case
+    (vector? xy-or-f)
+      (let [[x y] xy-or-f]
+        [(* s x) (* s y)])
+    (fn? f)
+      (fn [[xi yi]]
+        [(* s xi) (* s yi)])))
+
+(defn v-
+  [xy-or-fn-0 xy-or-fn-1]
+  (case
+    (and (vector xy-or-fn-0)
+         (vector xy-or-fn-1))
+      (mapv - xy-or-fn-0 xy-or-fn-1)
+    :else
+      (v+ xy-or-fn-0 (v* -1 xy-or-fn-1))))
+

 (defn init-ocean
   []
@@ -144,10 +198,11 @@
     surf         :surf
     ocean        :ocean))

-(def tree-node
-  (cliskf/vectorize (cliskf/offset [-0.5 -0.5] (cliskf/v+ [-0.5 -0.5 -0.5] (cliskf/scale 0.01 cliskp/noise)))))
-
-(def island-node
+(defn sample-tree
+  (offset [-0.5 -0.5] (v+ [-0.5 -0.5 -0.5] (scale 0.01 noise))))
+
+(defn sample-island
+  [noise]
   (cliskf/vectorize
     (cliskf/vlet [c  (center (invert (cliskf/offset (cliskf/scale 0.43 (cliskf/v* [0.5 0.5 0.5] cliskp/vsnoise)) cliskf/radius)))
                   c1 (cliskf/offset [0.5 0.5] (cliskf/v+ [-0.5 -0.5 -0.5] (cliskf/scale 0.06 cliskp/noise)))


Isolate side effects so this can be tested.

--- src/clj/freestuffly/scraper.clj
+++ src/clj/freestuffly/scraper.clj
@@ -28,8 +28,8 @@
        "&showall=off&include_offers=off&include_wanteds=off&include_receiveds=off&include_takens=off"))

 (defn- site-tree
-  []
-  (-> (client/get my-group-urls) :body h/parse h/as-hickory))
+  [scraped-html]
+  (h/as-hickory (h/parse scraped-html)))

 (defn- parsed-html
   [html]
@@ -56,5 +56,9 @@
                     (map vals results))))

 (defn scraped-content
-  ([] (scraped-content site-tree))
-  ([content-hash] (presentable (interesting-finds (content-for (parsed-html (content-hash)))))))
+  ([] (scraped-content (:body (client/get my-group-urls))))
+  ([scraped-html] (presentable
+                    (interesting-finds
+                      (content-for
+                        (parsed-html
+                          (site-tree scraped-html)))))))


Use idiomatic (seq) over (not (empty?))

Use idiomatic (seq) over (not (empty?))

--- src/clj/ji/service/game_env.clj
+++ src/clj/ji/service/game_env.clj
@@ -39,7 +39,7 @@
   until at least 1 set exists on board"
   [game]
   (loop [game game]
-    (if (and (not (empty? (:deck game)))
+    (if (and (seq (:deck game))
              (empty? (game/solve-board (:board game))))
       (recur (game/draw-cards 3 game))
       game)))


Add multiple outputs to worldgen -main

Add multiple outputs to worldgen -main

--- src/cljc/robinson/worldgen.cljc
+++ src/cljc/robinson/worldgen.cljc
@@ -541,18 +541,52 @@
 (defn -main [& args]
   (let [width   400
         height  400
-        seed    0
+        seed    1
         n       (rn/create-noise (rr/create-random seed))
         samples (for [y (range (- height) height 2)
                       x (range (- width) width 2)]
-                  [(+ x width) (+ y height) 2 2 (biome->color (sample-island n x y))])]
-    (letfn [(draw  [] (doseq [[x y w h c] samples]
-                        (q/fill (apply q/color c))
+                  [(+ x width) (+ y height) 2 2 (sample-island n x y)])]
+    #_(letfn [(draw  [] (doseq [[x y w h b] samples]
+                        (q/fill (apply q/color (biome->color
+                                                 (case b
+                                                   :ocean :ocean
+                                                   :surf :ocean
+                                                   :sand))))
                         (q/rect x y w h)))
             (setup [] (q/frame-rate 1)
+                      (q/no-stroke)
                       (q/background 0 0 0))]
       (quil.applet/applet
-                   :title "Show World"
+                   :title "Ocean/Sand"
+                   :renderer :p2d
+                   :setup setup
+                   :draw draw
+                   :size [(* 2 width) (* 2 height)]))
+    (letfn [(draw  [] (doseq [[x y w h b] samples]
+                        (q/fill (apply q/color (biome->color
+                                                 (case b
+                                                   :ocean :ocean
+                                                   :sand :sand
+                                                   :surf :surf
+                                                   :dirt))))
+                        (q/rect x y w h)))
+            (setup [] (q/frame-rate 1)
+                      (q/no-stroke)
+                      (q/background 0 0 0))]
+      (quil.applet/applet
+                   :title "Ocean/Surf/Sand/Interior"
+                   :renderer :p2d
+                   :setup setup
+                   :draw draw
+                   :size [(* 2 width) (* 2 height)]))
+    #_(letfn [(draw  [] (doseq [[x y w h b] samples]
+                        (q/fill (apply q/color (biome->color b)))
+                        (q/rect x y w h)))
+            (setup [] (q/frame-rate 1)
+                      (q/no-stroke)
+                      (q/background 0 0 0))]
+      (quil.applet/applet
+                   :title "Ocean/Surf/Sand/Interior"
                    :renderer :p2d
                    :setup setup
                    :draw draw


Enable sharing of short url via twitter

Enable sharing of short url via twitter

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

--- src/cljs/cljs_nusmods/main.cljs
+++ src/cljs/cljs_nusmods/main.cljs
@@ -431,7 +431,9 @@
                        (str "mailto:?"
                             "subject=My%20cljs-nusmods%20timetable&body="
                             "&body=" (js/encodeURI shortUrl)))
-        :twitter nil
+        :twitter (.open js/window
+                        (str "https://twitter.com/intent/tweet?url="
+                             (js/encodeURI shortUrl)))
         nil      nil))

 (defn- make-request-to-get-short-url
@@ -531,6 +533,7 @@
         zcbClient           (ZeroClipboard. $copy-to-clipboard)
         $urlShortenerInput  ($ :#url-shortener)
         $share-by-email     ($ :#share-by-email)
+        $share-on-twitter   ($ :#share-on-twitter)
         get-url-evt-handler (get-short-url-jq-evt-handler-maker
                               $urlShortenerInput localStorage)
         qtipOrgCopyText     "Copy to Clipboard"
@@ -558,7 +561,11 @@
     (.click $share-by-email
             (get-short-url-jq-evt-handler-maker $urlShortenerInput
                                                 localStorage
-                                                :email))))
+                                                :email))
+    (.click $share-on-twitter
+            (get-short-url-jq-evt-handler-maker $urlShortenerInput
+                                                localStorage
+                                                :twitter))))

 ; Main entry point of the program
 (defn ^:export init [acad-year sem]


Fixing bug: if the key of a task is the task, there is no refresh issues

--- src/cljs/clojure_rest/core.cljs
+++ src/cljs/clojure_rest/core.cljs
@@ -24,6 +24,13 @@
     :bug-fix "#BD8D31"
     :enhancement "#3A7E28"
     :else "#eee"))
+
+(defn card-side-color
+  "Render the ribbon on the left of the card, that indicates its category"
+  [card]
+  {:position "absolute" :zindex -1 :top 0 :bottom 0 :left 0 :width 5
+   :backgroundColor (-> card :category category->color)
+  })

 (defn filter-by-status
   [status cards]
@@ -78,17 +85,9 @@
    [:ul
     (map
       (fn [idx t]
-        [render-task #(update-card! (api/remove-task-at card idx)) t])
+        ^{:key t} [render-task #(update-card! (api/remove-task-at card idx)) t])
       (range) tasks)
-    ]
-   ])
-
-(defn card-side-color
-  "Render the ribbon on the left of the card, that indicates its category"
-  [card]
-  {:position "absolute" :zindex -1 :top 0 :bottom 0 :left 0 :width 5
-   :backgroundColor (-> card :category category->color)
-  })
+    ]])

 (defn render-add-task
   "Render the text field allowing to add new tasks to a card"
@@ -146,7 +145,7 @@
      :value (:filter @app-state)
      :on-change #(update-filter! (.. % -target -value))}]
    [render-board @card-list]
-   ])
+  ])

 (def fetch-and-render-app
   "Render the app - adding a fetching of data when the DOM is mounted"


Store both the literal text and the result.

--- src/cljs/leipzig_live/core.cljs
+++ src/cljs/leipzig_live/core.cljs
@@ -8,7 +8,8 @@
 ;; -------------------------
 ;; Model
 (defonce state
-  (atom {:music ""
+  (atom {:music nil
+         :text ""
          :playing nil}))

 ;; -------------------------
@@ -29,11 +30,11 @@
       #(:value %)))

 (defonce context (js/window.AudioContext.))
-(defn beep []
+(defn beep [freq]
   (let [oscillator (.createOscillator context)]
     (doto oscillator
       (.connect (.-destination context))
-      (-> .-frequency .-value (set! 440))
+      (-> .-frequency .-value (set! freq))
       (-> .-type (set! "square"))
       (.start 0))
     (swap! state assoc-in [:playing] oscillator)))
@@ -43,12 +44,14 @@
   (swap! state assoc-in [:playing] nil))

 (defn handle [expr-str]
-  (swap! state assoc-in [:music] expr-str))
+  (swap! state assoc-in [:text] expr-str)
+  (when-let [value (evaluate expr-str)]
+    (swap! state assoc-in [:music] value)))

 (defn toggle []
   (if (:playing @state)
     (kill)
-    (beep)))
+    (beep (:music @state))))

 ;; -------------------------
 ;; Views
@@ -56,11 +59,11 @@
 (defn home-page []
   [:div [:h1 "Welcome to Leipzig Live!"]
    [:div [:input {:type "text"
-                  :value (-> state deref :music print-str)
+                  :value (:text @state)
                   :on-change #(-> % .-target .-value handle)}]
     [:button {:on-click toggle} "Start/stop"]]
    [:div
-    (evaluate (-> @state :music))]])
+    (:music @state)]])

 (defn current-page []
   [:div [(session/get :current-page)]])


Dont't show add new profile btn if not editable.

--- src-cljs/kixi/hecuba/tabs/hierarchy/profiles.cljs
+++ src-cljs/kixi/hecuba/tabs/hierarchy/profiles.cljs
@@ -942,7 +942,7 @@
          [:div
           [:h3 "Profiles"]
           [:div [:button {:type "button"
-                          :class "btn btn-primary"
+                          :class (str "btn btn-primary " (if editable "" "hidden"))
                           :onClick (fn [_]  (set! (.-location js/window) (str "/profile/" selected-property-id)))}
                  "Add new profile"]]
           [:div {:id "alert"} (om/build bs/alert (-> data :profiles :alert))]


Small optimization in «stem-base-from-base»

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

--- src/conexp/fca/implications.clj
+++ src/conexp/fca/implications.clj
@@ -283,22 +283,21 @@
   "For a given set of implications returns its stem-base."
   [implications]
   (loop [stem-base    #{},
-         implications (pmap #(make-implication (premise %)
-                                               (close-under-implications implications
-                                                                         (into (premise %) (conclusion %))))
-                            implications),
+         implications implications,
          all          (vec implications)]
     (if (empty? implications)
       stem-base
       (let [A->B         (first implications),
             implications (rest implications),
             all          (subvec all 1)
-            A*           (close-under-implications all (premise A->B)),
-            A*->B        (make-implication A* (conclusion A->B))]
-        (if (not-empty (conclusion A*->B))
-          (recur (conj stem-base A*->B)
+            [A* B*]      (let [values (pvalues (close-under-implications all (premise A->B))
+                                               (close-under-implications all (conclusion A->B)))]
+                           [(first values) (second values)]),
+            A*->B*       (make-implication A* B*)]
+        (if (not-empty (conclusion A*->B*))
+          (recur (conj stem-base A*->B*)
                  implications
-                 (conj all A*->B))
+                 (conj all A*->B*))
           (recur stem-base
                  implications
                  all))))))


Use unicode symbol for implicational arrow

Experimental: symbol might be too small (note that this is actually LONG
RIGHTWARDS ARROW).

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

--- src/conexp/fca/implications.clj
+++ src/conexp/fca/implications.clj
@@ -22,7 +22,7 @@
   (hashCode [this]
     (hash-combine-hash Implication premise conclusion))
   (toString [this]
-    (str "(" premise "  ==>  " conclusion ")")))
+    (str "(" premise " ⟶ " conclusion ")")))

 (defmulti premise
   "Returns premise of given object."


Define wrap-serve and reorder wrap-main middlewares so exit is last.

--- src/incise/core.clj
+++ src/incise/core.clj
@@ -59,12 +59,18 @@
       (apply post-func more)
       return-value)))

+(defn wrap-serve
+  [main-func]
+  (-> main-func
+      (wrap-pre conf/avow!)
+      (wrap-pre conf/load)
+      (wrap-log-exceptions :bubble false)))
+
 (defn wrap-main
   [main-func]
   (-> main-func
-      (wrap-pre conf/load)
-      (wrap-post #(System/exit 0))
-      (wrap-log-exceptions :bubble false)))
+      (wrap-serve)
+      (wrap-post #(System/exit 0))))

 (defn -main
   "Based on the given args either deploy, compile or start the development


:bug: Fix "delete" shortcut.

:bug: Fix "delete" shortcut.

--- frontend/src/uxbox/main/data/workspace.cljs
+++ frontend/src/uxbox/main/data/workspace.cljs
@@ -2284,7 +2284,7 @@
    "ctrl+c" #(st/emit! copy-selected)
    "ctrl+v" #(st/emit! paste)
    "esc" #(st/emit! :interrupt deselect-all)
-   "delete" #(st/emit! delete-selected)
+   "del" #(st/emit! delete-selected)
    "ctrl+up" #(st/emit! (vertical-order-selected :up))
    "ctrl+down" #(st/emit! (vertical-order-selected :down))
    "ctrl+shift+up" #(st/emit! (vertical-order-selected :top))


Added support for excel cols reference nested values

--- src/labradoodle/excel.clj
+++ src/labradoodle/excel.clj
@@ -1,17 +1,47 @@
 (ns labradoodle.excel
   (:use [dk.ative.docjure.spreadsheet]))

-; http://stackoverflow.com/questions/1676891/mapping-a-function-on-the-values-of-a-map-in-clojure
+;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+;; Referenced while coding this ns:
+;;  - http://clojure.org/cheatsheet
+;;  - http://siscia.github.io/programming/2014/09/15/create-clojure-map-advanced-methods-part-1/
+;;  - http://stackoverflow.com/questions/1676891/mapping-a-function-on-the-values-of-a-map-in-clojure
+;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+(def columns (array-map :title "Task", :state "Status", [:milestone :title] "Milestone", [:assignee :name] "Assigned To"))
+
 (defn fmap [f m]
+  "Based on corresponding multi-method in https://github.com/clojure/algo.generic"
   (into {} (for [[k v] m] [k (f v)])))

-(defn map-key-comparator [m a b]
-  "Sort order is based on order of keys in map m"
-  (let [idxa (.indexOf (keys m) a)
-        idxb (.indexOf (keys m) b)]
+(defn idx-comparator [v a b]
+  "Sort order is based on order of elements in vector v"
+  (let [idxa (.indexOf v a)
+        idxb (.indexOf v b)]
     ;(println (str "A: " a "->" idxa))
     ;(println (str "B: " b "->" idxb))
     (compare idxa idxb)))
+
+(defn cols->topkeys [cols]
+  (let [ks (keys cols)]
+    (map #(if (vector? %) (first %) %) ks)))
+
+(defn ks->path [ks]
+  "Ensures ks is a vector (since get-in expects vector as first arg)"
+  (if (vector? ks)
+    (rest ks)
+    (vector ks)))
+
+(defn resolve-nested-val [cols [k v :as entry]]
+  "First, identifies key in cols (ie colsk) that corresponds to k. IF v is a map AND colsk is a
+  vector, THEN returns modified entry with value v replaced by nested value (ie nested value
+  that is referenced by colsk path), ELSE returns original entry."
+  (let [topks (cols->topkeys cols)
+        kidx (.indexOf topks k)
+        colk (nth (keys cols) kidx)]
+    (if (map? v)
+      [k (get-in v (ks->path colk) v)]
+      entry)))

 (defn issues->rows [cols issues]
   "Produces rows array, with shape like this:
@@ -19,13 +49,16 @@
    {:name \"Bar Widget\" :price 200}]"
   ; Create rows by transforming  issue objects as follows:
   ; (A) only contain keys from cols map;
-  ; (B) values are all strings
-  ; (C) entries are in same order as cols entries
-  (let [transform-issue (comp
-                          #(into (sorted-map-by (partial map-key-comparator cols)) %)
+  ; (B) resolves nested values for path keys (e.g. replaces milestone object with title if key is [:milestone :title])
+  ; (C) values are all strings
+  ; (D) entries are in same order as cols entries
+  (let [topkeys (cols->topkeys cols)
+        transform-issue (comp
+                          #(into (sorted-map-by (partial idx-comparator topkeys)) %)
                           ;#(into (sorted-map) %)
                           #(fmap str %)
-                          #(select-keys % (keys cols)))
+                          #(map (partial resolve-nested-val cols) %)
+                          #(select-keys % topkeys))
         rows (map transform-issue issues)]
     (println "---------------")
     (clojure.pprint/pprint rows)
@@ -36,7 +69,7 @@
   [[\"Name\" \"Price\"]
    [\"Foo Widget\" 100]
    [\"Bar Widget\" 200]]"
-  (let [cols (array-map :title "Task", :state "Status", :milestone "Milestone")
+  (let [cols columns
         rows (issues->rows cols issues)
         data (into [(vals cols)] (map vals rows)) ]
     (println "---------------")
@@ -45,7 +78,6 @@

 (defn issues->wb [proj issues]
   "Creates a spreadsheet containing data from issues"
-  ;; http://clojure.org/cheatsheet
   (let [sheet-name (str (:name proj) " Issues")
         celldata (issues->celldata issues)
         wb (create-workbook sheet-name celldata)


Move condition to doseq form in uberjar.

--- src/leiningen/uberjar.clj
+++ src/leiningen/uberjar.clj
@@ -18,8 +18,8 @@

 (defn uberjar [project & args]
   (deps project)
-  (doseq [dep (file-seq (file (:root project) "lib"))]
-    (when (.endsWith (.getName dep) ".jar") ;; TODO: move this clause to doseq
-      (println "Unpacking" (.getName dep))
-      (unzip dep *compile-path*)))
+  (doseq [dep (file-seq (file (:root project) "lib"))
+          :when (.endsWith (.getName dep) ".jar")]
+    (println "Unpacking" (.getName dep))
+    (unzip dep *compile-path*))
   (jar project))


[scamp] revise some comments

[scamp] revise some comments

--- modules/scamp/src/scamp/core.clj
+++ modules/scamp/src/scamp/core.clj
@@ -225,6 +225,8 @@
     coll
     (conj coll new-node-contact-address)))

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; receive-msg
 (defmulti receive-msg
   (fn [msg-type & _] msg-type))

@@ -241,9 +243,12 @@
            :args args))))

 (s/defmethod receive-msg :new-subscription :- CommUpdateSchema
-  #_"Forward the 'subscription to every :downstream node, duplicating
-  the forwarded 'subscription to :connection-redundancy :downstream
-  nodes. If :downstream is empty, do nothing."
+  #_"Add 'subscription to :upstream.
+     Then Forward the 'subscription to every :downstream node,
+     duplicating the forwarded 'subscription to :connection-redundancy
+     :downstream nodes. If :downstream is empty, do no forwarding.
+
+  2.2.1 Subscription: Algorithm 1"
   [_message-type :- MessageTypesSchema
    {:keys [logging connection-redundancy]}
    {:keys [downstream] :as node} :- NetworkedNodeSchema
@@ -531,7 +536,7 @@
 (s/defmethod receive-msg :node-removal :- CommUpdateSchema
   #_"Take 'config, a 'node, and the contact address of a
   'node-to-remove. Remove 'node-to-remove from :upstream and
-  :downstream, and return 'node.
+  :downstream.

   Return a vector matching 'CommUpdateSchema."
   [_message-type :- MessageTypesSchema


thread count

thread count

--- src/clj/morpheus/integration/sources/wikidata.clj
+++ src/clj/morpheus/integration/sources/wikidata.clj
@@ -140,7 +140,7 @@
 (defn import-entities [dump-path lang]
   (println "Import Vertices")
   (let [lang (keyword lang)
-        th-pool (cp/threadpool (/ (cp/ncpus) 2))]
+        th-pool (cp/threadpool (cp/ncpus))]
     (with-open [rdr (clojure.java.io/reader dump-path)]
       (cp/pdoseq
         th-pool [line (line-seq rdr)]
@@ -188,7 +188,7 @@
 (defn import-links [dump-path]
   (println "Import Edges")
   (with-open [rdr (clojure.java.io/reader dump-path)]
-    (let [th-parse-pool (cp/threadpool (/ (cp/ncpus) 2))]
+    (let [th-parse-pool (cp/threadpool (cp/ncpus))]
       (cp/pdoseq
         th-parse-pool [line (line-seq rdr)]
         (try


basic moving completed TODO: update-string map to signify a capture

--- src/quick_chess/core.cljs
+++ src/quick_chess/core.cljs
@@ -79,9 +79,9 @@
         :black init-black-bindings}
        :turn :white}))

-(defonce black #{\u265F \u265C \u265E \u265D \u265B \u265A})
-
-(defonce white #{\u2659 \u2656 \u2658 \u2657 \u2655 \u2654})
+(defonce black? #{\u265F \u265C \u265E \u265D \u265B \u265A})
+
+(defonce white? #{\u2659 \u2656 \u2658 \u2657 \u2655 \u2654})

 (defonce app-state (r/atom init-state))
 #_(swap! app-state assoc :height 500)
@@ -125,16 +125,13 @@
                (min (:height data) (:width data))
                0.03)})

-;;--------------------------------------------------------
-;;--REAGENT/REACT COMPONENTS AND HELPER FUNCTIONS TO THOSE
-(defn slider-view
-  "adjusts the size of the board"
-  [state]
-  [:input {:type "range" :value (:width state) :min 250 :max 700
-           :style {:width "200px"}
-           :on-change (fn [e]
-                        (let [val (js/parseInt (.-target.value e))]
-                          (swap! app-state assoc :width val :height val)))}])
+;;---------------------------------------------------
+;;--NORMAL HELPER FUNCTIONS TO HELP COMPUTE THE STATE
+(defn color-of-piece
+  [board [row col]]
+  (if (black? (get-in board [row col :piece]))
+    :black
+    :white))

 (defn out-of-board?
   "returns all possible locations for a given piece
@@ -181,10 +178,31 @@
      state
      positions)))

+(defn move
+  [[from-row from-col] [to-row to-col]]
+  (fn [state]
+    (let [from-map (get-in state
+                           [:board from-row from-col])]
+      ((comp
+         #(update-in % [:board from-row from-col]
+                     assoc
+                     :text ""
+                     :piece "")
+         #(update-in % [:board to-row to-col]
+                     assoc
+                     :text (:text from-map)
+                     :piece (:piece from-map)))
+       state))))
+
+(defn update-string-map
+  [str pos]
+  (fn [state]
+    (assoc-in state [:string-map (:turn state) str] pos)))
+
 (defn handle-deselection
-  [[row col :as pos] positions]
+  [pos positions]
   (comp
-   (change-color pos (get-in init-colors [row col]))
+   (change-color pos (get-in init-colors pos))
    (positions-to-default-color positions)))

 ;;can almost certainly be abstracted more
@@ -198,66 +216,105 @@
    (change-color pos highlight-color)))

 (defn deselect-piece
-  "changes the board it its normal no-piece selected
-  state were the board colors are default"
-  [state text-state old positions]
-  (let [[row col :as pos]
-        (get-in
-         state
-         [:string-map (:turn state) old])
-        color (get-in init-colors [row col])
-        pos-colors (map
-                    (fn [[row col]]
-                      (get-in
-                       state
-                       [:board row col :color]))
-                    positions)]
+  "changes the board to normal where no-piece is
+  selected state were the board colors are default"
+  [state text-state positions]
+  (let [pos (get-in
+             state
+             [:string-map (:turn state) (:piece-str @text-state)])]
     (swap! app-state (handle-deselection pos positions))
-    (swap! text-state assoc :move-to {})))
+    (swap! text-state assoc
+           :move-to {}
+           :piece-str "")))

 (defn deselected?
   "returns true if the input signifies the user deselected a piece"
-  [state old new]
+  [state {:keys [piece-str]} new]
   (and
    (get-in state
-           [:string-map (:turn state) old])
-   (> (count old) (count new))))
+           [:string-map (:turn state) piece-str])
+   (> (count piece-str) (count new))))

 (defn select-piece
-  [state text-state [row col :as pos]]
+  [{:keys [turn]} text-state pos str]
   (swap! text-state
-         assoc :move-to (zipmap
-                         default-keybindings
-                         (vec (possible-placements pos (:turn state)))))
-  (swap! app-state (handle-selection pos (:turn state))))
+         assoc
+         :move-to (zipmap
+                   default-keybindings
+                   (vec (possible-placements pos turn)))
+         :piece-str str)
+  (swap! app-state (handle-selection pos turn)))
+
+(defn handle-move
+  "deselects the pieces, and moves the piece"
+  [state text-state positions]
+  (let [{:keys [move-to piece-str text]} @text-state
+        from-pos (get-in
+                  state
+                  [:string-map (:turn state) piece-str])
+        to-pos (get move-to
+                    (apply str
+                           (drop
+                            (count piece-str)
+                            text)))]
+    (swap! app-state
+           (comp
+            (update-string-map piece-str to-pos)
+            (move from-pos to-pos)
+            (handle-deselection from-pos positions)))
+    (swap! text-state assoc
+           :move-to {}
+           :piece-str "")))
+
+(defn move-command?
+  [{:keys [piece-str move-to text]}]
+  (and
+   (not (empty? piece-str))
+   (get move-to
+           (apply str
+                  (drop
+                   (count piece-str)
+                   text)))))

 (defn handle-text-input
   "handles the text input given an event"
-  [state text-state]
+  [text-state]
   (fn [e]
     (let [str (-> e .-target .-value)
-          old (:text @text-state)
-          piece (get-in
-                 state
-                 [:string-map (:turn state) str])]
+          state @app-state
+          piece-pos (get-in
+                     state
+                     [:string-map (:turn state) str])
+          positions (vals (:move-to @text-state))]
       (swap! text-state assoc :text str)
       (cond
-        piece (select-piece state text-state piece)
-        (deselected? state old str) (deselect-piece
-                                     state
-                                     text-state
-                                     old
-                                     (vals (:move-to @text-state)))))))
+        (move-command? @text-state) (handle-move state text-state positions)
+        piece-pos (select-piece state text-state piece-pos str)
+        (deselected? state @text-state str) (deselect-piece
+                                             state
+                                             text-state
+                                             (vals (:move-to @text-state)))))))
+;;-----------------------
+;;--REAGENT/REACT COMPONENTS
+(defn slider-view
+  "adjusts the size of the board"
+  []
+  [:input {:type "range" :value (:width @app-state) :min 250 :max 700
+           :style {:width "200px"}
+           :on-change (fn [e]
+                        (let [val (js/parseInt (.-target.value e))]
+                          (swap! app-state assoc :width val :height val)))}])

 (defn input-view
   "input of commands through strings"
   []
   (let [text-state (r/atom {:text ""
-                            :move-to {}})]
-    (fn [state]
+                            :move-to {}
+                            :piece-str ""})]
+    (fn []
       [:input {:type "text"
                :value (:text @text-state)
-               :on-change (handle-text-input state text-state)}])))
+               :on-change (handle-text-input text-state)}])))

 (defn cell-view
   [state row-idx]
@@ -286,13 +343,12 @@
   []
   [:div
    [:div "Size:"]
-   [slider-view @app-state]
+   [slider-view]
    [board-view @app-state]
-   [input-view @app-state]])
-
-;; -------------------------
-;; Initialize app
-
+   [input-view]])
+
+;; --------------------
+;; --INITIALIZE THE APP
 (defn mount-root []
   (r/render [app-view] (.getElementById js/document "app")))


limit memory tiles to 300 tiles

limit memory tiles to 300 tiles

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

--- plugins/SlideExplorer2/src/slide_explorer/main.clj
+++ plugins/SlideExplorer2/src/slide_explorer/main.clj
@@ -261,7 +261,8 @@
               (disk/load-tile memory-tile-atom tile))
             (do
               ;(println "no")
-              (disk/unload-tile memory-tile-atom tile))))))
+              ;(disk/unload-tile memory-tile-atom tile)
+              )))))

 (defn load-visible-only
   "Runs visible-loader whenever screen-state-atom changes."
@@ -303,7 +304,7 @@
     (def dti disk-tile-index)
     (def ai acquired-images)
     (swap! ss assoc :channels (initial-lut-objects first-seq))
-    ;(evict-oldest memory-tiles 300)
+    (evict-oldest memory-tiles 300)
     (record-added-tiles memory-tiles disk-tile-index)
     (load-visible-only screen-state memory-tiles disk-tile-index)
     (explore-fn)


use :rename

use :rename

--- src/hackerrank/clojure_libs.clj
+++ src/hackerrank/clojure_libs.clj
@@ -54,7 +54,12 @@
 ;; use only function we needed

 ;; use exclude
-(use '[clojure.string :exclude [replace reverse]])
-(split "a,b,c" #",")
+;; (use '[clojure.string :exclude [replace reverse]])
+;; (split "a,b,c" #",")
 ;; eliminates shadowing of name colissions
 ;; best: use only with :only
+
+;; use rename
+(use '[clojure.string :rename {replace str-replace, reverse str-reverse}])
+(str-reverse "foobar")
+(reverse "foobar")


Remove code no longer needed now that we directly serialize tf-idf-data.

--- project/analyze-data/src/analyze_data/find_knn.clj
+++ project/analyze-data/src/analyze_data/find_knn.clj
@@ -1,35 +1,7 @@
 (ns analyze-data.find-knn
   (:require [clojure.core.matrix :as m]
-            [clojure.edn :as edn]
-            [clojure.java.io :as io]
             [analyze-data.knn.core :refer [cosine-distance knn]]
-            [analyze-data.tf-idf.core :refer [tf-idf-document to-terms]]
-            [analyze-data.gzip :refer [gzip-reader]])
-  (:import java.io.PushbackReader))
-
-(defn read-edn-stream
-  "Return a lazy sequence of (transform-fn item) for each item parsed from a
-  stream of edn objects. transform-fn defaults to identity. reader must be a
-  java.io.PushbackReader or some derivee. Since it is lazy, the stream must
-  remain open while new items are being requested."
-  ([reader] (read-edn-stream reader identity))
-  ([reader transform-fn]
-    (lazy-seq
-      (when-let [line (edn/read {:eof nil} reader)]
-        (cons (transform-fn line) (read-edn-stream reader transform-fn))))))
-
-(defn read-tf-idf-data
-  "Given the path to a file of gzipped tf-idf data as produced by
-  analyze-data.corpus-to-tf-idf/csv-corpus-to-tf-idf-data!, read into a map
-  with :all-terms, :idf, :document-names, and :data keys."
-  [file-path]
-  (with-open [file-reader (-> file-path
-                              gzip-reader
-                              PushbackReader.)]
-    {:all-terms (edn/read file-reader)
-     :idf (edn/read file-reader)
-     :document-names (edn/read file-reader)
-     :data (m/sparse-matrix (read-edn-stream file-reader m/sparse-array))}))
+            [analyze-data.tf-idf.core :refer [tf-idf-document to-terms]]))

 (defn knn-named-result
   "Transform [index value] into [document-name value]."
@@ -51,7 +23,7 @@
   "Find 3 nearest neighbors (per cosine-distance) to query-document in
   tf-idf-data.

-  tf-idf-data: map produced by read-tf-idf-data
+  tf-idf-data: map produced by corpus-to-tf-idf-data
   query-document: string

   Return sequence of the form