XML is now streaming

XML is now streaming

--- src/cfpb/qu/views.clj
+++ src/cfpb/qu/views.clj
@@ -11,6 +11,7 @@
    [stencil.core :refer [render-file]]
    [noir.response :as response]
    [clojure.data.csv :as csv]
+   [clojure.data.xml :as xml]
    monger.json
    [halresource.resource :as hal]
    [cfpb.qu.project :refer [project]]
@@ -31,6 +32,8 @@

 ;; Allow for encoding of UrlLike's in JSON.
 (add-encoder UrlLike encode-str)
+
+(def ^:dynamic *stream-size* *stream-size*)

 (def footer-info {:qu_version (:version project)
                   :build_number (:build-number project)
@@ -362,37 +365,29 @@
                      false)
               (recur (drop size rows)))))))))

-(defn slurp-binary
-  "Reads len bytes from InputStream is and returns a byte array."
-  [^java.io.InputStream is len]
-  (with-open [rdr is]
-    (let [buf (byte-array len)]
-      (.read rdr buf)
-      buf)))
-
 (defn send-stream
   [request response ^java.io.InputStream is len]
-  (let [buf (byte-array len)]
-    (with-open [reader is]
+  (let [buf (char-array len)]
+    (with-open [is (io/reader is)]
       (with-channel request channel
         (on-close channel #(log/info "Channel closed:" %))
         (loop [n (.read is buf)]
-          (let [string (apply str (map char (take n buf)))]
+          (let [string (apply str (take n buf))]
             (send! channel (assoc response :body string) false)
-            (if (> n 0)
-              (recur (.read is buf))
-              (close channel))))
+            (when-not (= n -1)
+              (recur (.read is buf)))))
         (close channel)))))

 (defmethod slice-query "application/json" [_ resource {:keys [request]}]
   (let [resource (hal/json-representation resource)
         response (response/content-type "text/json; charset=utf-8" {})
-        in (PipedInputStream.)]
+        in (PipedInputStream. *stream-size*)
+        out (PipedOutputStream. in)]
     (future
-      (with-open [out (PipedOutputStream. in)]
-        (json/generate-stream resource (io/writer out))))
-    (send-stream request response in 1024)
-    (ring-response {})))
+      (with-open [out (io/writer out)]
+        (json/generate-stream resource out)))
+    (send-stream request response in *stream-size*)
+    (ring-response response)))

 (defmethod slice-query "text/javascript" [_ resource {:keys [callback]}]
   (let [callback (if (str/blank? callback) "callback" callback)]
@@ -400,8 +395,18 @@
          (hal/resource->representation resource :json)
          ");")))

-(defmethod slice-query "application/xml" [_ resource _]
-  (hal/resource->representation resource :xml))
+(defmethod slice-query "application/xml" [_ resource {:keys [request]}]
+  (let [resource (hal/xml-representation resource)
+        response (response/content-type "application/xml; charset=utf-8" {})
+        in (PipedInputStream. *stream-size*)
+        out (PipedOutputStream. in)]
+    (future
+      (with-open [out (io/writer out)]
+        (xml/emit (xml/sexp-as-element resource)
+                  out
+                  :encoding "UTF-8")))
+    (send-stream request response in *stream-size*)
+    (ring-response response)))

 (defmethod slice-query :default [format _ _]
   (format-not-found format))


binding (won't work well until I fix finally...)

--- src/clj/cljs/core.clj
+++ src/clj/cljs/core.clj
@@ -155,3 +155,28 @@
        `(when-not ~x
           (throw (cljs.core/str
                    "Assert failed: " ~message "\n" (cljs.core/pr-str '~x)))))))
+
+(defmacro binding
+  "binding => var-symbol init-expr
+
+  Creates new bindings for the (already-existing) vars, with the
+  supplied initial values, executes the exprs in an implicit do, then
+  re-establishes the bindings that existed before.  The new bindings
+  are made in parallel (unlike let); all init-exprs are evaluated
+  before the vars are bound to their new values."
+  [bindings & body]
+  (let [names (take-nth 2 bindings)
+        vals (take-nth 2 (drop 1 bindings))
+        tempnames (map gensym names)
+        binds (map vector names vals)
+        resets (reverse (map vector names tempnames))]
+    `(let [~@(interleave tempnames names)]
+       (try
+        ~@(map
+           (fn [[k v]] (list 'set! k v))
+           binds)
+        ~@body
+        (finally
+         ~@(map
+            (fn [[k v]] (list 'set! k v))
+            resets))))))


Ego boost by updating

Ego boost by updating

Newsletter subscribers count manually

--- src/clj/hsm/views.clj
+++ src/clj/hsm/views.clj
@@ -41,7 +41,7 @@
   [:div.bs-callout.bs-callout-success ;{:style "background-color:#f7f7f7;" }

     [:a.btn.btn-success {:href "#mc_embed_signup" :data-toggle :modal} "Subscribe Free"]
-    [:p {:style "margin-top:10px"} "Join " [:b 944] " others. No spamming." [:br][:b "I promise!"]]
+    [:p {:style "margin-top:10px"} "Join " [:b 953] " others. No spamming." [:br][:b "I promise!"]]
     [:p "We are currently under high development. "[:a {:href "https://github.com/bcambel/hackersome?utm_source=left_menu_link"} "Follow us at github."]]
     [:hr]
     [:p "Looking for " [:b[:span.red "Python Tutorials? "]] [:br] [:a {:href "/tutorial/?utm_source=left_menu_link"}  "Check these awesome tutorials"]]


get-user-from-slack-id returns nil for nil id

--- src/clj/tictag/db.clj
+++ src/clj/tictag/db.clj
@@ -43,14 +43,14 @@
 (defrecord Database [db-spec tagtime]
   component/Lifecycle
   (start [component]
-    (timbre/debugf "Starting database, config: %s" (pr-str db-spec))
+    (timbre/debug "Starting database pool")
     (assoc component
            :db {:datasource (hikari/make-datasource (datasource-options db-spec))
                 :crypto-key (:crypto-key db-spec)}
            :pends (atom (ring-buffer 16))))
   (stop [component]
     (when-let [ds (get-in component [:db :datasource])]
-      (timbre/debugf "Closing database pool: %s" ds)
+      (timbre/debug "Closing database pool.")
       (hikari/close-datasource ds))
     (dissoc component :db)))

@@ -288,12 +288,13 @@
                  :beeminder [:= :beeminder.user_id :users.id])))

 (defn get-user-from-slack-id [db slack-id]
-  (to-user
-   db
-   (first
-    (j/query (:db db)
-             (sql/format
-              (where user-query [:= :slack.slack_user_id slack-id]))))))
+  (when slack-id
+    (to-user
+     db
+     (first
+      (j/query (:db db)
+               (sql/format
+                (where user-query [:= :slack.slack_user_id slack-id])))))))

 (defn write-user [db {:keys [username password email tz] :as user}]
   (j/execute!


Unify atom watcher should recur with dereferenced atom (i.e., the data), not the atom.

--- src/cljs/c2/core.cljs
+++ src/cljs/c2/core.cljs
@@ -97,7 +97,7 @@
                (do (add-watch data (keyword (str "auto-unify" (swap! auto-unify-id inc)))
                               (fn [key data-atom old new]
                                 (p "atom updated; automatically calling unify!")
-                                (unify! container data mapping
+                                (unify! container @data-atom mapping
                                         :selector selector
                                         :key-fn key-fn
                                         :enter  enter


Added comments into core module

Added comments into core module

--- src/clouseau/core.clj
+++ src/clouseau/core.clj
@@ -51,17 +51,18 @@
     "3000")

 (def cli-options
+    "Definitions of all command line options currenty supported."
     ;; an option with a required argument
-  [["-p" "--port   PORT"    "port number"   :id :port]])
+    [["-p" "--port   PORT"    "port number"   :id :port]])

 (def app
-    "Ring application."
-    (-> server/handler
-        cookies/wrap-cookies
-        http-params/wrap-params))
+    "Definition of a Ring-based application behaviour."
+    (-> server/handler            ; handle all events
+        cookies/wrap-cookies      ; we need to work with cookies
+        http-params/wrap-params)) ; and to process request parameters, of course

 (defn start-server
-    "Start server on specified port."
+    "Start the HTTP server on the specified port."
     [port]
     (println "Starting the server at the port: " port)
     (jetty/run-jetty app {:port (read-string port)}))
@@ -90,3 +91,5 @@
           port             (options :port)]
           (start-server    (get-port port))))

+; finito
+


Ana-api/current-file might not exist

Ana-api/current-file might not exist

--- src/reagent/core.clj
+++ src/reagent/core.clj
@@ -12,7 +12,11 @@

 (defn- source-info [env]
   (when (:line env)
-    {:file (ana-api/current-file)
+    {:file (try
+             (ana-api/current-file)
+             (catch Exception _
+               ;; ana-api/current-file was added in 1.10.758
+               cljs.analyzer/*cljs-file*))
      :line (:line env)
      :column (:column env)}))


Code review: Keep emacs happy, trailing whitespace (ignore this commit)

--- src/cower/handler.clj
+++ src/cower/handler.clj
@@ -21,37 +21,37 @@
                  (wcar* (apply car/mget keys)))]
     (key-values-to-json keys values)))

-(defn- write-json [thing]
+(defn- write-json [thing]
   (json/write-str thing :escape-slash false))

 (defroutes app-routes
   (GET "/packages" []
        {:status 200
         :body (write-json (search "*"))})
-
+
   (POST "/packages" [name url]
-        (do
+        (do
           (wcar* (car/set name url))
           {:status 201}))
-
+
   (GET "/packages/:name" [name]
-       (let [url (wcar* (car/get name)) ]
+       (let [url (wcar* (car/get name))]
          (if (nil? url)
            {:status 404}
            {:status 200
             :body (write-json
-                    (key-value-to-map [name url])) })))
-
+                   (key-value-to-map [name url]))})))
+
   (DELETE "/packages/:name" [name]
-          (do
+          (do
             (wcar* (car/del name))
             {:status 204}))
-
+
   (GET "/packages/search/:name" [name]
        {:status 200
         :body (write-json
-                (search (str "*" name "*")))})
-
+               (search (str "*" name "*")))})
+
   (route/resources "/")
   (route/not-found "Not Found"))


Fixing build breaker

Fixing build breaker

--- src/shuppet/core.clj
+++ src/shuppet/core.clj
@@ -1,5 +1,8 @@
 (ns shuppet.core
-  (:require [clojure.string :refer [lower-case]]))
+  (:require [clojure.string :refer [lower-case]]
+            [clojure.data.json :refer [json-str]]
+            [shuppet.util :refer :all]
+            [shuppet.securitygroups :refer :all]))

 (declare ^:dynamic application-name)
 (declare ^:dynamic environment)
@@ -15,7 +18,6 @@
                 action action
                 vpc-id "vpc-7bc88713"] ;todo get it from somewhere
         (clojure.core/refer 'clojure.core)
-        (refer 'clojure.string)
         (refer 'clojure.data.json)
         (refer 'shuppet.core)
         (refer 'shuppet.util)
@@ -31,4 +33,4 @@
   ([app-name env]
      (configure app-name env nil)))

-;(configure  "test" "prod")
+;(configure  "test" "dev")


Factor common foreign libs def

Factor common foreign libs def

--- node_repl.clj
+++ node_repl.clj
@@ -1,26 +1,21 @@
 (require 'cljs.repl)
 (require 'cljs.build.api)
 (require 'cljs.repl.node)
+
+(def foreign-libs [{:file "libs/greeting.js"
+       :provides ["greeting"]
+       :module-type :commonjs}
+      {:file "libs/german.js"
+       :provides ["german"]
+       :module-type :commonjs}])

 (cljs.build.api/build "src"
   {:main 'foo.bar
    :output-to "out/main.js"
    :verbose true
-   :foreign-libs
-     [{:file "libs/greeting.js"
-       :provides ["greeting"]
-       :module-type :commonjs}
-      {:file "libs/german.js"
-       :provides ["german"]
-       :module-type :commonjs}]})
+   :foreign-libs foreign-libs})

 (cljs.repl/repl (cljs.repl.node/repl-env)
   :watch "src"
   :output-dir "out"
-  :foreign-libs
-     [{:file "libs/greeting.js"
-       :provides ["greeting"]
-       :module-type :commonjs}
-      {:file "libs/german.js"
-       :provides ["german"]
-       :module-type :commonjs}])
+  :foreign-libs foreign-libs)


preload font

preload font

--- src/splash/core.cljs
+++ src/splash/core.cljs
@@ -177,6 +177,7 @@
          [
           "sfx/splash-screen.ogg"
           "img/stars.png"
+          "http://fonts.gstatic.com/s/indieflower/v8/10JVD_humAd5zP2yrFqw6ugdm0LZdjqr5-oayXSOefg.woff2"
           ]
          :full-colour 0x302060
          :highlight 0x8080ff


Simplify start of app

Simplify start of app

--- src/discuss/core.cljs
+++ src/discuss/core.cljs
@@ -15,7 +15,6 @@
 ;; Initialization
 (defn main []
   (com/init!)
-  (com/request-references)
   (auth/one-click-login))

 ;(main)


search.clj refactored query

search.clj refactored query

--- src/elliot/search.clj
+++ src/elliot/search.clj
@@ -21,22 +21,34 @@
     :hl "on"
     :hl-fl "viewable_words_t"}))

+(defn extract-data-from-block-query-response
+  [highlights block-query-response]
+  {:highlight
+   (first
+    (:viewable_words_t
+     (get highlights
+          (keyword (:id block-query-response)))))
+
+   :start-time (:start_time_s block-query-response)
+   :stop-time (:stop_time_s block-query-response)})

 (defn get-blocks [query-struct doc]
   (let [query-response (query-solr-for-blocks query-struct doc)]
    (assoc doc
           :blocks
           (map
-           (fn [result]
-             {:highlight
-              (first
-               (:viewable_words_t
-                (get (:highlights query-response)
-                     (keyword (:id result)))))
+           (partial extract-data-from-block-query-response
+                    (:highlights query-response))
+           (:docs query-response)))))

-              :start-time (:start_time_s result)
-              :stop-time (:stop_time_s result)})
-           (:docs query-response)))))
+(defn improve-query [stock-query]
+  (assoc stock-query
+         :q
+         (str
+          "title_t:\""
+          (:q stock-query)
+          "\""
+          (:q stock-query))))

 (defn go [query-struct]
   (if (nil? (query-struct :q))
@@ -45,13 +57,7 @@

     ;;Do an actual query
     (let [rv (common/mapply
-              solr/query connection (assoc query-struct
-                                           :q
-                                           (str
-                                            "title_t:\""
-                                            (:q query-struct)
-                                            "\""
-                                            (:q query-struct))))]
+              solr/query connection (improve-query query-struct))]
       (assoc
        rv
        :docs


Update to newer JmDNS.

Update to newer JmDNS.

It looks like JmDNS 3.4.1 was released 25-Aug-2011. Ricky Clarkson
took subsequent commits / fixes and made a release of 3.4.2 on
13-Feb-2013.

This hopefully will lead to better stability and perhaps also address
bug #58.

--- Clojure/project.clj
+++ Clojure/project.clj
@@ -5,7 +5,7 @@
             :url "http://www.eclipse.org/legal/epl-v10.html"}
   :dependencies [[org.clojure/clojure "1.6.0"]
                  [org.clojure/clojurescript "0.0-2913"]
-                 [javax.jmdns/jmdns "3.4.1"]]
+                 [com.github.rickyclarkson/jmdns "3.4.2-r353-1"]]
   :source-paths ["src"]
   :compiler {
      :optimizations :none


- Added missing direct dependency on liberator.representation; - Used an alias for liberator.representation

--- src/freecoin/core.clj
+++ src/freecoin/core.clj
@@ -29,6 +29,7 @@
 (ns freecoin.core
   (:require [org.httpkit.server :as server]
             [liberator.dev :as ld]
+            [liberator.representation :as lr]
             [clojure.tools.logging :as log]
             [clojure.data.json :as json]
             [ring.middleware.defaults :as ring-mw]
@@ -63,16 +64,16 @@
                  (config/client-secret config-m)
                  (routes/absolute-path :sso-callback)))

-(defmethod liberator.representation/render-seq-generic "application/activity+json" [data _]
+(defmethod lr/render-seq-generic "application/activity+json" [data _]
   (json/write-str data))

-(defmethod liberator.representation/render-map-generic "application/activity+json" [data context]
+(defmethod lr/render-map-generic "application/activity+json" [data context]
   (json/write-str data))

-(defmethod liberator.representation/render-seq-generic "application/json" [data _]
+(defmethod lr/render-seq-generic "application/json" [data _]
   (json/write-str data))

-(defmethod liberator.representation/render-map-generic "application/json" [data context]
+(defmethod lr/render-map-generic "application/json" [data context]
   (json/write-str data))

 (defn todo [_]


Readability improvements - no code change

--- src/frontend/core.clj
+++ src/frontend/core.clj
@@ -92,19 +92,25 @@
   (let [server-name (:server-name req)
         env (System/getenv "CIRCLE_FRONTEND_ENV")]
     (cond
-      (or
-        (= env "dev")
-        (= server-name "dev.circlehost")) {:proto "http" :host "dev.circlehost:8080"}
-      (or
-        (= env "prod")
-        (= server-name "prod.circlehost")) {:proto "https" :host "circleci.com"}
-      (or
-        (= env "enterprise")
-        (= server-name "enterprise.circlehost")) {:proto "https" :host "enterprise-staging.sphereci.com"}
+      (or (= env "dev")
+          (= server-name "dev.circlehost"))
+      {:proto "http" :host "dev.circlehost:8080"}
+
+      (or (= env "prod")
+          (= server-name "prod.circlehost"))
+      {:proto "https" :host "circleci.com"}
+
+      (or (= env "enterprise")
+          (= server-name "enterprise.circlehost"))
+      {:proto "https" :host "enterprise-staging.sphereci.com"}
+
       (= env "docker")
       {:proto "http" :host (System/getenv "CIRCLE_BACKEND_HOST")}
-      (re-matches #"(.*).circlehost" server-name) (when-let [env (some->> req :server-name (re-matches #"(.*).circlehost") second)]
-                                                    {:proto "https" :host (format "%s.circleci.com" env)})
+
+      (re-matches #"(.*).circlehost" server-name)
+      (when-let [env (some->> req :server-name (re-matches #"(.*).circlehost") second)]
+        {:proto "https" :host (format "%s.circleci.com" env)})
+
       :else {:proto "http" :host "dev.circlehost:8080"})))

 (def proxy-config


Removes random group ID

Removes random group ID

This caused existing message to be re-sent, which made testing easier.

--- src/yuubin/kafka.clj
+++ src/yuubin/kafka.clj
@@ -2,9 +2,8 @@
   (:import [org.apache.kafka.clients.consumer KafkaConsumer]
            [org.apache.kafka.clients.producer KafkaProducer ProducerRecord]))

-;; TODO Remove randomness after testing.
 (def default-consumer-config
-  {"group.id" (str "yuubin-" (rand-int 10000))
+  {"group.id" "yuubin-consumer"
    "auto.offset.reset" "earliest"
    "enable.auto.commit" "false"
    "key.deserializer" "org.apache.kafka.common.serialization.StringDeserializer"


bump template to 0.2.5

bump template to 0.2.5

--- template/project.clj
+++ template/project.clj
@@ -1,4 +1,4 @@
-(defproject cljs-lambda/lein-template "0.2.4"
+(defproject cljs-lambda/lein-template "0.2.5"
   :description "Clojurescript on AWS Lambda"
   :url "https://github.com/nervous-systems/cljs-lambda"
   :license {:name "Unlicense" :url "http://unlicense.org/UNLICENSE"}


Fix airity bug in room/update-settings

Fix airity bug in room/update-settings

--- src/yetibot/core/models/room.clj
+++ src/yetibot/core/models/room.clj
@@ -45,5 +45,6 @@
   "Updates or creates new setting k = v for a given room"
   [uuid room k v]
   (apply-settings
+    uuid room
     (fn [current-val-if-exists]
       (assoc current-val-if-exists k v))))


Allow for variation in score given slower Travis systems

--- test/herder/solver/core_test.clj
+++ test/herder/solver/core_test.clj
@@ -91,13 +91,14 @@
                 (.setDependantEventCount 1))
           two (doto (eventWithPerson alpha)
                 (.setChainedEvent one)
-                (.setEventType EventType/ONE_DAY))]
-      (is (= "0hard/-1soft"
-             (->>
-              (getSolution [(doto one
-                              (.setLaterEvent two)) two])
-              (.getScore)
-              (.toString))))))
+                (.setEventType EventType/ONE_DAY))
+          softScore (->>
+                     (getSolution [(doto one
+                                     (.setLaterEvent two)) two])
+                     (.getScore)
+                     (.getSoftScore))]
+      (is (< softScore 0))
+      (is (> softScore -3))))

   (deftest EventsHavedistinctSlotsWithOverlyFullSolution
     (->> (getSolution


THA port charting.cljx to cljc

THA port charting.cljx to cljc

--- src/hatti/charting.cljc
+++ src/hatti/charting.cljc
@@ -2,13 +2,13 @@
   (:require [c2.layout.histogram :refer [histogram]]
             [c2.scale :as scale]
             [c2.svg :as svg]
-            #+clj [clj-time.format :as tf]
-            #+clj [clj-time.coerce :as tc]
-            #+cljs [cljs-time.format :as tf]
-            #+cljs [cljs-time.coerce :as tc]
-            #+clj [clojure.math.numeric-tower :refer [gcd lcm floor ceil abs]]
-            #+cljs [hatti.maths :refer [gcd lcm floor ceil abs]]
-            #+cljs [hatti.utils :refer [format]]
+            [#?(:clj  clj-time.format
+                :cljs cljs-time.format) :as tf]
+            [#?(:clj  clj-time.coerce
+                :cljs cljs-time.coerce) :as tc]
+            [#? (:clj clojure.math.numeric-tower
+                :cljs hatti.maths) :refer [gcd lcm floor ceil abs]]
+            #?(:cljs [hatti.utils :refer [format]])
             [hatti.ona.forms :as f]
             [clojure.string :refer [join blank?]]))

@@ -17,26 +17,27 @@
 (defn- safe-floor
   "Like floor but returns nil if passed nil."
   [n]
-  #+clj (try
-          (floor n)
-          (catch IllegalArgumentException e nil))
-  #+cljs (floor n))
+  #?(:clj (try
+             (floor n)
+             (catch IllegalArgumentException e nil))
+     :cljs (floor n)))

 (defn- style
   "Helper function to create the style argument in hiccup vectors.
   (style :width '200px' :height '100px') => {:style 'width:200px;height:100px'}"
   [style-map]
-  {:style #+cljs style-map
-          #+clj  (join ";" (for [[k v] style-map]
-                               (str (name k) ": " v)))})
+  {:style #?(:cljs style-map
+             :clj  (->> (for [[k v] style-map]
+                          (str (name k) ": " v))
+                     (join ";" )))})

 (defn parse-int
   "Parse an integer from a string."
   [st]
-  #+clj (when st (if (instance? String st)
-                   (when-not (blank? st) (read-string st))
-                   st))
-  #+cljs (let [ans (js/parseInt st)] (if (js/isNaN ans) nil ans)))
+  #?(:clj (when st (if (instance? String st)
+                       (when-not (blank? st) (read-string st))
+                       st))
+     :cljs (let [ans (js/parseInt st)] (if (js/isNaN ans) nil ans))))

 (defn str->int [typ]
   "Converts string to integer, for typ (int|date)."
@@ -50,11 +51,11 @@
    Optional digits parameter = number of digits after decimal, default is 1."
   (let [int-fmt-s (str "%." digits "f")
         d->millis #(* millis-in-day %)
-        date->str #+clj #(tf/unparse (tf/formatters :year-month-day)
-                                     (tc/from-long  %))
-                  #+cljs #(.format (js/moment %) "ll")]
+        date->str #? (:clj  #(tf/unparse (tf/formatters :year-month-day)
+                                         (tc/from-long  %))
+                      :cljs #(.format (js/moment %) "ll"))]
     (case typ
-      "int" #(format int-fmt-s (float %))
+      "int"  #(format int-fmt-s (float %))
       "date" #(date->str (d->millis %)))))

 (defn range->str [[mn mx] typ]
@@ -64,30 +65,30 @@
     (if (<= mx mn) (fmt mn)
       (join " to " [(fmt mn) (fmt mx)]))))

-#+cljs
-(defn evenly-spaced-bins
-  "Given a list of answers, returns each one as a bin, in string form.
+#?(:cljs
+   (defn evenly-spaced-bins
+     "Given a list of answers, returns each one as a bin, in string form.
    nil is mapped to nil. The bins, in order, are returned as metadata.
    eg. (evenly-spaced-bins [1 2 10] 5 'int') => ['1 to 2' '1 to 2' '9 to 10']
    metadata of this above value would be:
    {:bins ['1 to 2', '3 to 4', '5 to 6', '7 to 8', '9 to 10']}"
-  [answers bins typ]
-  (let [numbers (map (str->int typ) answers)
-        mx (reduce max (remove nil? numbers))
-        mn (reduce min (remove nil? numbers))
-        s (scale/linear :domain [mn mx] :range [0 (- bins (/ 1 10000))])
-        is (map safe-floor (map #(when % (s %)) numbers))
-        t (scale/linear :domain [0 bins] :range [mn mx])
-        lbounds (->> (range bins) (map t) (map float) distinct)
-        ubounds (conj (mapv #(if (= % (safe-floor %))
-                               (dec %) %) (drop 1 lbounds)) mx)
-        fmt (int->str typ :digits 0)
-        strings (mapv #(range->str [%1 %2] typ) lbounds ubounds)
-        results (map (fn [i] (when i (get strings (int i)))) is)
-        strings (-> strings distinct vec)] ; remove repeats before output
-    (with-meta results
-      {:bins (if (contains? (set answers) nil)
-               (conj strings nil) strings)})))
+     [answers bins typ]
+     (let [numbers (map (str->int typ) answers)
+           mx (reduce max (remove nil? numbers))
+           mn (reduce min (remove nil? numbers))
+           s (scale/linear :domain [mn mx] :range [0 (- bins (/ 1 10000))])
+           is (map safe-floor (map #(when % (s %)) numbers))
+           t (scale/linear :domain [0 bins] :range [mn mx])
+           lbounds (->> (range bins) (map t) (map float) distinct)
+           ubounds (conj (mapv #(if (= % (safe-floor %))
+                                  (dec %) %) (drop 1 lbounds)) mx)
+           fmt (int->str typ :digits 0)
+           strings (mapv #(range->str [%1 %2] typ) lbounds ubounds)
+           results (map (fn [i] (when i (get strings (int i)))) is)
+           strings (-> strings distinct vec)] ; remove repeats before output
+       (with-meta results
+         {:bins (if (contains? (set answers) nil)
+                  (conj strings nil) strings)}))))

 (defn label-count-pairs
   "Take chart-data from the ona API, returns label->count map.
@@ -226,7 +227,8 @@
                       (str (format "%.1f" (float (s n))) "%")))
         select-mult? (= field_type "select all that apply")
         bar-div (if select-mult? :div.bars.select-mult :div.bars.select-one)
-        colspan #+clj :colspan #+cljs :col-span ; sablono/react.js use col-span
+        ;; sablono/react.js use col-span
+        colspan #? (:clj :colspan :cljs :col-span)
         tdr :td.t-right]
     [:table#bar-chart.table
      [:thead


Forgot the arglists on this one

Forgot the arglists on this one

--- src/grimoire/api.clj
+++ src/grimoire/api.clj
@@ -49,6 +49,7 @@
 (defmulti thing->prior-versions
   "Returns a sequence of things representing itself at earlier or equal versions."

+  {:arglists '[[config thing]]}
   dispatch)

 (defmulti read-notes


Trial run on clj

Trial run on clj

--- src/grimoire/doc.clj
+++ src/grimoire/doc.clj
@@ -7,7 +7,9 @@
             [clojure.tools.namespace.find :as tns.f]
             [clojure.java.classpath :as cp]
             [grimoire.api :as api]
+            [grimoire.api.fs :refer [->Config]]
             [grimoire.api.fs.write]
+            [grimoire.api.fs.read]
             [grimoire.things :as t]
             [grimoire.util :as util]
             [grimoire.either :as e]
@@ -135,11 +137,12 @@
   there already _is_ metadata there without overwriting it."
   [config thing meta]
   (if (and (not (:clobber config))
-           (e/succeed? (api/read-meta config thing)))
+           (e/succeed? (api/read-meta (:datastore config) thing)))
     (println
      (format "Warning: metadata for thing %s already exists! continuing w/o clobbering..."
              (t/thing->path thing)))
-    (api/write-meta config thing meta)))
+    (do (println (t/thing->path thing))
+        (api/write-meta (:datastore config) thing meta))))

 (defn write-docs-for-var
   "General case of writing documentation for a Var instance with
@@ -153,15 +156,15 @@
                  (update :ns   ns-stringifier)
                  (dissoc :inline
                          :protocol))]
-    (guarde-write-meta config
-                       (var->thing config var)
-                       docs)))
+    (guarded-write-meta config
+                        (var->thing config var)
+                        docs)))

 (defn write-docs-for-specials
   "Function of a config and what is presumed to be a legitimate .edn file
   containing a map from platform naming strings to maps from namespace qualified
   symbols to metadata for these symbols."
-  [{:keys [groupid artifactid version platform] :as config} specials-file]
+  [{:keys [groupid artifactid version platform] :as config} ?special-file]
   (assert (.exists ?special-file) "No such special symbols file!")
   (let [specials-data (edn/read-string (slurp ?special-file))
         ?specials     (get specials-data platform)]
@@ -196,9 +199,9 @@
                         ns-vars)
         vars    (filter #(not (fn? @%1)) ns-vars)]

-    (let [meta  (-> ns the-ns meta)
+    (let [meta  (-> ns the-ns meta (or {}))
           thing (ns->thing config ns)]
-      (api/write-meta config thing meta))
+      (api/write-meta (:datastore config) thing meta))

     ;; write per symbol docs
     (doseq [var ns-vars]
@@ -298,8 +301,7 @@
                          :artifactid artifactid
                          :version    version
                          :platform   platform
-                         :datastore  {:docs dst
-                                      :mode :filesystem}
+                         :datastore  (->Config dst "" "")
                          :clobber    clobber}
                pattern  (format ".*?/%s/%s/%s.*"
                                 (string/replace groupid "." "/")
@@ -327,8 +329,7 @@
                         :artifactid p-artifactid
                         :version    p-version
                         :platform   platform
-                        :datastore  {:docs (last args)
-                                     :mode :filesystem}
+                        :datastore  (->Config (last args) "" "")
                         :clobber    clobber}]
           (doseq [ns (->> p-source-paths
                           (map io/file)


Don't special case writing docs for clojure.core

I don't need that code anymore, and it's an incorrect arity invocation
of the write-docs-for-specials fn anyway.

--- src/grimoire/doc.clj
+++ src/grimoire/doc.clj
@@ -208,11 +208,7 @@

       ;; write per symbol docs
       (doseq [var ns-vars]
-        (write-docs-for-var config var))
-
-      ;; FIXME: this shouldn't be needed
-      (when (= ns 'clojure.core)
-        (write-docs-for-specials config)))
+        (write-docs-for-var config var)))

     ;; FIXME: should be a real logging thing
     (println "Finished" ns)


[#1189] Added whitespace normalisation to compatible-columns? predicate

--- backend/src/akvo/lumen/update.clj
+++ backend/src/akvo/lumen/update.clj
@@ -7,6 +7,8 @@
             [akvo.lumen.util :as util]
             [clojure.java.jdbc :as jdbc]
             [clojure.set :as set]
+            [clojure.string :as string]
+            [clojure.walk :refer [keywordize-keys]]
             [hugsql.core :as hugsql]))

 (hugsql/def-db-fns "akvo/lumen/job-execution.sql")
@@ -63,12 +65,12 @@
         columns))))

 (defn compatible-columns? [imported-columns columns]
-  (let [imported-columns (map (fn [column]
-                                (cond-> {:id (keyword (get column "columnName"))
-                                         :type (keyword (get column "type"))
-                                         :title (get column "title")}
-                                  (contains? column "key") (assoc :key (boolean (get column "key")))))
-                              imported-columns)]
+  (let [imported-columns (map #(cond-> {:id (keyword (:columnName %))
+                                        :type (keyword (:type %))
+                                        :title (:title %)}
+                                 (contains? % :key) (assoc :key (boolean (:key %))))
+                              (map keywordzie-keys imported-columns))
+        columns (map #(update % :title string/trim) (map keywordize-keys columns))]
     (set/subset? (set imported-columns)
                  (set columns))))


Add faster implementation for retrieve image size.

--- backend/src/uxbox/cli/collimp.clj
+++ backend/src/uxbox/cli/collimp.clj
@@ -24,7 +24,8 @@
             [uxbox.util.uuid :as uuid]
             [uxbox.util.data :as data])
   (:import [java.io Reader PushbackReader]
-           [javax.imageio ImageIO]))
+           [javax.imageio ImageIO]
+           [org.im4java.core Info]))

 ;; --- Constants & Specs

@@ -63,11 +64,8 @@

 (defn- retrieve-image-size
   [path]
-  (let [path (fs/path path)
-        file (.toFile path)
-        buff (ImageIO/read file)]
-    [(.getWidth buff)
-     (.getHeight buff)]))
+  (let [info (Info. (str path) true)]
+    [(.getImageWidth info) (.getImageHeight info)]))

 (defn- retrieve-image
   [conn id]


renamed keywords. breaking changed :route/name to :route/id :AppRoot to :root-class :set-active-route! to set-route!

--- src/routom/core.cljs
+++ src/routom/core.cljs
@@ -122,21 +122,21 @@
              static om/IQueryParams
              (params
                [this]
-               (when-let [{:keys [route/name route/params]} @active-route]
-                 (:params (get-active-query routes route-hierarchy name params))))
+               (when-let [{:keys [route/id route/params]} @active-route]
+                 (:params (get-active-query routes route-hierarchy id params))))
              static om/IQuery
              (query
                [this]
-               (when-let [{:keys [route/name route/params]} @active-route]
-                 (:query (get-active-query routes route-hierarchy name params))))
+               (when-let [{:keys [route/id route/params]} @active-route]
+                 (:query (get-active-query routes route-hierarchy id params))))
              Object
              (componentWillMount
                [this]

-               (letfn [(on-route-changed [{:keys [route/name route/params] :as active-route}]
+               (letfn [(on-route-changed [{:keys [route/id route/params] :as active-route}]

                          (when active-route
-                           (set-active-query! this routes route-hierarchy name params)))]
+                           (set-active-query! this routes route-hierarchy id params)))]
                  (add-watch
                    active-route
                    :app-root
@@ -148,9 +148,9 @@
                [this]
                (remove-watch active-route :app-root))
              (render [this]
-                     (let [{:keys [route/name] :as active-route} @active-route]
+                     (let [{:keys [route/id] :as active-route} @active-route]
                        (if active-route
-                         (let [path (u/get-path @route-hierarchy name)
+                         (let [path (u/get-path @route-hierarchy id)
                                props (om/props this)
                                root-props (merge
                                             props
@@ -158,8 +158,8 @@
                                element-tree (get-element-tree @routes path root-props render-module-status)]
                            element-tree))
                        )))]
-       {:AppRoot           AppRoot
-        :set-active-route! set-active-route!}))))
+       {:root-class           AppRoot
+        :set-route! set-active-route!}))))


Bump lein profiles dependency versions

Bump lein profiles dependency versions

--- lein/profiles.clj
+++ lein/profiles.clj
@@ -36,12 +36,12 @@
                        ;; Q: How many of any of the rest of these do I actually use?
                        ;; This one's gone
                        #_[nrepl-inspect "0.3.0"]
-                       [org.codehaus.plexus/plexus-utils "3.0.17"]
+                       [org.codehaus.plexus/plexus-utils "3.0.22"]
                        ;; I use this everywhere. But it doesn't belong in here
                        #_[org.clojure/tools.namespace "0.2.10"]
                        ;; I know I have a lot of projects that transitively rely on this, but they really shouldn't
                        #_[org.clojure/tools.nrepl "0.2.12" :exclusions [org.clojure/clojure]]
-                       [pjstadig/humane-test-output "0.7.0"]
+                       [pjstadig/humane-test-output "0.8.0"]
                        ;; Q: Is there any point to this next one?
                        #_[ritz/ritz-nrepl-middleware "0.7.0"]
                        ;; This approach is long deprecated.
@@ -77,17 +77,15 @@
         ;;:local-repo "repo"
         :plugins [[cider/cider-nrepl "0.11.0" :exclusions [org.clojure/java.classpath]]
                   [com.jakemccrary/lein-test-refresh "0.14.0"]
-                  [jonase/eastwood "0.2.2" :exclusions [org.clojure/clojure]]
-                  [lein-ancient "0.6.8" :exclusions [cheshire
+                  [jonase/eastwood "0.2.3" :exclusions [org.clojure/clojure]]
+                  [lein-ancient "0.6.10" :exclusions [cheshire
                                                      common-codec
                                                      commons-codec
                                                      org.clojure/clojure
                                                      #_org.clojure/tools.reader
                                                      slingshot]]
-                  ;; This next one's super useful, but its dependencies are out of date
-                  ;; TODO: Update!
                   [lein-kibit "0.1.2" :exclusions [org.clojure/clojure]]
-                  [lein-pprint "1.1.1"]
+                  [lein-pprint "1.1.2"]
                   [mvxcvi/whidbey "1.3.0" :exclusions [org.clojure/clojure]]]
         :repl-options {:nrepl-middleware
                        []}


more debug logging

more debug logging

--- src/babel/over.cljc
+++ src/babel/over.cljc
@@ -88,7 +88,7 @@
                          {:head (copy head)})]
       (if (not (= :fail result))
         (do
-          (log/debug (str "overh: " (get-in parent [:rule]) " -> " (spec-info head) " : "
+          (log/debug (str "overh success: " (get-in parent [:rule]) " -> " (spec-info head) " : "
                           (strip-refs
                            (dissoc
                             head :dag_unify.core/serialized))))
@@ -120,10 +120,14 @@
          is-fail? (= :fail result)]
      (if (not is-fail?)
        (do
-         (log/debug (str "overc: " (get-in parent [:rule]) " -> " (get-in comp [:rule]
+         (log/debug (str "overc success: " (get-in parent [:rule]) " -> " (get-in comp [:rule]
                                                                           (get-in comp [:synsem :sem :pred]
                                                                                "(no pred for comp)"))))
-         (list result))))))
+         (list result))
+       (log/debug (str "overc: fail-path for rule: " (:rule parent) ":"
+                       (dag_unify.core/fail-path
+                        (copy parent)
+                        {:comp (copy comp)})))))))

 (declare show-bolt)
 (declare subpath?)


update error message

update error message

--- src/cake/server.clj
+++ src/cake/server.clj
@@ -36,7 +36,7 @@
         (if-let [ns (second (read-file-ns-decl (java.io.File. file)))]
           (when (find-ns ns) ;; don't reload namespaces that aren't already loaded
             (load-file file))
-          (println "cannot reload file without namespace declaration"))))))
+          (println "cannot reload file without namespace declaration:" file))))))

 (defn exit []
   (System/exit 0))


Fixed main entry point of the app.

Fixed main entry point of the app.

Changed the function name from ‘main’ to ‘-main’ so that leiningen can
find it. Changed run-dmc to run for production.

--- src/cine/server.clj
+++ src/cine/server.clj
@@ -34,8 +34,8 @@
   (-> app-routes
       (wrap-defaults site-defaults)))

-(defn main
+(defn -main
   "Main Entry point of the app"
   []
-  (run-dmc app {:host "localhost" :port 9003}))
+  (run app {:host "localhost" :port 9003}))


ignore what's returned

ignore what's returned

--- src/cljs/forms.cljs
+++ src/cljs/forms.cljs
@@ -36,10 +36,10 @@
     {:form update-score :id "update-score" :func update-s}
     {:form delete-team :id "delete-team" :func delete}])

-(defn handler [_]
+(defn handler []
   (.log js/console "success"))

-(defn error [_]
+(defn error []
   (.log js/console "error"))

 (defn create [params]


Change ifs to whens when there's no else.

Also, fns that require default collector args are
now multiarity, so that calls don't have to know
about them.

--- src/isla/parser.clj
+++ src/isla/parser.clj
@@ -15,61 +15,60 @@
   (-root (lex code)))

 (defn -root [tokens]
-  (nnode :root [(-block tokens [])]))
+  (nnode :root [(-block tokens)]))

-(defn -block [tokens collected]
-  (if-let [{node :node left-tokens :left-tokens}
-           (-expression tokens [])]
-    (recur left-tokens (conj collected node)) ;; add expr, continue collecting more
-    (if (= 0 (count tokens))
-      (nnode :block collected) ;; no more exprs, all tokens used, return block
-      (throw (Exception. (str "Got lost at: " (vec tokens))))))) ;; tokens remaining - throw
+(defn -block
+  ([tokens] (-block tokens []))
+  ([tokens collected]
+     (if-let [{node :node left-tokens :left-tokens}
+              (-expression tokens)]
+       (recur left-tokens (conj collected node)) ;; add expr, continue collecting more
+       (if (= 0 (count tokens))
+         (nnode :block collected) ;; no more exprs, all tokens used, return block
+         (throw (Exception. (str "Got lost at: " (vec tokens)))))))) ;; tokens remaining - throw

 ;; expressions

-(defn -expression [tokens collected]
-  (pattern-sequence-selector tokens [-type-assignment -value-assignment
-                                     -array-operation -invocation]
-                             :expression))
+(defn -expression
+  ([tokens] (-expression tokens []))
+  ([tokens collected]
+     (pattern-sequence-selector tokens [-type-assignment -value-assignment
+                                        -array-operation -invocation]
+                                :expression)))

 (defn -type-assignment [tokens]
-  (if-let [{nodes :nodes left-tokens :left-tokens}
-           (pattern-sequence tokens [-assignee -is-a -identifier -nl] [])]
-    {:node (nnode :type-assignment (take 3 nodes)) :left-tokens left-tokens}
-    nil))
+  (when-let [{nodes :nodes left-tokens :left-tokens}
+             (pattern-sequence tokens [-assignee -is-a -identifier -nl])]
+    {:node (nnode :type-assignment (take 3 nodes)) :left-tokens left-tokens}))

 (defn -value-assignment [tokens]
-  (if-let [{nodes :nodes left-tokens :left-tokens}
-           (pattern-sequence tokens [-assignee -is -value -nl] [])]
-    {:node (nnode :value-assignment (take 3 nodes)) :left-tokens left-tokens}
-    nil))
+  (when-let [{nodes :nodes left-tokens :left-tokens}
+             (pattern-sequence tokens [-assignee -is -value -nl])]
+    {:node (nnode :value-assignment (take 3 nodes)) :left-tokens left-tokens}))

 (defn -array-operation [tokens]
-  (if-let [{nodes :nodes left-tokens :left-tokens}
-           (pattern-sequence tokens [-assignee -list-operation -value -nl] [])]
-    {:node (nnode :array-operation (take 3 nodes)) :left-tokens left-tokens}
-    nil))
+  (when-let [{nodes :nodes left-tokens :left-tokens}
+             (pattern-sequence tokens [-assignee -list-operation -value -nl])]
+    {:node (nnode :array-operation (take 3 nodes)) :left-tokens left-tokens}))

 (defn -invocation [tokens]
-  (if-let [{nodes :nodes left-tokens :left-tokens}
-           (pattern-sequence tokens [-identifier -value -nl] [])]
-    {:node (nnode :invocation (take 2 nodes)) :left-tokens left-tokens}
-    nil))
+  (when-let [{nodes :nodes left-tokens :left-tokens}
+             (pattern-sequence tokens [-identifier -value -nl])]
+    {:node (nnode :invocation (take 2 nodes)) :left-tokens left-tokens}))

 (defn -list-operation [tokens]
-  (if-let [{node :node left-tokens :left-tokens}
-           (pattern-sequence-selector tokens [-add -remove] :list-operation)]
-    (let []
-      {:node node :left-tokens left-tokens})
-    nil))
+  (when-let [{node :node left-tokens :left-tokens}
+             (pattern-sequence-selector tokens [-add -remove] :list-operation)]
+    {:node node :left-tokens left-tokens}))

 ;; atoms

 (defn -is-a [tokens]
   (let [one (first tokens) two (second tokens)]
-    (if (and (string? one) (string? two))
-      (if (is-type #"is a" (str one " " two))
-        {:node (nnode :is-a [:is-a]) :left-tokens (nthrest tokens 2)}))))
+    (when (and (string? one)
+               (string? two)
+               (is-type #"is a" (str one " " two)))
+      {:node (nnode :is-a [:is-a]) :left-tokens (nthrest tokens 2)})))

 (defn -nl [tokens] (one-token-pattern tokens :nl :nl))

@@ -101,16 +100,14 @@
   (pattern-sequence-selector tokens [-object -scalar] :assignee))

 (defn -scalar [tokens]
-  (if-let [{nodes :nodes left-tokens :left-tokens}
-           (pattern-sequence tokens [-identifier] [])]
-    {:node (nnode :scalar (take 1 nodes)) :left-tokens left-tokens}
-    nil))
+  (when-let [{nodes :nodes left-tokens :left-tokens}
+             (pattern-sequence tokens [-identifier])]
+    {:node (nnode :scalar (take 1 nodes)) :left-tokens left-tokens}))

 (defn -object [tokens]
-  (if-let [{nodes :nodes left-tokens :left-tokens}
-           (pattern-sequence tokens [-identifier -identifier] [])]
-    {:node (nnode :object (take 2 nodes)) :left-tokens left-tokens}
-    nil))
+  (when-let [{nodes :nodes left-tokens :left-tokens}
+             (pattern-sequence tokens [-identifier -identifier])]
+    {:node (nnode :object (take 2 nodes)) :left-tokens left-tokens}))

 (defn -integer [tokens]
   (one-token-pattern tokens #"[1-9][0-9]*" :integer
@@ -141,27 +138,24 @@

 (defn pattern-sequence-selector [tokens pattern-sequences tag]
   (let [alts (alternatives tokens pattern-sequences)]
-    (if (> (count alts) 0)
+    (when (> (count alts) 0)
       (let [{node :node left-tokens :left-tokens} (first alts)]
-        {:node (nnode tag [node]) :left-tokens left-tokens}) ;; return alternative
-      nil))) ;; no alternatives match - return
+        {:node (nnode tag [node]) :left-tokens left-tokens})))) ;; return alternative

-(defn pattern-sequence [tokens patterns collected]
-  (if-let [pattern (first patterns)]
-    (if-let [{node :node left-tokens :left-tokens} (pattern tokens)] ;; matched token
-      (pattern-sequence left-tokens (rest patterns) (conj collected node)) ;; round again
-      nil) ;; pattern sequence element match failure - return
-    {:nodes collected :left-tokens tokens})) ;; pattern matched - return
+(defn pattern-sequence
+  ([tokens patterns]
+     (pattern-sequence tokens patterns []))
+  ([tokens patterns collected]
+     (if-let [pattern (first patterns)]
+       (when-let [{node :node left-tokens :left-tokens} (pattern tokens)] ;; matched token
+         (recur left-tokens (rest patterns) (conj collected node))) ;; round again
+       {:nodes collected :left-tokens tokens}))) ;; pattern matched - return

-(defn one-token-pattern [tokens matcher tag & args]
-  (if-let [token (first tokens)]
-    (if (is-type matcher token)
-      (let [output (if (not= nil args)
-                     ((first args) token)
-                     [token])]
-        {:node (nnode tag output) :left-tokens (rest tokens)})
-      nil)
-    nil))
+(defn one-token-pattern [tokens matcher tag & [f]]
+  (when-let [token (first tokens)]
+    (when (is-type matcher token)
+      (let [output (if f (f token) [token])]
+        {:node (nnode tag output) :left-tokens (rest tokens)}))))

 (defn nnode [tag data]
   {:tag tag :c data})


Add GraphML reader

Add GraphML reader

--- src/jungerer/io.clj
+++ src/jungerer/io.clj
@@ -2,7 +2,9 @@
   (:require [clojure.java.io :as io]
             [clojure.string :as string]
             [jungerer.graph :as g])
-  (:import edu.uci.ics.jung.io.GraphMLWriter))
+  (:import com.google.common.base.Function
+           edu.uci.ics.jung.graph.Hypergraph
+           [edu.uci.ics.jung.io GraphMLReader GraphMLWriter]))

 (defn load-pairs!
   [f graph]
@@ -18,6 +20,15 @@
     (doseq [[a b] (g/edges graph)]
       (.write w (str a \tab b \newline)))))

+(defn load-graphml!
+  [^String f ^Hypergraph graph]
+  (.load (GraphMLReader.) f graph))
+
 (defn save-as-graphml
   [f graph]
-  (.save (GraphMLWriter.) graph (io/writer f)))
+  (doto (GraphMLWriter.)
+    (.setEdgeIDs (reify Function
+                   (apply [_ edge]
+                     edge)))
+    (.save graph (io/writer f)))
+  nil)


everything except java calls

everything except java calls

--- src/funcgo/core.clj
+++ src/funcgo/core.clj
@@ -224,7 +224,6 @@
   (try
     (let
         [clj (funcgo-parse (slurp (first args)))]
-      ;;(println clj)
       (doseq
           [expr (read-string (str "[" clj "]"  ))]
         (pprint/pprint expr)


Initial code.

Initial code.

--- src/fx_clj/core.clj
+++ src/fx_clj/core.clj
@@ -1,6 +1,42 @@
-(ns fx-clj.core)
+(ns fx-clj.core
+  (:require [clojure.core.async :refer [put! go <! >!]]))

-(defn foo
-  "I don't do a whole lot."
-  [x]
-  (println x "Hello, World!"))
+;; TODO: use java.thread uncaught ex handler
+(defn set-fx-exception-handler! [f])
+
+(defn run!* [f])
+
+(defn- async-run-wrapper [f ch]
+  (let [res
+        (try
+          (f)
+          (catch Throwable ex
+            (put! ch (ex-info (str "Error on JavaFX application thread") {} ex))
+            (throw ex) ;; Should this be rethrown??
+            ))]
+    (put! ch res)))
+
+(defn- run<** [f cb]
+  (let [ch (chan)]
+    (run!* f ch)
+    (let [res (cb ch)]
+      (when (instace? Throwable res)
+        (throw res)))))
+
+(defn run<!* [f] (run<** f <!))
+
+(defn run<!!* [f] (run<** f <!!))
+
+(defmacro run! [& body])
+
+(defmacro run<! [& body])
+
+(defmacro run<!! [& body])
+
+(defn pset! [])
+
+(defn pset<! [])
+
+(defn pset<!! [])
+
+(defn compile [form])


add back select-plugin :X

add back select-plugin :X

--- src/goodbot/bot.clj
+++ src/goodbot/bot.clj
@@ -4,11 +4,13 @@
    [irclj.core :as irclj]
    [goodbot.parse :refer [extract-command extract-word]]])

+(defn select-plugin [plugins name]
+  (->> plugins (filter #(= name (:command %)) first)))
+
 (defn add-help [plugins]
   (declare plugins-with-help)
   (defn help-handler [irc message]
     (defn handle [command]
-      (println "plugins" plugins-with-help)
       (if-let [plugin (select-plugin plugins-with-help command)]
         (or (:doc plugin)
             (str "." command " doesn't have documentation!"))


Add data.csv, boot-test, and set up for testing.

--- project/analyze-data/build.boot
+++ project/analyze-data/build.boot
@@ -1,9 +1,13 @@
 ; vi: ft=clojure

 (set-env!
-  :resource-paths #{"src"}
+  :resource-paths #{"src", "test"}
   :dependencies '[[org.clojure/clojure "1.8.0"]
-                  [incanter "1.9.0"]])
+                  [org.clojure/data.csv "0.1.3"]
+                  [incanter "1.9.0"]
+                  [adzerk/boot-test "1.2.0" :scope "test"]])
+
+(require '[adzerk.boot-test :refer [test]])

 (task-options!
     aot {:all true}


add more tests for English generation

add more tests for English generation

--- test/babel/test/en.cljc
+++ test/babel/test/en.cljc
@@ -410,7 +410,52 @@
                                          :obj :unspec
                                          :aspect :progressive
                                          :subj {:pred :I}}}})]
-    {:fo (fo result)
-     :tense (get-in result [:synsem :sem :tense] :wtf)}))
-
-
+    (not (nil? result))))
+
+(deftest generate-with-put
+  (let [result (generate {:synsem {:sem {:obj :unspec
+                                         :subj {:pred :gianluca},
+                                         :pred :put}
+                                   :cat :verb}})]
+    (is (not (nil? result)))))
+
+(deftest generate-with-sleep
+  (let [result (generate {:synsem {:sem {:obj :unspec
+                                         :subj {:pred :gianluca},
+                                         :pred :sleep}
+                                   :cat :verb}})]
+    (is (not (nil? result)))))
+
+(deftest generate-with-wash-oneself-1
+  (let [result (generate {:synsem {:sem {:subj {:pred :gianluca},
+                                         :pred :wash-oneself
+                                 ;;        :reflexive true
+                                         ;;:obj {:pred :gianluca}
+                                         }
+                                   :cat :verb}})]
+    (is (not (nil? result)))))
+
+(deftest generate-with-comb-oneself-1
+  (let [result (generate {:synsem {:sem {:subj {:pred :gianluca},
+                                         :pred :comb-oneself
+                                 ;;        :reflexive true
+                                         ;;:obj {:pred :gianluca}
+                                         }
+                                   :cat :verb}})]
+    (is (not (nil? result)))))
+
+(deftest generate-with-comb-oneself-2
+  (let [result (generate {:synsem {:sem {:subj {:gender :masc, :number :sing, :null false, :animate true, :pred :gianluca,
+                                                :human true},
+                                         :pred :comb-oneself,
+                                         :reflexive true,
+                                         :obj {:gender :masc, :number :sing, :null false,
+                                               :animate true, :pred :gianluca, :human true},
+                                         :aspect :progressive, :tense :past}}})]
+    (is (not (nil? result)))))
+
+
+
+
+
+


use more concise namespace abbreviation

use more concise namespace abbreviation

--- src/babel/reader.clj
+++ src/babel/reader.clj
@@ -12,7 +12,7 @@
    [clojure.java.io :as io]
    [clojure.tools.logging :as log]
    [compojure.core :as compojure :refer [GET PUT POST DELETE ANY]]
-   [dag_unify.core :as unify :refer [dissoc-paths get-in ref? strip-refs unify]]
+   [dag_unify.core :as u :refer [dissoc-paths get-in ref? strip-refs unify]]
    [korma.core :as db]
    [ring.util.response :as resp]])

@@ -148,9 +148,9 @@
         target-expression
         (target-timing-fn (babel.generate/generate target-spec target-model))
         source-spec
-        (unify/strip-refs ;; TODO: consider removing strip-refs; not clear if there is any reason why we need to do it.
-         (unify/unify
-          {:synsem {:sem (unify/get-in target-expression [:synsem :sem])}}
+        (u/strip-refs ;; TODO: consider removing strip-refs; not clear if there is any reason why we need to do it.
+         (u/unify
+          {:synsem {:sem (u/get-in target-expression [:synsem :sem])}}
           basic-spec))

         ;; TODO: catch possible deref NPE exception that can happen when model is not yet loaded.
@@ -159,11 +159,11 @@
         (source-timing-fn (generate source-spec source-model))]
     (let [pairing
           {:target ((:morph target-model) target-expression)
-           :pred (unify/strip-refs
-                  (unify/get-in target-expression [:synsem :sem :pred]))
-           :tense (unify/get-in target-expression [:synsem :sem :tense])
-           :sem (unify/get-in target-expression [:synsem :sem])
-           :subj (unify/get-in target-expression [:synsem :sem :subj :pred])
+           :pred (u/strip-refs
+                  (u/get-in target-expression [:synsem :sem :pred]))
+           :tense (u/get-in target-expression [:synsem :sem :tense])
+           :sem (u/get-in target-expression [:synsem :sem])
+           :subj (u/get-in target-expression [:synsem :sem :subj :pred])
            :source (if source-expression
                      ((:morph @@(get models source-language))
                       source-expression
@@ -226,7 +226,7 @@
 (defn read-all [spec language]
   (let [spec (dissoc (unify spec
                             {:synsem {:subcat '()}})
-                     :unify/serialized)
+                     :u/serialized)

         ;; normalize for JSON lookup
         json-input-spec (if (= :top spec)


fix keyword mismatch passed to (morph): should be :from-language, not :source-language

--- src/babel/writer.clj
+++ src/babel/writer.clj
@@ -218,12 +218,12 @@
             ;; for example, (defn fill-language-by-spec) is passed a
             ;; _spec_ param which, depending on the language's
             ;; writer implementation (e.g. babel.italiano/writer searches based on :comp and :head).
-            fo (:morph model)
+            morph (:morph model)

             surface (if sentence
   	      	      (if source-language
-  	    	        (fo sentence :source-language source-language)
-                       (fo sentence)))]
+  	    	        (morph sentence :from-language source-language)
+                       (morph sentence)))]
         (if (nil? sentence)
           (let [warn-mesg (str "No sentence could be generated in language: " language " with spec:"
                                (strip-refs spec))]


Add more arities to subscribe function.

Add more arities to subscribe function.

Fixes #10

--- src/beicon/core.cljs
+++ src/beicon/core.cljs
@@ -237,10 +237,14 @@

 (defn subscribe
   "Subscribes an observer to the observable sequence."
-  [ob nf ef cf]
-  {:pre [(observable? ob)]}
-  (let [disposable (.subscribe ob nf ef cf)]
-    #(.dispose disposable)))
+  ([ob nf]
+   (subscribe ob nf nil nil))
+  ([ob nf ef]
+   (subscribe ob nf ef nil))
+  ([ob nf ef cf]
+   {:pre [(observable? ob)]}
+   (let [disposable (.subscribe ob nf ef cf)]
+     #(.dispose disposable))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Observable Transformations


Add :auth to default state.

Add :auth to default state.

--- src/uxbox/state.cljs
+++ src/uxbox/state.cljs
@@ -5,10 +5,10 @@
 (defonce state (atom {}))

 (defonce stream
-  (rs/init {:user {:fullname "Cirilla Fiona"
-                   :avatar "/images/favicon.png"}
-            :dashboard {:project-order :name
+  (rs/init {:dashboard {:project-order :name
                         :project-filter ""}
+            :route nil
+            :auth nil
             :workspace nil
             :shapes-by-id {}
             :elements-by-id {}


Slight name tweak

Slight name tweak

--- src/yada/swagger.clj
+++ src/yada/swagger.clj
@@ -65,7 +65,7 @@
   Get
   (get* [_ ctx] (rs/swagger-json spec)))

-(defrecord Swagger [spec route spec-handler]
+(defrecord Swaggered [spec route spec-handler]
   Matched
   (resolve-handler [this m]
     (cond (= (:remainder m) (str (or (:base-path spec) "") "/swagger.json"))
@@ -93,7 +93,7 @@
     ;; containing any yada/partial (or bidi/partial) entries.
     (spec-handler req))

-  ;; So that we can use the Swagger record as a Ring handler
+  ;; So that we can use the Swaggered record as a Ring handler
   clojure.lang.IFn
   (invoke [this req]
     (let [handler (make-handler ["" this])]
@@ -102,8 +102,8 @@
 (defn swaggered [spec route]
   (infof "swaggered, route is %s, spec is %s" route spec)
   (let [spec (merge spec {:paths (into {} (map to-path (route-seq (unroll-route route))))})]
-    (->Swagger spec route
-               (yada/resource (->SwaggerSpec spec (to-date (now)))))))
+    (->Swaggered spec route
+                 (yada/resource (->SwaggerSpec spec (to-date (now)))))))

 #_(pprint
    (swaggered {:info {:title "Hello World!"


Format correctly.

Format correctly.

--- src/zprint/main.cljc
+++ src/zprint/main.cljc
@@ -69,17 +69,21 @@
             (let [[exit-status in-str format-str format-stderr] running-status]
               (try [0 (slurp filename) nil nil]
                    (catch Exception e
-                     [1 nil nil
+                     [1
+                      nil
+                      nil
                       (str "Failed to open file " filename " because: " e)])))
             (let [[exit-status in-str format-str format-stderr] running-status]
               (if (= exit-status 1)
                 ; We are done, move on
                 running-status
-                (try [0 nil (zprint-file-str in-str filename) nil]
-                     (catch Exception e
-                       [1 nil nil
-                        (str "Failed to format file: " filename
-                             " because " e)]))))
+                (try
+                  [0 nil (zprint-file-str in-str filename) nil]
+                  (catch Exception e
+                    [1
+                     nil
+                     nil
+                     (str "Failed to format file: " filename " because " e)]))))
             ;
             ; See comment in -main about graalVM issues with this code
             ;
@@ -94,7 +98,9 @@
                        (.close w)
                        [0 nil nil nil])
                      (catch Exception e
-                       [1 nil nil
+                       [1
+                        nil
+                        nil
                         (str "Failed to write output file: " filename
                              " because " e)]))))
             ; Write whatever is supposed to go to stderr, if anything
@@ -168,8 +174,10 @@
             (if (and (not (clojure.string/blank? options))
                      (not valid-switch?)
                      (clojure.string/starts-with? options "-"))
-              [:complete 1
-               (str "Unrecognized switch: '" options "'" "\n" main-help-str) {}]
+              [:complete
+               1
+               (str "Unrecognized switch: '" options "'" "\n" main-help-str)
+               {}]
               running-status)
             ; Handle switches with extraneous data
             (let [[option-status exit-status option-stderr op-options]
@@ -178,7 +186,8 @@
                 running-status
                 ; Does this swtich have too much data
                 (if (and valid-switch? (not arg-count-ok?))
-                  [:complete 1
+                  [:complete
+                   1
                    (str "Error processing switch '"
                         options
                         "', providing "
@@ -187,7 +196,8 @@
                         (if (= (dec arg-count) 1) "" "s")
                         " was incorrect!"
                         "\n"
-                        main-help-str) {}]
+                        main-help-str)
+                   {}]
                   running-status)))
             ; Handle switches
             (let [[option-status exit-status option-stderr op-options]
@@ -195,9 +205,11 @@
               (if (= option-status :complete)
                 running-status
                 (if (or version? help?)
-                  [:complete 0
+                  [:complete
+                   0
                    (cond version? (:version (get-options))
-                         help? main-help-str) op-options]
+                         help? main-help-str)
+                   op-options]
                   running-status)))
             ; If this is not a switch, get any operational options off
             ; of the command line
@@ -210,12 +222,14 @@
                 (try
                   [:incomplete 0 nil (select-op-options (read-string options))]
                   (catch Exception e
-                    [:complete 1
+                    [:complete
+                     1
                      (str "Failed to use command line operational options: '"
                           options
                           "' because: "
                           e
-                          ".") {}]))))
+                          ".")
+                     {}]))))
             ; Get all of the operational-options (op-options),
             ; merging in any that were on the command line
             (let [[option-status exit-status option-stderr op-options]
@@ -254,7 +268,9 @@
                 (if explain?
                   ; Force set-options to configure using op-options
                   (do (set-options! {} "" op-options)
-                      [:complete 0 (zprint-str (get-explained-options))
+                      [:complete
+                       0
+                       (zprint-str (get-explained-options))
                        op-options])
                   running-status)))
             ; If --url try to load the args - along with other args
@@ -307,12 +323,14 @@
                                    op-options)
                      [:complete 0 nil op-options]
                      (catch Exception e
-                       [:complete 1
+                       [:complete
+                        1
                         (str "Failed to use command line options: '"
                              options
                              "' because: "
                              e
-                             ".") {}]))))
+                             ".")
+                        {}]))))
             ; We could nitialize using the op-options if we haven't done
             ; so already, but if we didn't have any command line options, then
             ; there are no op-options that matter.


reformatting for readability

reformatting for readability


Update mongoDB.clj

Update mongoDB.clj

--- src/data/mongoDB.clj
+++ src/data/mongoDB.clj
@@ -30,8 +30,8 @@
       )
     (insert-data-into-DBcollection :countries csv/read-data "countries.csv")
     (insert-data-into-DBcollection :languages csv/read-data "languages.csv")
-    (println "Initialization done!")))
+    (println "Done!")))

 (defn -main [& args]
-  (initialization))+  (initialization))


Fix help screen exit code

Fix help screen exit code

--- src/degasolv/cli.clj
+++ src/degasolv/cli.clj
@@ -154,29 +154,33 @@
   [command args command-spec]
   (let [{:keys [options arguments errors summary]}
         (parse-opts args (concat
-                          (:cli command-spec)
-                          [["-h" "--help" "Print this help page"]])
-                    :in-order true)]
+                           (:cli command-spec)
+                           [["-h" "--help" "Print this help page"]])
+                    :in-order true)
+        print-usage
+        (fn print-usage [code]
+          (exit code
+                (str (usage command summary)
+                     (if (:required-arguments command-spec)
+                       (str
+                         "\n\n"
+                         (required-args-msg
+                           (:required-arguments command-spec))
+                         "\n\n")
+                       "\n\n")
+                     (if (:subcommands command-spec)
+                       (str
+                         (command-list (keys (:subcommands command-spec)))
+                         "\n\n")
+                       ""))))]
+
     (cond
-      (or
-       (:help options)
+      (:help options)
+      (print-usage 0)
        (and
          (empty? arguments)
-         (:subcommands command-spec)))
-      (exit 1
-            (str (usage command summary)
-                 (if (:required-arguments command-spec)
-                   (str
-                    "\n\n"
-                     (required-args-msg
-                       (:required-arguments command-spec))
-                     "\n\n")
-                   "\n\n")
-                 (if (:subcommands command-spec)
-                   (str
-                    (command-list (keys (:subcommands command-spec)))
-                    "\n\n")
-                   "")))
+         (:subcommands command-spec))
+      (print-usage 1)
       errors
       (exit 1
             (string/join


don't run callbacks on a nil old-record

don't run callbacks on a nil old-record

--- src/er_cassandra/model/alia/upsert.clj
+++ src/er_cassandra/model/alia/upsert.clj
@@ -178,7 +178,7 @@
   [session :- ModelSession
    entity :- Entity
    old-record :- t/MaybeRecordSchema
-   record :- t/MaybeRecordSchema
+   record :- t/RecordSchema
    opts :- fns/UpsertOptsSchema]

   (assert (or (nil? old-record)
@@ -189,7 +189,8 @@
   (ddo [:let [opts (ts/default-timestamp-opt opts)]

         ;; serialize the old-record and record
-        old-record-ser (t/run-callbacks session entity :before-save old-record opts)
+        old-record-ser (when old-record
+                         (t/run-callbacks session entity :before-save old-record opts))
         record-ser (t/run-callbacks session entity :before-save record opts)

         :let [record-keys (-> record keys set)


Remove comment

Remove comment

--- src/exploud/util.clj
+++ src/exploud/util.clj
@@ -24,8 +24,6 @@
       (Integer/parseInt (str s))
       (catch Exception e
         nil))))
-
-;ent-indexdaemon-3.0.15-1-para-2014-07-11_10-53-25

 (defn image-details
   "Extracts details from the name of an image in the form ent-{app}-{version}-{iteration}-{year}-{month}-{day}_{hour}-{minute}-{second}"


Atomic orbitals: Fix some doc strings.

Atomic orbitals: Fix some doc strings.


Useful tidbits in core

Useful tidbits in core

--- src/aurora/editor/core.cljs
+++ src/aurora/editor/core.cljs
@@ -23,7 +23,9 @@
              (fn [_]
                (let [node->stats (:node->stats (:kn @cur-env))]
                  (dotimes [node (count node->stats)]
-                   (prn :stats node (aget node->stats node) (get-in @cur-env [:kn :plan :node->flow node]))))))
+                   (prn :stats node (aget node->stats node) (get-in @cur-env [:kn :plan :node->flow node])))
+                 (prn :total-in (reduce + (for [node (range (count node->stats))] (aget node->stats node "count-in"))))
+                 (prn :total-out (reduce + (for [node (range (count node->stats))] (aget node->stats node "count-out")))))))

   (assoc (aurora.language/FilterMap. #{} #{}))

@@ -31,6 +33,5 @@
   (def x (first (aurora.language/get-facts-compat (:kn @cur-env) :known|pretended)))
   (aurora.language/add-facts (:kn @cur-env) :forgotten (.-shape x) [x])
   (runtime/handle-feed cur-env [] {})
+  (aurora.editor.clauses/compile-state)
   )
-
-(get-in @state [:program :madlibs "e706d4c8_3bcb_4f47_af7c_62b8f48115c1"])


cljdocs

cljdocs

--- src/ganjika/core.clj
+++ src/ganjika/core.clj
@@ -4,7 +4,9 @@

 ;; TODO better interop by coercing argument types

-(defn- method-specs [^java.lang.Class c]
+(defn- method-specs
+  "Creates a seq of specs for all public methods of the provided class."
+  [^java.lang.Class c]
   (->> c
        .getDeclaredMethods
        (filter is-public)
@@ -20,42 +22,48 @@
                :param-types (.getParameterTypes m)
                :is-static (java.lang.reflect.Modifier/isStatic (.getModifiers m))}))))

-(defn hint-param [param type]
+(defn- hint-symbol
+  "Hints the provided symbol using the provided type.
+  For primitive types uses the Java wrapper classes."
+  [sym type]
   (let [boxed-primitive {"int" java.lang.Integer "long" java.lang.Long
                          "short" java.lang.Short "float" java.lang.Float
                          "double" java.lang.Double "boolean" java.lang.Boolean
                          "byte" java.lang.Byte "char" java.lang.Character}]
-    (vary-meta param assoc :tag (or (boxed-primitive (.getName type)) type))))
+    (vary-meta sym assoc :tag (or (boxed-primitive (.getName type)) type))))

-(defn build-params [use-type-hinting spec]
+(defn- build-params
+  "Given a method spec returns a list of symbols to be used as function
+  parameters (type-hinting them if necessary)"
+  [spec use-type-hinting]
   (let [params (->> spec
                     :param-count
                     range
                     (map gensym)
                     vec)]
     (if (and use-type-hinting (not (:disable-hinting spec)))
-      (map hint-param params (:param-types spec))
+      (map hint-symbol params (:param-types spec))
       params)))

 (defn- build-arity
-  "TODO"
+  "Giving a spec builds the arity part of a fn, i.e.: `([params] body)."
   [instance no-currying use-type-hinting spec]
   (let [raw-method-symbol (symbol (str "." (:raw-name spec)))
-        params (build-params use-type-hinting spec)
+        params (build-params spec use-type-hinting)
         is-void (:is-void spec)]
     (cond
-     ;; define function for static method
+     ;; arity for static method
      (:is-static spec)
      (let [static-method-symbol (symbol (str (:class-name spec) "/" (:raw-name spec)))]
        `([~@params] (~static-method-symbol ~@params)))
-     ;; define non-curried function
+     ;; arity for non-curried function
      no-currying
      `([this# ~@params]
        (let [result# (~raw-method-symbol this# ~@params)]
          (if ~is-void
            this#
            result#)))
-     ;; define curried function
+     ;; arity for curried function
      :else
      `([~@params]
        (let [result# (~raw-method-symbol @~instance ~@params)]
@@ -63,12 +71,14 @@
            @~instance
            result#))))))

-(defn build-function
-  "TODO make private"
+(defn- build-function
+  "Builds a fn definition with n arities, where n is (count specs).
+  The function will curry the target-sym unless no-currying is true.  If
+  type-hinting is true, type-hinted all the function parameters (unless
+  the spec forbids it with :disable-hinting)."
   [target-sym no-currying type-hinting [fn-name specs]]
   (let [fn-symbol (symbol fn-name)
-        use-type-hinting type-hinting
-        arity-fn (partial build-arity target-sym no-currying use-type-hinting)]
+        arity-fn (partial build-arity target-sym no-currying type-hinting)]
     `(defn ~fn-symbol ~@(map arity-fn specs))))

 (defn- define-symbol
@@ -78,14 +88,21 @@
         obj-symbol (gensym class-name)]
     (eval `(def ~obj-symbol ~object))))

-(defn- remove-repeated-arities [specs]
+(defn- remove-repeated-arities
+  "Given a seq of specs with the same :name, removes the ones that have
+  repeated arities."
+  ;; TODO take into account repeated arities for methods with the same name
+  ;; but different modifiers (static/non-static)
+  [specs]
   (map (fn [[_ [spec & has-specs-with-same-arity]]]
          (if has-specs-with-same-arity
            (assoc spec :disable-hinting true)
            spec))
        (group-by :param-count specs)))

-(defn build-specs [clazz]
+(defn build-specs
+  "Given a class builds map of method specs grouped by :name"
+  [clazz]
   (->> clazz
        method-specs
        (group-by :name)


Fully qualify that classname

Fully qualify that classname

--- src/grimoire/doc.clj
+++ src/grimoire/doc.clj
@@ -15,11 +15,11 @@
 (defn var->type [v]
   {:pre [(var? v)]}
   (let [m (meta v)]
-    (cond (:macro m)               :macro
+    (cond (:macro m)                            :macro
           (or (:dynamic m)
-              (.isDynamic ^Var v)) :var
-          (fn? @v)                 :fn
-          :else                    :var)))
+              (.isDynamic ^clojure.lang.Var v)) :var
+              (fn? @v)                          :fn
+              :else                             :var)))

 (defn var->thing


change within to be gte/lte

change within to be gte/lte

--- src/karras/sugar.clj
+++ src/karras/sugar.clj
@@ -44,7 +44,7 @@
 (defn lte        [field y]   {field {:$lte y}})
 (defn gte        [field y]   {field {:$gte y}})
 (defn eq         [field y]   {field y})
-(defn within     [field y z] {field {:$gt y :$lt z}})
+(defn within     [field y z] {field {:$gte y :$lte z}})
 (defn ne         [field y]   {field {:$ne y}})
 (defn in         [field ys]  {field {:$in ys}})
 (defn not-in     [field ys]  {field {:$nin ys}})


try more env variables

try more env variables

--- src/holston/core.clj
+++ src/holston/core.clj
@@ -25,6 +25,9 @@
   (println (System/getenv name))
   (println (str "and now a var which we kinda know works" (System/getenv "DATABASE_URL")))
   (println (System/getenv "DATABASE_URL"))
+  (println "user and path")
+  (println (System/getenv "USER"))
+  (println (System/getenv "PATH"))
   (println "Now the or..")
   (or (System/getenv name)
       (throw (Exception. (str "Mandatory environment variable missing: " name)))))


fix link opening broken by router code

fix link opening broken by router code

--- src/chat/client/router.cljs
+++ src/chat/client/router.cljs
@@ -23,10 +23,11 @@
                                                                    href
                                                                    (when-let [parent (.-parentNode e)]
                                                                      (recur parent)))) (.-target e))]
-                                                (let [path (.getPath (.parse Uri href))]
-                                                  (when (secretary/locate-route path)
-                                                    (. h (setToken path))
-                                                    (.preventDefault e))))))))
+                                                (when (.hasSameDomainAs (.parse Uri href) (.parse Uri js/window.location))
+                                                  (let [path (.getPath (.parse Uri href))]
+                                                    (when (secretary/locate-route path)
+                                                      (. h (setToken path))
+                                                      (.preventDefault e)))))))))

 (defn dispatch-current-path! []
   (secretary/dispatch! (.getPath (.parse Uri js/window.location))))


tweak square-element

tweak square-element

--- src/chessground/common.cljs
+++ src/chessground/common.cljs
@@ -20,7 +20,9 @@
   "If element is a square, return it. If it's a piece, return its parent"
   (if (has-class dom-element "square")
     dom-element
-    (when (has-class dom-element "piece") (square-element (.-parentNode dom-element)))))
+    (when (has-class dom-element "piece")
+      (let [parent (.-parentNode dom-element)]
+        (when (has-class parent "square") parent)))))

 (defn square-key [dom-element]
   "Gets the square key from the element, or its parent"


implement error-handling on go-get-data!

--- src/cljs/foosball/data.cljs
+++ src/cljs/foosball/data.cljs
@@ -14,6 +14,10 @@
   (let [key (if (seq? key) key [key])]
     (get-in @app key)))

+(defn throw-err [e]
+  (when (instance? js/Error e) (throw e))
+  e)
+
 (defn go-get-data!
   "Asynchronously gets data from a server (using HTTP GET) and stores this inside given app.
   Takes a map of options which can be used to customize behaviour:
@@ -27,30 +31,29 @@
   :error-handler (default: rethrows) on errors this is called"
   [{:keys [server-url app key
            satisfied-with-existing-app-data? server-data-transform on-data-complete
-           set-to-nil-until-complete]
+           set-to-nil-until-complete error-handler]
     :or {satisfied-with-existing-app-data? false
          server-data-transform identity
          on-data-complete (constantly false)
-         error-handler false
+         error-handler (constantly false)
          set-to-nil-until-complete false}
     :as options}]
   (assert (and server-url app key))
-  (when set-to-nil-until-complete
-    (om/update! app key nil))
-  (let [current-value (when satisfied-with-existing-app-data? (client-data options))]
-    (if-not (nil? current-value)
-      (on-data-complete current-value)
-      (go (let [response  (<! (get-data server-url))
-                new-value (-> response :body server-data-transform)]
-            (om/update! app key new-value)
-            (on-data-complete new-value))))))
+  (try
+    (do
+      (when set-to-nil-until-complete
+        (om/update! app key nil))
+      (let [current-value (when satisfied-with-existing-app-data? (client-data options))]
+        (if-not (nil? current-value)
+          (on-data-complete current-value)
+          (go (let [response  (throw-err (<! (get-data server-url)))
+                    new-value (-> response :body server-data-transform)]
+                (om/update! app key new-value)
+                (on-data-complete new-value))))))
+    (catch js/Error e (error-handler e))))

 (defn add-uuid-key [ds]
   (mapv (fn [d] (merge d {:key (uuid/make-random-uuid)})) ds))

 (defn post! [url data]
   (http/post url {:edn-params data}))
-
-(defn throw-err [e]
-  (when (instance? js/Error e) (throw e))
-  e)


Actually don't collide with the player on release

Whoops, this was bogus

--- src/cljs/kindness/game.cljs
+++ src/cljs/kindness/game.cljs
@@ -376,7 +376,7 @@
         [[x1 y1 w1 h1] [x2 y2 w2 h2]] (map utils/position-and-bounds both)]
     ;; nobody can collide with
     ;; an entity that doesn't have bounds
-    (and (seq (filter identity boundables))
+    (and (= (count (remove nil? boundables)) (count both))
          (or (tap-print
               "top-right"
               (and (<= x1 x2 (+ x1 w1))


Allow for NVD3 to update the graph automatically without removing/redrawing it!

--- src/cljs/om_sente/core.cljs
+++ src/cljs/om_sente/core.cljs
@@ -289,7 +289,7 @@
                   (showXAxis true))]
     (.. chart -xAxis (axisLabel "Character") (tickFormat (.format js/d3 ",r")))
     (.. chart -yAxis (axisLabel "ASCII") (tickFormat (.format js/d3 ",r")))
-    (.. js/d3 (select "#nv-node") (append "svg")
+    (.. js/d3 (select "#nv-node svg")
         (datum #js [
                     #js {:values (clj->js raw-data)
                          :key "Text Data"
@@ -308,14 +308,16 @@
     om/IDidUpdate
     (did-update [this prev-props prev-state]
                 (when (graph-data-changing prev-props app)
-                  (.remove (.-firstChild (om/get-node owner "nv-node")))
+                  ;; no need to remove the SVG node, we can just pour new data into it
                   (nv-line-graph (mapv (fn [a b] {:y a :x b}) (make-target (:data/text app)) (range)))))
     om/IRender
     (render [this]
             (dom/div #js {:style #js {:height 400}
                           :react-key "nv-node"
                           :ref "nv-node"
-                          :id "nv-node"}))))
+                          :id "nv-node"}
+                     ;; add the SVG node once, NVD3 updates the data via transition
+                     (dom/svg nil)))))

 (defn secured-application
   "Component that represents the secured portion of our application."


...and actually implement it.

...and actually implement it.

--- src/cljs/vinculum/core.cljs
+++ src/cljs/vinculum/core.cljs
@@ -33,6 +33,13 @@
         chart (get-chart)]
     (.draw chart data options)))

+(defn- draw-line-chart [data div {:keys [id]}]
+  (let [{:keys [width height]}    div
+        chart (js/google.visualization.LineChart. (.getElementById js/document id))
+        options (chart-options) ;; fixme: use width/height!
+        draw-stats (clj->js (cons ["Date" "Weight"] data))]
+    (.draw chart data options)))
+
 (defn get-div-dimensions
   "Get width and height of a div with a specified id."
   [id]
@@ -58,7 +65,7 @@
     om/IDidMount
     (did-mount [_]
       (when-let [data (seq (:data cursor))]
-        (draw-chart data (:div cursor) opts)))
+        (draw-line-chart data (:div cursor) opts)))
     om/IDidUpdate
     (did-update [_ _ _]
       (let [{:keys [width height]} (:div cursor)]
@@ -66,7 +73,7 @@
           (while (.hasChildNodes n)
             (.removeChild n (.-lastChild n))))
         (when-let [data (seq (:data cursor))]
-          (draw-chart data (:div cursor) opts))))))
+          (draw-chart-chart data (:div cursor) opts))))))

 (defn handler [response]
   (swap! app-state assoc-in [:weight :data] (map #(list (:date %) (:weight %)) response)))


Make link a mailto

Make link a mailto

--- src-cljs/frontend/components/opt_in.cljs
+++ src-cljs/frontend/components/opt_in.cljs
@@ -46,5 +46,5 @@
           "As a reminder, the iOS beta is ending as of Monday, November 30th. If you have not already, please confirm a plan to lock-in pricing and ensure a smooth transition to the limited-release "
           [:a {:href "http://circleci.com/pricing"} "here"]
           ". Reach out to "
-          [:a {:href "sayhi@circleci.com"} "sayhi@circleci.com"]
+          [:a {:href "mailto:sayhi@circleci.com"} "sayhi@circleci.com"]
           " with any questions!"]]]))))


Simplify names for Java interface functions

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

--- src/conexp/contrib/java.clj
+++ src/conexp/contrib/java.clj
@@ -21,15 +21,11 @@
                      (.replaceAll "-" "_")
                      (.replaceAll " " "_")
                      (.replaceAll "!" "")
+                     (.replaceAll "\\?" "")
                      (.replaceAll "<" "_lt_")
                      (.replaceAll ">" "_gt_")
                      (.replaceAll "=" "_eq_"))]
-    (symbol
-     (if (.endsWith new-name "?")
-       (if-not (.startsWith new-name "has")
-         (str "is_" (subs new-name 0 (dec (count new-name))))
-         (subs new-name 0 (dec (count new-name))))
-       new-name))))
+    (symbol new-name)))

 (defvar- conexp-functions
   (let [public-map (ns-publics 'conexp.main)]


Fixed regression in gravitative-force

Fixed regression in gravitative-force

and now the code seems to work, although there are still some bugs (as a
DivisionByZero Exception in repulsive-force, for example...) and the
code is slow (which might be due to the with-printed-result).

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

--- src/conexp/layout/force.clj
+++ src/conexp/layout/force.clj
@@ -9,6 +9,12 @@
 ;;; Force layout as described by C. Zschalig

 ;; Helpers
+
+(defmacro with-printed-result [string & body]
+  `(let [result# (do
+		   ~@body)]
+     (println ~string result#)
+     result#))

 (defn- square
   "Squares."
@@ -187,7 +193,7 @@
     (try
      (sum [n inf-irrs,
 	   :let [phi_n (double (phi (node-positions n)
-				(node-positions (upper-neighbours n))))]]
+				    (node-positions (upper-neighbours n))))]]
 	 (cond
 	  (<= 0 phi_n phi_0)
 	  (+ phi_n
@@ -221,20 +227,17 @@

 	phi_n_i (double (phi pos-n_i pos-u_i))]
     (cond
-     (<= 0 phi_n_i phi_0)
-     (* (nth edge-rot part)
-        (/ (- (square (Math/sin phi_n_i))
-	      (square (Math/sin phi_0)))
-	   (square y_e))),
-
-     (<= phi_0 phi_n_i (- Math/PI phi_0))
-     0.0,
-
-     (<= (- Math/PI phi_0) phi_n_i Math/PI)
-     (* (nth edge-rot part)
-	(/ (- (square (Math/sin phi_0))
-	      (square (Math/sin phi_n_i)))
-	   (square y_e))))))
+     (<= y_e 0) (if (zero? part)
+		  0.0
+		  Double/NEGATIVE_INFINITY),
+     (<= phi_0 phi_n_i (- Math/PI phi_0)) 0.0,
+     :else (* (if (<= 0 phi_n_i phi_0)
+		1
+		-1)
+	      (nth edge-rot part)
+	      (/ (- (square (Math/sin phi_n_i))
+		    (square (Math/sin phi_0)))
+		 (square y_e))))))

 ;; Overall Energy and Force
@@ -246,10 +249,11 @@
 (defn layout-energy
   "Returns the overall energy of the given layout."
   [layout information]
+  (with-printed-result "energe ="
   (double
-   (+ (* *repulsive-amount* (repulsive-energy layout))
-      (* *attractive-amount* (attractive-energy layout))
-      (* *gravitative-amount* (gravitative-energy layout information)))))
+   (+ (* *repulsive-amount* (with-printed-result "rep =" (repulsive-energy layout)))
+      (* *attractive-amount* (with-printed-result "att =" (attractive-energy layout)))
+      (* *gravitative-amount* (with-printed-result "grav =" (gravitative-energy layout information)))))))

 (defn- layout-force
   "Computes overall force component of index n in the inf-irreducible elements."
@@ -257,9 +261,12 @@
   (let [part (mod n 2),
 	n_i (nth inf-irrs (div n 2))]
     (double
-     (+ (* *repulsive-amount* (repulsive-force layout n_i part information))
-	(* *attractive-amount* (attractive-force layout n_i part information))
-	(* *gravitative-amount* (gravitative-force layout n_i part information))))))
+     (+ (* *repulsive-amount* (with-printed-result (str "F_rep(" (div n 2) ", " part ") =")
+				(repulsive-force layout n_i part information)))
+	(* *attractive-amount* (with-printed-result (str "F_att(" (div n 2) ", " part ") =")
+				 (attractive-force layout n_i part information)))
+	(* *gravitative-amount* (with-printed-result (str "F_gra(" (div n 2) ", " part ") =")
+				  (gravitative-force layout n_i part information)))))))

 ;;

@@ -318,7 +325,7 @@
 	;; minimize layout energy with above placement as initial value
 	[energy, neg-force] (energy-by-inf-irr-positions lattice inf-irrs),
 	[new-points, value] (minimize energy
-				      ;;neg-force
+				      neg-force
 				      (apply concat inf-irr-points)),

 	;; make hash
@@ -341,7 +348,7 @@
 ;;;

 (defn- test-repulsive-force
-  ""
+  "Testing repulsive forces with a tiny example."
   [pos-w n_i]
   (let [layout [{:w pos-w, :w-1 [0 0], :w-2 [1 1]}
 		#{[:w-1 :w-2]}],
@@ -350,6 +357,15 @@
     [(repulsive-force layout n_i 0 {:order order}),
      (repulsive-force layout n_i 1 {:order order})]))

+(defn- test-gravitative-force
+  "Testing gravitative forces with a tiny example."
+  [pos-a]
+  (let [information {:upper-neighbours-of-inf-irrs {:a :b},
+		     :phi_0 (/ Math/PI 2)},
+	layout [{:a pos-a, :b [0 0]}, #{[:a :b]}]]
+    [(gravitative-force layout :a 0 information),
+     (gravitative-force layout :a 1 information)]))
+
 (require 'conexp)
 (defn- make-test-lattice
   ""


Comment out crypto stuff until kalium does a release

Refs abstractj/kalium#17.

--- src/icecap/crypto.clj
+++ src/icecap/crypto.clj
@@ -8,9 +8,10 @@
   location of the blob in the database) and the cap key (the key used
   to encrypt the blob).
   - An authenticated encryption scheme."
-  (:require [caesium.crypto.generichash :refer [blake2b]]
-            [caesium.crypto.secretbox :as secretbox])
-  (:import java.util Arrays))
+  ;; (:require [caesium.crypto.generichash :refer [blake2b]]
+  ;;           [caesium.crypto.secretbox :as secretbox])
+  ;; (:import java.util Arrays)
+  )

 (def master-key-bits
   "The size of the master key, in bits."
@@ -69,16 +70,16 @@
   "A personalization parameter."
   (.getBytes "icecap blob storage"))

-(defn blake2b-kdf
-  "Create a key derivation function based on BLAKE2b."
-  (reify KDF
-    (derive [_ cap master-key salt]
-      (let [output (blake2b cap :salt salt :key master-key :personal personal)
-            index-start-byte (inc cap-key-bytes)
-            index-end-byte (+ index-start-byte index-bytes)
-            index (Arrays/copyOfRange output index-start-byte index-end-byte)
-            cap-key (Arrays/copyOf output cap-key-bytes)]
-        {:index index :cap-key cap-key}))))
+;; (defn blake2b-kdf
+;;   "Create a key derivation function based on BLAKE2b."
+;;   (reify KDF
+;;     (derive [_ cap mccaster-key salt]
+;;       (let [output (blake2b cap :salt salt :key master-key :personal personal)
+;;             index-start-byte (inc cap-key-bytes)
+;;             index-end-byte (+ index-start-byte index-bytes)
+;;             index (Arrays/copyOfRange output index-start-byte index-end-byte)
+;;             cap-key (Arrays/copyOf output cap-key-bytes)]
+;;         {:index index :cap-key cap-key}))))

 (defprotocol EncryptionScheme
   "An authenticated encryption scheme."
@@ -93,13 +94,13 @@
     (encrypt [_ _ plaintext] plaintext)
     (decrypt [_ _ ciphertext] ciphertext)))

-(defn secretbox-scheme
-  "An encryption scheme based on NaCl's `secretbox`.
+;; (defn secretbox-scheme
+;;   "An encryption scheme based on NaCl's `secretbox`.

-  Please note that this uses a fixed nonce, and that's *perfectly
-  fine*. This is the only message ever encrypted with that key!"
-  (reify EncryptionScheme
-    (encrypt [_ key plaintext]
-      (secretbox/encrypt key (secretbox/int->nonce 1) plaintext))
-    (decrypt [_ key ciphertext]
-      (secretbox/decrypt key (secretbox/int->nonce 1) ciphertext))))
+;;   Please note that this uses a fixed nonce, and that's *perfectly
+;;   fine*. This is the only message ever encrypted with that key!"
+;;   (reify EncryptionScheme
+;;     (encrypt [_ key plaintext]
+;;       (secretbox/encrypt key (secretbox/int->nonce 1) plaintext))
+;;     (decrypt [_ key ciphertext]
+;;       (secretbox/decrypt key (secretbox/int->nonce 1) ciphertext))))


Hacks!

Hacks!

--- src/icecap/schema.clj
+++ src/icecap/schema.clj
@@ -1,6 +1,8 @@
 (ns icecap.schema
   "The schemata for icecap plans."
   (:require [schema.core :as s]
+            [icecap.handlers.http]
+            [icecap.handlers.delay]
             [icecap.handlers.core :refer [get-schema]]
             [icecap.execute :refer [supported-scheme?]]))

@@ -12,8 +14,8 @@
   (s/conditional ;; HACK: this implementation is quite unfortunate,
    ;; but I can't figure out how to make it any better; see also:
    ;; https://github.com/Prismatic/schema/issues/140
-   #(= (:type %) :http) (get-schema :http)
-   #(= (:type %) :delay) (get-schema :delay)))
+   #(= (:type %) :http) (get-schema {:type :http})
+   #(= (:type %) :delay) (get-schema {:type :delay})))

 (defn with-one-or-more
   "Constrain a seq schema to require one or more items.


Remove avow-config! from config/get.

Remove avow-config! from config/get.

--- src/incise/config.clj
+++ src/incise/config.clj
@@ -19,7 +19,6 @@
   [(comp string? :out-dir) "must have an output dir"])

 (defn get [& more]
-  (avow-config! @config)
   (if (empty? more)
     @config
     (apply @config more)))


minor cleanup: some imports

minor cleanup: some imports

--- src/lambdacd/util.clj
+++ src/lambdacd/util.clj
@@ -1,4 +1,6 @@
 (ns lambdacd.util
+  (:import (java.nio.file Files)
+           (java.nio.file.attribute FileAttribute))
   (:require [clojure.core.async :as async]
             [clojure.java.io :as io]
             [clojure.string :as string]
@@ -12,7 +14,7 @@
   (satisfies? clojure.core.async.impl.protocols/Channel c))

 (defn create-temp-dir []
-  (str (java.nio.file.Files/createTempDirectory "foo" (into-array java.nio.file.attribute.FileAttribute []))))
+  (str (Files/createTempDirectory "foo" (into-array FileAttribute []))))

 (defn write-as-json [file data]
   (spit file (json/write-str data)))


a teeny bit of ui

a teeny bit of ui

--- src/ligbugs/core.cljs
+++ src/ligbugs/core.cljs
@@ -55,9 +55,10 @@
                              y (range n)]
                          [[x y] (a/chan)]))
         mults (into {} (map (fn [[xy ch]] [xy (a/mult ch)]) chans))
-        in-mults (into {} (map (fn [xy] [xy (remove nil? (map mults (neighbors xy)))]) (keys chans)))]
-    (doall (map (fn [xy] (bug xy (chans xy) (in-mults xy))) (keys chans)))
-    {:mults mults}))
+        in-mults (into {} (map (fn [xy] [xy (remove nil? (map mults (neighbors xy)))]) (keys chans)))
+        stop-fns (doall (map (fn [xy] (bug xy (chans xy) (in-mults xy))) (keys chans)))]
+    {:mults mults
+     :stop (fn [] (doseq [f stop-fns] (f)))}))

 (defn bug-view [m style]
@@ -71,15 +72,42 @@
       [:div {:class "bug-wrapper" :style style}
        [:div {:class (str @class " bug")}]])))

-(defn bugs-view [mults style]
-  (let [dim (js/Math.sqrt (count mults))]
+(defn bugs-view [mults]
+  (let [dim (js/Math.sqrt (count @mults))
+        style {:height (str (dec (* 100 (/ 1 dim))) "%")
+               :width (str (dec (* 100 (/ 1 dim))) "%")}]
     [:div (for [i (range dim)]
             ^{:key i} [:div {:class "row"}
                        (for [j (range dim)]
-                         ^{:key [i j]} [bug-view (mults [i j]) style])])]))
+                         ^{:key [i j]} [bug-view (@mults [i j]) style])])]))
+
+(defn setup-view [setup-fn]
+  (let [value (atom 1)]
+    (fn []
+      [:div
+       [:label "Rows:"]
+       [:input {:type "number" :min 1 :max 1000
+                :value @value
+                :on-change #(reset! value (-> % .-target .-value))}]
+       [:button {:on-click #(setup-fn @value)} "Synchronize!"]])))
+
+(defn view []
+  (let [bugs (atom {})
+        stop-fn (atom nil)
+        reset-fn (fn [n]
+                   (if @stop-fn (@stop-fn))
+                   (let [{:keys [mults stop]} (start-grid! n)]
+                     (reset! bugs mults)
+                     (reset! stop-fn stop)))]
+    [:div
+     [setup-view reset-fn]
+     [bugs-view bugs]]))

 (defn setup-grid! [n]
   (let [{:keys [mults stop]} (start-grid! n)]
-    (reagent/render-component (fn [] [bugs-view mults {:height (str (dec (* 100 (/ 1 n))) "%")
-                                                      :width (str (dec (* 100 (/ 1 n))) "%")}])
+    (reagent/render-component (fn [] [bugs-view mults stop])
                               (.-body js/document))))
+
+
+(reagent/render-component (fn [] [view])
+                              (.-body js/document))