Use `NioServerSocketChannel` and `NioEventLoopGroup` instead of the corresponding `Epoll` classes, since the latter are Linux-specific.

--- src/riemann/transport/tcp.clj
+++ src/riemann/transport/tcp.clj
@@ -18,7 +18,7 @@
            [io.netty.handler.codec LengthFieldBasedFrameDecoder
                                    LengthFieldPrepender]
            [io.netty.handler.ssl SslHandler]
-           [io.netty.channel.epoll EpollEventLoopGroup EpollServerSocketChannel]
+           [io.netty.channel.socket.nio NioServerSocketChannel]
            [io.netty.channel.nio NioEventLoopGroup])
   (:require [less.awful.ssl :as ssl]
             [interval-metrics.core :as metrics])
@@ -117,14 +117,14 @@
   (start! [this]
           (locking this
             (when-not @killer
-              (let [boss-group (EpollEventLoopGroup.)
-                    worker-group (EpollEventLoopGroup.)
+              (let [boss-group (NioEventLoopGroup.)
+                    worker-group (NioEventLoopGroup.)
                     bootstrap (ServerBootstrap.)]

                 ; Configure bootstrap
                 (doto bootstrap
                   (.group boss-group worker-group)
-                  (.channel EpollServerSocketChannel)
+                  (.channel NioServerSocketChannel)
                   (.option ChannelOption/SO_REUSEADDR true)
                   (.option ChannelOption/TCP_NODELAY true)
                   (.childOption ChannelOption/SO_REUSEADDR true)


accept CQLRaw columns in select

accept CQLRaw columns in select

--- src/er_cassandra/record.clj
+++ src/er_cassandra/record.clj
@@ -10,7 +10,8 @@
    [er-cassandra.key :refer [flatten-key extract-key-equality-clause]]
    [er-cassandra.session :as session])
   (:import
-   [er_cassandra.session Session]))
+   [er_cassandra.session Session]
+   [qbits.hayt.cql CQLRaw]))

 ;; low-level record-based cassandra statement generation and execution
 ;;
@@ -33,8 +34,19 @@
 (s/defschema WhereSchema
   [WhereClauseSchema])

-(s/defschema ColumnsSchema
-  [(s/one s/Keyword :first-col) s/Keyword])
+(s/defschema UpdateColumnSchema
+  s/Keyword)
+
+(s/defschema UpdateColumnsSchema
+  [(s/one UpdateColumnSchema :first-col) UpdateColumnSchema])
+
+(s/defschema SelectColumnSchema
+  (s/conditional
+   keyword? s/Keyword
+   :else CQLRaw))
+
+(s/defschema SelectColumnsSchema
+  [(s/one SelectColumnSchema :first-col) SelectColumnSchema])

 (s/defschema OrderByClauseSchema
   [(s/one s/Keyword :order-by-col)
@@ -46,7 +58,7 @@
 (s/defschema LimitSchema s/Int)

 (s/defschema FullTableSelectOptsSchema
-  {(s/optional-key :columns) ColumnsSchema
+  {(s/optional-key :columns) SelectColumnsSchema
    (s/optional-key :limit) LimitSchema})

 (s/defschema SelectOptsSchema
@@ -239,7 +251,7 @@
    (s/optional-key :if-exists) s/Bool
    (s/optional-key :if-not-exists) s/Bool
    (s/optional-key :using) UpsertUsingSchema
-   (s/optional-key :set-columns) ColumnsSchema})
+   (s/optional-key :set-columns) UpdateColumnsSchema})

 (s/defn update-statement
   "returns a Hayt update statement"


bugfix regarding flash message when adding user / signup

--- resources/leiningen/new/closp/clj/routes/user.clj
+++ resources/leiningen/new/closp/clj/routes/user.clj
@@ -88,9 +88,11 @@
     (let [activationid (uservice/generate-activation-id)
           pw_crypted (hashers/encrypt password)]
       (db/create-user email pw_crypted activationid)
-      (if (when sendmail? (uservice/send-activation-email email activationid config))
-        (succ-cb-page)
-        (error-cb-page {:email-error "Something went wrong sending the email, please contact us."})))
+      (if sendmail?
+        (if (uservice/send-activation-email email activationid config)
+          (succ-cb-page)
+          (error-cb-page {:email-error "Something went wrong sending the email, please contact us."}))
+        (succ-cb-page (layout/flash-result (str "User added.") "alert-success"))))
     (let [email-error (vali/on-error :id first)
           pass-error (vali/on-error :pass first)
           confirm-error (vali/on-error :confirm first)


fixed typo

fixed typo

--- server/src/gratefulplace/controllers/topics.clj
+++ server/src/gratefulplace/controllers/topics.clj
@@ -39,7 +39,7 @@
   :exists? (exists? (record (id)))
   :handle-ok (fn [ctx]
                (if auth
-                 (t/reset-watch-count (id) (:id auth)))
+                 (ts/reset-watch-count (id) (:id auth)))
                (record-in-ctx ctx)))

 (defresource create! [params auth]


Fix join constructor. Add self-join test. Failing test case for trie-tree.

--- src/aurora/btree.cljs
+++ src/aurora/btree.cljs
@@ -415,12 +415,13 @@
         (aset seek-key moving-key-ix (.key this))
         (.maintain this))
   (up [this]
-      (assert (true? end?)) ;; ?
       (assert (> moving-key-ix 0))
       (aset seek-key moving-key-ix greatest)
       (set! moving-key-ix pinned-key-ix)
       (set! pinned-key-ix (- pinned-key-ix 1))
       (set! pinned-key (when (>= pinned-key-ix 0) (aget seek-key pinned-key-ix)))
+      (when (false? end?)
+        (.seek iterator seek-key))
       (.maintain this))
   (mark [this]
         (.mark iterator))
@@ -515,7 +516,7 @@
   (assert (> num-vars 0))
   (dotimes [i (alength iterators)]
     (let [iterator-vars (aget iterator->vars i)]
-      (assert (== (alength iterator-vars) (.key-len (aget iterators i))))
+      (assert (== (alength iterator-vars) (.-key-len (aget iterators i))))
       (dotimes [j (alength iterator-vars)]
         (assert (< (aget iterator-vars j) num-vars)))))
   (let [var->iterators #js []
@@ -528,14 +529,14 @@
         (dotimes [j (alength iterators)]
           (.push iterator->present? false))))
     (dotimes [iterator (alength iterators)]
-      (let [iterator-vars (aget iterators iterator)]
+      (let [iterator-vars (aget iterator->vars iterator)]
         (dotimes [j (alength iterator-vars)]
           (let [var (aget iterator-vars j)]
-            (.push (aget var->iterators var) iterator)
+            (.push (aget var->iterators var) (aget iterators iterator))
             (aset var->iterator->present? var iterator true)))))
     (dotimes [i num-vars]
       (assert (> (alength (aget var->iterators i)) 0))
-      (.push var->intersection i (intersection (aget var->iterators i))))
+      (.push var->intersection (intersection (aget var->iterators i))))
     (let [join (Join. 0 iterators var->intersection var->iterator->present? false num-vars)]
       (.maintain join)
       join)))
@@ -809,6 +810,24 @@
                  movements (gen/vector (gen-next key-len))] ;; TODO use gen-movement once Treeterator supports seek
                 (run-trie-tree-prop min-keys key-len actions movements)))

+(defn run-self-join-prop [min-keys key-len actions movements]
+  (let [tree (apply-to-tree (tree min-keys key-len) actions)
+        iterator-results (apply-to-iterator (iterator tree) movements)
+        iterator-a (trieterator (iterator tree))
+        iterator-b (trieterator (iterator tree))
+        join-results (apply-to-iterator
+                      (treeterator (join #js [iterator-a iterator-b] key-len #js [(into-array (range key-len)) (into-array (range key-len))]))
+                      movements)]
+    (= iterator-results join-results)))
+
+(defn self-join-prop [key-len]
+  (prop/for-all [min-keys gen/s-pos-int
+                 actions (gen/vector (gen-action key-len))
+                 movements (gen/vector (gen-next key-len))] ;; TODO use gen-movement once Treeterator supports seek
+                (run-self-join-prop min-keys key-len actions movements)))
+
+(run-trie-tree-prop 1 3 [[:assoc! #js [-86 90 "-9"] #js [-77 20 -16]] [:assoc! #js [-64 90 -44] #js [7 -8 -47]]] [[:next]])
+
 (comment
   (dc/quick-check 1000 (least-prop 1))
   (dc/quick-check 1000 (least-prop 2))
@@ -834,6 +853,10 @@
   ;; cljs.core.pr_str(cemerick.double_check.quick_check(1000, aurora.btree.intersection_prop))
   (dc/quick-check 10000 (trie-tree-prop 1))
   (dc/quick-check 10000 (trie-tree-prop 2))
+  (dc/quick-check 10000 (trie-tree-prop 3))
+  (dc/quick-check 100 (self-join-prop 1))
+  (dc/quick-check 100 (self-join-prop 2))
+  (dc/quick-check 100 (self-join-prop 3))

   (defn f []


make all args of (lightning-bolt) required

--- src/babel/forest.cljc
+++ src/babel/forest.cljc
@@ -156,6 +156,7 @@
                               (lightning-bolt grammar lexicon
                                               (get-in parent [:head])
                                               (+ 1 depth)
+                                              index morph)]
                           (if (empty? phrasal-children)
                             (let [message (str "no phrasal children for parent: '" (morph parent) "' with rule: " (get-in parent [:rule]) ") and cat: " (get-in spec [:synsem :cat]))]
                               (log/debug message))


fix main

fix main

--- uberjar/src/dda/pallet/dda_user_crate/main.clj
+++ uberjar/src/dda/pallet/dda_user_crate/main.clj
@@ -36,7 +36,7 @@
     ""
     "user.edn"
     "  - follows the edn format."
-    "  - has to be a valid UserDomainConfig (see: https://github.com/DomainDrivenArchitecture/dda-user-crate)"
+    "  - has to be a valid UserConventionConfig (see: https://github.com/DomainDrivenArchitecture/dda-user-crate)"
     ""]))

 (defn -main [& args]
@@ -48,21 +48,21 @@
       (not= (count arguments) 1) (mh/exit 1 (usage summary))
       (:serverspec options) (if (core-app/existing-serverspec
                                   app/crate-app
-                                  {:domain (first arguments)
+                                  {:convention (first arguments)
                                    :targets (:targets options)
                                    :verbosity verbose})
                                 (mh/exit-test-passed)
                                 (mh/exit-test-failed))
       (:configure options) (if (core-app/existing-configure
                                   app/crate-app
-                                  {:domain (first arguments)
+                                  {:convention (first arguments)
                                    :targets (:targets options)})
                              (mh/exit-default-success)
                              (mh/exit-default-error))
       :default (let [result (core-app/existing-install
                                 app/crate-app
-                                {:domain (first arguments)
-                                :targets (:targets options)})]
+                                {:convention (first arguments)
+                                 :targets (:targets options)})]
                   (if result
                       (mh/exit-default-success)
                       (mh/exit-default-error))))))


CMR-5129 Updates doc string.

CMR-5129 Updates doc string.

--- umm-lib/src/cmr/umm/iso_smap/granule/orbit.clj
+++ umm-lib/src/cmr/umm/iso_smap/granule/orbit.clj
@@ -51,7 +51,8 @@
             end-lat (convert-direction end-direction))))

 (defn- coerce-float
-  "Coerce's string to float, catches exceptions and produces error message."
+  "Coerce's string to float, catches exceptions and logs error message and returns nil if
+  value is not parseable."
   [field value]
   (try
     (Float. value)


implement cumulative sum in QP

implement cumulative sum in QP

--- src/metabase/driver/generic_sql/query_processor.clj
+++ src/metabase/driver/generic_sql/query_processor.clj
@@ -215,8 +215,7 @@
 (defn- query-is-cumulative-sum?
   "Is this a cumulative sum query?"
   [query]
-  (some->> query
-           :aggregation
+  (some->> (:aggregation query)
            first
            (= "cum_sum")))


JOINing works

JOINing works

--- src/metabase/driver/generic_sql/query_processor.clj
+++ src/metabase/driver/generic_sql/query_processor.clj
@@ -177,10 +177,16 @@
                :simple first-subclause))))

-(defmethod apply-form :join-tables [[_ ]])
+(defmethod apply-form :join-tables [[_ join-tables]]
+  (vec (for [{:keys [table-name pk-field source-field]} join-tables]
+         `(join ~table-name
+                (~'= ~(keyword (format "%s.%s" (:name (:source-table (:query qp/*query*))) (:field-name source-field)))
+                     ~(keyword (format "%s.%s" table-name                                  (:field-name pk-field))))))))
+

 (defmethod apply-form :limit [[_ value]]
   `(limit ~value))
+

 (defmethod apply-form :order-by [[_ subclauses]]
   (vec (for [{:keys [field direction]} subclauses]
@@ -215,6 +221,7 @@
                                                                `(~let-form ~binding-form                     ; has to go there to work correctly
                                                                            (sql-only ~@body))))
                                                       (s/replace #"\sFROM" "\nFROM")                         ; add newlines to the SQL to make it more readable
+                                                      (s/replace #"\sLEFT JOIN" "\nLEFT JOIN")
                                                       (s/replace #"\sWHERE" "\nWHERE")
                                                       (s/replace #"\sGROUP BY" "\nGROUP BY")
                                                       (s/replace #"\sORDER BY" "\nORDER BY")


update example build.clj with try/catch

update example build.clj with try/catch

shouldn't crash if the compiler runs into an error.

--- dev/build.clj
+++ dev/build.clj
@@ -29,7 +29,6 @@
                          :public-dir (io/file "target/cljs") ;; where should the output go
                          :public-path "target/cljs") ;; whats the path the html has to use to get the js?
                   (cljs/step-find-resources-in-jars) ;; finds cljs,js in jars from the classpath
-                  (cljs/step-find-resources "lib/js-closure" {:reloadable false})
                   (cljs/step-find-resources "test-data") ;; find cljs in this path
                   (cljs/step-finalize-config) ;; shouldn't be needed but is at the moment
                   (cljs/step-compile-core)    ;; compile cljs.core
@@ -38,12 +37,16 @@

     ;; compile, flush, reload, repeat
     (loop [state state]
-      (recur (-> state
-                 (cljs/step-compile-modules)
-                 (cljs/flush-to-disk)
-                 (cljs/flush-unoptimized)
-                 (cljs/wait-and-reload!)
-                 ))))
+      (let [new-state (try
+                        (-> state
+                            (cljs/step-compile-modules)
+                            (cljs/flush-unoptimized)
+                            (cljs/wait-and-reload!))
+                        (catch Throwable t
+                          (prn [:failed-to-compile t])
+                          (.printStackTrace t)
+                          (cljs/wait-and-reload! state)))]
+        (recur new-state))))
   ;; never really gets here, ctrl+c to stop
   :done)

@@ -58,7 +61,6 @@
              :public-dir (io/file "target/cljs")
              :public-path "target/cljs")
       (cljs/step-find-resources-in-jars)
-      (cljs/step-find-resources "lib/js-closure" {:reloadable false})
       (cljs/step-find-resources "test-data")
       (cljs/step-finalize-config)
       (cljs/step-compile-core)
@@ -87,7 +89,6 @@
              :public-dir (io/file "target/cljs")
              :public-path "target/cljs")
       (cljs/step-find-resources-in-jars)
-      (cljs/step-find-resources "lib/js-closure" {:reloadable false})
       (cljs/step-find-resources "test-data")
       (cljs/step-finalize-config)
       (cljs/step-compile-core)
@@ -127,7 +128,6 @@
              :public-dir (io/file "target/cljs")
              :public-path "target/cljs")
       (cljs/step-find-resources-in-jars)
-      (cljs/step-find-resources "lib/js-closure" {:reloadable false})
       (cljs/step-find-resources "test-workers")
       (cljs/step-finalize-config)
       (cljs/step-compile-core)


Allow for https via proxy

Allow for https via proxy

--- src/cfpb/qu/views.clj
+++ src/cfpb/qu/views.clj
@@ -41,6 +41,12 @@
                   :build_url (@project :build-url)
                   :api_name (env :api-name)})

+(defn- request-protocol
+  [request]
+  (if-let [proto (get-in request [:headers "x-forwarded-proto"])]
+    proto
+    (name (:scheme request))))
+
 (defn json-error
   ([status] (json-error status {}))
   ([status body]
@@ -292,7 +298,7 @@
 (defmulti slice-query (fn [format _ _] format))

 (defmethod slice-query "text/html"
-  [_ resource {:keys [query metadata slicedef headers dimensions]}]
+  [_ resource {:keys [request query metadata slicedef headers dimensions]}]
   (let [desc (partial concept-name metadata query)
         dataset (get-in resource [:properties :dataset])
         slice (get-in resource [:properties :slice])
@@ -339,7 +345,7 @@
      "text/html;charset=UTF-8"
      (layout-html resource
                   (slice-html
-                   {:action (str "http://" (headers "host") base-href)
+                   {:action (str (request-protocol request) "://" (headers "host") base-href)
                     :base-href base-href
                     :metadata-href (urls/slice-metadata-path dataset slice)
                     :dataset dataset


Added support for with-out-str using *print-fn* [cljs-321]

--- src/clj/cljs/core.clj
+++ src/clj/cljs/core.clj
@@ -1156,3 +1156,14 @@
            (~'f)
            ~(gen-apply-to-helper))))
      (set! ~'*unchecked-if* false)))
+
+(defmacro with-out-str
+  "Evaluates exprs in a context in which *print-fn* is bound to .append
+  on a fresh StringBuffer.  Returns the string created by any nested
+  printing calls."
+  [& body]
+  `(let [sb# (goog.string/StringBuffer.)]
+     (binding [cljs.core/*print-fn* (fn [x#] (.append sb# x#))]
+       ~@body)
+     (cljs.core/str sb#)))
+


Fixes for nested hosting situations.

Fixes for nested hosting situations.

--- src/clj/game/core.clj
+++ src/clj/game/core.clj
@@ -23,7 +23,7 @@
     (say state side {:user "__system__" :text (str username " " text "." (when hr "[hr]"))}))))

 (declare prompt! forfeit trigger-event handle-end-run trash update-advancement-cost update-all-advancement-costs
-         update-all-ice update-ice-strength update-breaker-strength all-installed resolve-steal-events)
+         update! get-card update-all-ice update-ice-strength update-breaker-strength all-installed resolve-steal-events)

 (defn can-pay? [state side & args]
   (let [costs (merge-costs (remove #(or (nil? %) (= % [:forfeit])) args))
@@ -106,13 +106,35 @@
        (gain state :runner :memory mu))
      c)))

+(defn get-nested-host [state card]
+  (if (:host card) (recur state (:host card)) card))
+
+(defn update-hosted! [state side {:keys [cid] :as card}]
+  (if-let [h (get-card state (:host card))]
+    (recur state side (let [[head tail] (split-with #(not= (:cid %) cid) (:hosted h))]
+                        (assoc h :hosted (vec (concat head [card] (rest tail))))))
+    (update! state side card)))
+
+(defn remove-from-host [state side {:keys [cid] :as card}]
+  (let [host-card (get-card state (:host card))]
+    (update-hosted! state side (update-in host-card [:hosted] (fn [coll] (remove-once #(not= (:cid %) cid) coll))))))
+
+(defn get-card-hosted [state {:keys [cid zone side host] :as card}]
+  (let [root-host (get-card state (get-nested-host state card))
+        helper (fn search [card target]
+                 (if (nil? card)
+                   nil
+                   (if-let [c (some #(when (= (:cid %) (:cid target)) %) (:hosted card))]
+                     c
+                     (some #(when-let [s (search % target)] s) (:hosted card)))))]
+    (helper root-host card)))
+
 (defn get-card [state {:keys [cid zone side host type] :as card}]
   (if (= type "Identity")
     (get-in @state [(to-keyword side) :identity])
     (if zone
       (if host
-        (let [h (get-card state host)]
-          (some #(when (= cid (:cid %)) %) (:hosted h)))
+        (get-card-hosted state card)
         (some #(when (= cid (:cid %)) %)
               (get-in @state (cons (to-keyword side) (map to-keyword zone)))))
       card)))
@@ -121,9 +143,8 @@
   (if (= type "Identity")
     (when (= side (to-keyword (:side card)))
       (swap! state assoc-in [side :identity] card))
-    (if-let [h (get-card state host)]
-      (let [[head tail] (split-with #(not= (:cid %) cid) (:hosted h))]
-        (update! state side (assoc h :hosted (vec (concat head [card] (rest tail))))))
+    (if host
+      (update-hosted! state side card)
       (let [z (cons (to-keyword (:side card)) zone)
             [head tail] (split-with #(not= (:cid %) cid) (get-in @state z))]
         (when-not (empty? tail)
@@ -144,7 +165,7 @@
                          (some #(when (= cid (:cid %)) %) (get-in @state (cons :runner (vec zone))))
                          (some #(when (= cid (:cid %)) %) (get-in @state (cons :corp (vec zone))))))
        (doseq [h (:hosted card)]
-         (trash state side (dissoc (update-in h [:zone] #(map to-keyword %)) :facedown)))
+         (trash state side (dissoc (update-in h [:zone] #(map to-keyword %)) :facedown) {:unpreventable true}))
        (let [dest (if (sequential? to) (vec to) [to])
              c (if (and (= side :corp) (= (first dest) :discard) (:rezzed card))
                  (assoc card :seen true) card)
@@ -160,12 +181,8 @@
            (swap! state update-in (cons side dest) #(conj (vec %) moved-card)))
          (doseq [s [:runner :corp]]
            (if host
-             (when-let [host-card (some #(when (= (:cid host) (:cid %)) %)
-                                        (get-in @state (cons s (vec zone))))]
-               (update! state side (update-in host-card [:hosted]
-                                              (fn [coll] (remove-once #(not= (:cid %) cid) coll)))))
-             (swap! state update-in (cons s (vec zone))
-                    (fn [coll] (remove-once #(not= (:cid %) cid) coll)))))
+             (remove-from-host state side card)
+             (swap! state update-in (cons s (vec zone)) (fn [coll] (remove-once #(not= (:cid %) cid) coll)))))
          (let [z (vec (cons :corp (butlast zone)))
                n (last z)]
            (when (and (not keep-server-alive)


Added preliminary server address

Added preliminary server address

--- src/cljs/sbsk/db.cljs
+++ src/cljs/sbsk/db.cljs
@@ -4,7 +4,8 @@
             [cljs-http.client :as http]
             [cljs.core.async :refer [<!]]
             [cognitect.transit :as t]))
-
+(def server-address
+  "ec2-54-89-240-173.compute-1.amazonaws.com")
 (def data-loc-prefix
   "https://s3-us-west-2.amazonaws.com/sbsk-data-segmented/data.")
 (def data-loc-suffix
@@ -55,7 +56,7 @@
                       :search-pending? true
                       :search query)]
     (when (> (count query) 3)
-      (go (let [result (<! (http/get "http://localhost:3000"
+      (go (let [result (<! (http/get (str "http://" server-address ":3000")
                                      {:query-params {:q query}
                                       :with-credentials? false}))]
             (when (:success result)


stop accepting blank answers

stop accepting blank answers

--- src/cljs/daveconservatoire/site/ui/exercises.cljs
+++ src/cljs/daveconservatoire/site/ui/exercises.cljs
@@ -103,9 +103,11 @@
   {:action
    (fn []
      (let [{::keys [ex-answer correct-answer streak-count class last-error] :as props} (get-in @state ref)]
-       (if (= ex-answer correct-answer)
-         (let [next-streak (inc streak-count)
-               new-props   (if last-error
+       (js/console.log ex-answer)
+       (if (and ex-answer (not= ex-answer "") )
+         (if (= ex-answer correct-answer)
+           (let [next-streak (inc streak-count)
+                 new-props (if last-error
                              (assoc props ::streak-count next-streak
                                           ::last-error false)
                              (new-round class
@@ -113,9 +115,9 @@
                                       {::streak-count next-streak
                                        ::hints-used   0
                                        ::ex-answer    nil})))]
-           (swap! state assoc-in ref new-props)
-           (play-sound new-props))
-         (swap! state update-in ref assoc ::streak-count 0 ::last-error true))))
+             (swap! state assoc-in ref new-props)
+             (play-sound new-props))
+           (swap! state update-in ref assoc ::streak-count 0 ::last-error true)))))

    :remote
    (let [{::keys [name streak-count ex-total-questions hints-used]} (get-in @state ref)]


fixed registry edit

fixed registry edit

--- src/cljs/swarmpit/component/registry_v2/edit.cljs
+++ src/cljs/swarmpit/component/registry_v2/edit.cljs
@@ -23,7 +23,8 @@
      :variant         "outlined"
      :defaultValue    value
      :required        true
-     :InputLabelProps {:shrink true}}))
+     :InputLabelProps {:shrink true}
+     :onChange        #(state/update-value [:url] (-> % .-target .-value) state/form-value-cursor)}))

 (defn- form-auth [value]
   (comp/switch


Update web template

Update web template

--- src/clojure/leiningen/new/web_clojure/project.clj
+++ src/clojure/leiningen/new/web_clojure/project.clj
@@ -1,10 +1,10 @@
 (defproject {{name}} "0.0.1-SNAPSHOT"
   :description "FIXME: write this!"
   :dependencies [[org.clojure/clojure "1.6.0"]
-                 [org.clojure/clojurescript "0.0-2234"]
+                 [org.clojure/clojurescript "0.0-2268"]
                  [ring "1.3.0"]]
   :plugins [[lein-cljsbuild "1.0.3"]
-            [lein-ring "0.8.10"]]
+            [lein-ring "0.8.11"]]
   :hooks [leiningen.cljsbuild]
   :source-paths ["src/clj"]
   :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]


Add some documentation.

Add some documentation.

--- src/containium/core.clj
+++ src/containium/core.clj
@@ -19,7 +19,16 @@
 (def globals (atom {}))

+;;; Root systems logic.
+
 (defn with-systems
+  "This function starts the root systems for the containium. The
+  `system-components` argument is a sequence of triples, where each
+  triple contains an identifier (likely a keyword) for the root
+  system, the symbol pointing to the start function of the system and
+  a symbol to the stop function of the system. The start function
+  takes the config from spec as an argument, whereas the stop function
+  takes that what the start function returned as an argument."
   [system-components config systems f]
   (if-let [[key start stop] (first system-components)]
     (try
@@ -34,8 +43,10 @@
     (f systems)))

+;;; Box logic.

 (defn start-box
+  "The logic for starting a box."
   [module resolve-dependencies]
   (try
     (let [box (boxure {:resolve-dependencies resolve-dependencies
@@ -49,6 +60,7 @@

 (defn start-boxes
+  "Starts all the boxes in the specified spec."
   [spec systems]
   (let [{:keys [config modules resolve-dependencies]} spec]
     (loop [modules modules
@@ -60,11 +72,28 @@
         boxes))))

+(defn stop-boxes
+  "Calls the stop function of all boxes in the specefied boxes map."
+  [boxes]
+  (doseq [[name box] boxes]
+    (try
+      ;; Box stop logic here.
+      (catch Throwable ex
+        (println "Exception while stopping module" name ":" ex)
+        ;; Kill box here?
+        ))))
+
+
+;;; Command loop.
+
 (defmulti handle-command
-  "May return a pair, where the first item is an updated state, and
-  the second item is an updated boxes. If no value is returned, or a
-  value in the pair is nil, then the state and/or boxes are not
-  updated in the command loop."
+  "This multi-method dispatches on the command (the first word in the
+  command string). It receives the arguments, the spec, the current
+  command-loop state and the running boxes map. This method may return
+  a pair, where the first item is an updated state map, and the second
+  item is an updated boxes map. If no value is returned, or a value in
+  the pair is nil, then the state and/or boxes are not updated in the
+  command-loop."
   (fn [command args spec state boxes] command))

@@ -105,6 +134,8 @@

 (defn shutdown-state
+  "Go over the current command-loop state, and shutdown anything that
+  needs shutting down when the containium is about to stop."
   [state]
   (when-let [server (:nrepl state)]
     (nrepl/stop-server server)
@@ -112,6 +143,13 @@

 (defn handle-commands
+  "This functions starts the command loop. It uses the handle-command
+  multi-method for handling the individual commands (except shutdown).
+  See the documentation on the handle-command for more info on this.
+  This function receives the spec, the root systems and a map of
+  started boxes. More boxes may be started from the command loop, or
+  stopped. Therefore, this function returns an updated map of
+  currently running boxes."
   [spec systems boxes]
   ;; Handle commands like starting and stopping modules, and stopping the application.
   ;; This can be done through typing here, updates on the file system, through sockets...
@@ -127,18 +165,13 @@
             (recur (or new-state state) (or new-boxes boxes))))))))

-(defn stop-boxes
-  [boxes]
-  (doseq [[name box] boxes]
-    (try
-      ;; Box stop logic here.
-      (catch Throwable ex
-        (println "Exception while stopping module" name ":" ex)
-        ;; Kill box here?
-        ))))
-
+;;; The coordinating functions.

 (defn run
+  "This function is used for the with-systems function. It is called
+  when all root systems are up and running. Currently it starts the
+  boxes, enters the command loop, and stops the boxes when the command
+  loop exited."
   [spec systems]
   (swap! globals assoc :systems systems)
   (let [boxes (start-boxes spec systems)


update core to expose basic API

update core to expose basic API

--- src/crucible/core.clj
+++ src/crucible/core.clj
@@ -1,7 +1,23 @@
 (ns crucible.core
-  (:require [crucible.values :refer [convert-value]]))
+  (:require [crucible.template :as tpl]
+            [crucible.resources :as res]))

-(defn encode
-  [map]
-  (convert-value map))
+(defn template
+  [& {:as elements}]
+  (tpl/make-template elements))

+(defn resource
+  [spec & properties]
+  (apply res/resource spec properties))
+
+(defn ref
+  ([r]
+   [:ref r])
+  ([r att]
+   [:ref r att]))
+
+(defn join
+  ([v]
+   [:fn [:join {:delimiter "" :values v}]])
+  ([delimiter v]
+   [:fn [:join {:delimiter delimiter :values v}]]))


don't unify with [:synsem :essere] since it causes 'babel.test.it/casa-generate'' to fail

--- src/babel/enrich.cljc
+++ src/babel/enrich.cljc
@@ -16,13 +16,12 @@

 (defn against-pred [spec lexicon]
   (let [pred (get-in spec [:synsem :sem :pred] :top)]
+    (log/debug (str "against-pred with spec: " spec " and pred: " pred))
     (if (= :top pred)
       spec
       (mapcat (fn [lexeme]
                 (let [result (unify spec
-                                    {:synsem {:sem (strip-refs (get-in lexeme [:synsem :sem] :top))}}
-                                    {:synsem {:essere (strip-refs (get-in lexeme [:synsem :essere] :top))}}
-                                    )]
+                                    {:synsem {:sem (strip-refs (get-in lexeme [:synsem :sem] :top))}})]
                   (if (not (fail? result))
                     (do
                       (log/debug (str "matched head lexeme: " (strip-refs lexeme)))


Fix css injection on app types

Fix css injection on app types

--- src-docs/com/wsscode/pathom/book/app_types.cljs
+++ src-docs/com/wsscode/pathom/book/app_types.cljs
@@ -44,6 +44,6 @@
                         :parser
                         (p/parser (-> map-db/parser-config
                                       (assoc :mutate fulcro/mutate)))))]
-      (css-injection/upsert-css id root)
+      (css-injection/upsert-css id {:component root})
       (swap! apps assoc id {::app app ::root root ::node node}))
     (js/console.warn "App type" name "is not registered")))


removed empty form

removed empty form

--- src/diary/datomic.clj
+++ src/diary/datomic.clj
@@ -4,14 +4,6 @@
             [clojure.java.io :as io])
   (:import datomic.Util))

-
-(def schema
-  )
-
-
-
-(defn upsert [conn entry]
-  (d/transact conn [entry]))

 (defn create [conn entry]
   (let [ res @(upsert conn (assoc entry :db/id (d/tempid :db.part/user)))


RS & AB | 128 | Minor indentation change in an attempt to trigger SNAP CI

--- test/mooncake/test/handler.clj
+++ test/mooncake/test/handler.clj
@@ -33,9 +33,9 @@
       (let [an-activity-src-url "https://an-activity.src"
             another-activity-src-url "https://another-activity.src"]
         (index {:context
-                 {:activity-sources
-                  {:an-activity-src an-activity-src-url
-                   :another-activity-src another-activity-src-url}}}) => (every-checker
+                {:activity-sources
+                 {:an-activity-src an-activity-src-url
+                  :another-activity-src another-activity-src-url}}}) => (every-checker
                                                                             (contains {:status 200})
                                                                             (contains {:body (contains "JDog")})
                                                                             (contains {:body (contains "KCat")}))


Add test demonstrating l-g-c failing when local repo is behind

--- test/runbld/test/main_test.clj
+++ test/runbld/test/main_test.clj
@@ -1,6 +1,6 @@
 (ns runbld.test.main-test
   (:require [cheshire.core :as json]
-            [clj-git.core :refer [git-branch git-clone git-log load-repo
+            [clj-git.core :refer [git git-branch git-clone git-log load-repo
                                   shallow-clone?]]
             [clj-http.core :as http-core]
             [clojure.java.io :as jio]
@@ -184,44 +184,103 @@
             (is (empty? @slack))))))))

 (s/deftest last-good-commit
-  (testing "last-good-commit:"
-    (testing "successful intake"
-      (let [email-body (atom :no-email-body-yet)]
-        (with-redefs [email/send* (fn [_ _ _ _ plain html attachments]
-                                    (reset! email-body html)
-                                    ;; to satisfy schema
-                                    {})
-                      slack/send (fn [& _] (prn 'slack))]
-          (let [intake-dir "tmp/git/main-intake"
-                periodic-dir "tmp/git/main-periodic"]
-            (try
-              (git/init-test-clone periodic-dir intake-dir)
-              (let [[opts-intake res-intake]
+  (let [email-body (atom "no-email-body-yet")]
+    (with-redefs [email/send* (fn [_ _ _ _ plain html attachments]
+                                (reset! email-body html)
+                                ;; to satisfy schema
+                                {})
+                  slack/send (fn [& _] (prn 'slack))]
+      (testing "successful intake"
+        (let [intake-dir "tmp/git/main-intake"
+              periodic-dir "tmp/git/main-periodic"]
+          (try
+            (git/init-test-clone periodic-dir intake-dir)
+            (let [[opts-intake res-intake]
+                  (run (conj
+                        ["-c" "test/config/main.yml"
+                         "-j" "elastic+foo+master+intake"
+                         "-d" intake-dir]
+                        (if (opts/windows?)
+                          "test/success.bat"
+                          "test/success.bash")))]
+              (let [[opts-periodic res-periodic]
+                    (run (conj
+                          ["-c" "test/config/main.yml"
+                           "-j" "elastic+foo+master+periodic"
+                           "-d" periodic-dir
+                           "--last-good-commit" "elastic+foo+master+intake"]
+                          (if (opts/windows?)
+                            "test/fail.bat"
+                            "test/fail.bash")))]
+                (is (= 0 (:exit-code res-intake)))
+                (is (= 1 (:exit-code res-periodic)))
+                (is (.contains @email-body "using successful commit")
+                    (with-out-str
+                      (println "@email-body")
+                      (prn @email-body)))))
+            (finally
+              (io/rmdir-r periodic-dir)
+              (io/rmdir-r intake-dir)))))
+      (reset! email-body "no-email-body-yet")
+      (testing "the source is updated prior to checking out l-g-c"
+        ;; The setup is when the last-good-commit is a commit "in the
+        ;; future" from the point of view of the locally checked-out copy
+        ;; of the repo.  In that case we get an exception with "fatal:
+        ;; reference is not a tree" when we attempt to checkout the l-g-c
+        ;; Simply fetching will resolve the issue.
+        (let [origin "tmp/git/origin-repo"
+              first-clone "tmp/git/first-clone"
+              second-clone "tmp/git/second-clone"]
+          (try
+            (let [origin-repo (load-repo origin)
+                  first-repo (load-repo first-clone)
+                  second-repo (load-repo second-clone)]
+              (.mkdirs (io/file (:path origin-repo)))
+              (git origin-repo "init" ["--bare"])
+              ;; Add a commit to the first repo- the one that will
+              ;; soon be out of date
+              (git-clone first-clone origin)
+              (git/add-test-commit first-clone)
+              (git first-repo "push")
+              ;; now create a new clone that will have the previous
+              ;; commit and push another new commit that first won't
+              ;; have
+              (git-clone second-clone origin)
+              (git/add-test-commit second-clone)
+              (git second-repo "push")
+              ;; Run runbld on the second clone to store the l-g-c as
+              ;; one that doesn't exist in the first
+              (let [[opts-second res-second]
                     (run (conj
                           ["-c" "test/config/main.yml"
                            "-j" "elastic+foo+master+intake"
-                           "-d" intake-dir]
+                           "-d" second-clone]
                           (if (opts/windows?)
                             "test/success.bat"
-                            "test/success.bash")))]
-                (let [[opts-periodic res-periodic]
-                      (run (conj
-                            ["-c" "test/config/main.yml"
-                             "-j" "elastic+foo+master+periodic"
-                             "-d" periodic-dir
-                             "--last-good-commit" "elastic+foo+master+intake"]
-                            (if (opts/windows?)
-                              "test/fail.bat"
-                              "test/fail.bash")))]
-                  (is (= 0 (:exit-code res-intake)))
-                  (is (= 1 (:exit-code res-periodic)))
-                  (is (.contains @email-body "using successful commit")
-                      (with-out-str
-                        (println "@email-body")
-                        (prn @email-body)))))
-              (finally
-                (io/rmdir-r periodic-dir)
-                (io/rmdir-r intake-dir)))))))))
+                            "test/success.bash")))
+                    ;; now run it on the first clone, which would
+                    ;; throw an exception were it not for the added
+                    ;; fetching
+                    [opts-first res-first]
+                    (run (conj
+                          ["-c" "test/config/main.yml"
+                           "-j" "elastic+foo+master+periodic"
+                           "-d" first-clone
+                           "--last-good-commit" "elastic+foo+master+intake"]
+                          (if (opts/windows?)
+                            "test/fail.bat"
+                            "test/fail.bash")))]
+                ;; make sure we saw what we expected to see
+                (is (= 0 (:exit-code res-second)))
+                (is (= 1 (:exit-code res-first)))
+                (is (.contains @email-body "using successful commit")
+                    (with-out-str
+                      (println "@email-body")
+                      (prn @email-body)))))
+            (finally
+              (io/rmdir-r origin)
+              (io/rmdir-r first-clone)
+              (io/rmdir-r second-clone))))))))

 (s/deftest set-scm-build
   (testing "the scm build can be set multiple ways:"


remove unneeded type hint

remove unneeded type hint

--- labs/architecture-examples/om/src/todomvc/utils.cljs
+++ labs/architecture-examples/om/src/todomvc/utils.cljs
@@ -23,7 +23,7 @@
           (reader/read-string s)
           [])))))

-(defn hidden [^boolean is-hidden]
+(defn hidden [is-hidden]
   (if is-hidden
     #js {:display "none"}
     #js {}))


RS & CM | #5 | Minor change in http-api for consistency

--- src/d_cent/http_api.clj
+++ src/d_cent/http_api.clj
@@ -15,8 +15,9 @@
           :else            api-failure)))

 (defn find-user-profile-by-twitter-id [twitter-id]
-  (let [api-response @(http/get (str utils/host-url "/api/v1/users?twitter=" twitter-id))]
-    (json/parse-string (api-response :body))))
+  (let [{:keys [body status]} @(http/get (str utils/host-url "/api/v1/users?twitter=" twitter-id))]
+    (cond (= status 200) (-> body (json/parse-string true))
+      :else          api-failure)))

 (defn create-objective [objective]
   (let [{:keys [body status]} (json-post (str utils/host-url "/api/v1/objectives") (update-in objective [:end-date] str))]


Fix the link to the online library

Fix the link to the online library

--- src/catalog/latex.clj
+++ src/catalog/latex.clj
@@ -111,7 +111,8 @@
 (defn to-url
   "Return an url given a `record-id`"
   [record-id]
-  (format "http://online.sbs.ch/iguana/www.main.cls?sUrl=search#anchor_Record_%s" record-id))
+  (let [api-key "c97386a2-914a-40c2-bd8d-df4c273175e6"]
+    (format "http://online.sbs.ch/iguana/www.main.cls?v=%s&sUrl=search%23RecordId=%s" api-key record-id)))

 (defmulti catalog-entry (fn [{fmt :format}] fmt))


Add toggle shape locking event.

Add toggle shape locking event.

--- src/uxbox/data/workspace.cljs
+++ src/uxbox/data/workspace.cljs
@@ -281,6 +281,17 @@
         (if blocked?
           (assoc-in state [:shapes-by-id sid] (assoc shape :blocked false))
           (assoc-in state [:shapes-by-id sid] (assoc shape :blocked true)))))))
+
+(defn toggle-shape-locking
+  [sid]
+  (reify
+    rs/UpdateEvent
+    (-apply-update [_ state]
+      (let [shape (get-in state [:shapes-by-id sid])
+            locked? (:locked shape false)]
+        (if locked?
+          (assoc-in state [:shapes-by-id sid] (assoc shape :locked false))
+          (assoc-in state [:shapes-by-id sid] (assoc shape :locked true)))))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Events (for selected)


bitwise-op? multimethod

bitwise-op? multimethod

--- src/atom_finder/classifier/literal-encoding.clj
+++ src/atom_finder/classifier/literal-encoding.clj
@@ -15,18 +15,17 @@
                 :dec
   ))

-(s/defmethod radix IASTNode :- s/Keyword [n :- IASTNode]
+(s/defmethod radix IASTNode :- s/Keyword [n]
   (radix (String. (.getValue n))))

-(s/defmethod bitwise-op? s/Bool [n :- IASTNode]
-  (condp instance
-      IASTBinaryExpression (bitwise-binary-op? n)
-      IASTUnaryExpression  (bitwise-unary-op? n)))
+(defmulti bitwise-op? "Check if an ASTNode represents a bitwise operator" class)
+(s/defmethod bitwise-op? IASTBinaryExpression :- s/Bool [n] false)
+(s/defmethod bitwise-op? IASTUnaryExpression :- s/Bool [n] false)

-&  bitwise AND
-|  bitwise inclusive OR
-^  bitwise XOR (eXclusive OR)
-<<  left shift
->>  right shift
-~  bitwise NOT (one's complement) (unary)
+; &  bitwise AND
+; |  bitwise inclusive OR
+; ^  bitwise XOR (eXclusive OR)
+; <<  left shift
+; >>  right shift
+; ~  bitwise NOT (one's complement) (unary)


Simplify a bit of the code

Simplify a bit of the code

--- src/io/aviso/rook.clj
+++ src/io/aviso/rook.clj
@@ -139,40 +139,49 @@
   But then, unless your name is Rich, you're in trouble already... "
   [namespace]
   (->> (ns-paths namespace)
-       (map (fn [[[request-method path] function-key]]
+       (map (fn [[[route-method route-path] function-key]]
               (when-let [fun (ns-function namespace function-key)]
-                [[request-method path] fun])))
+                [route-method route-path fun])))
        (remove nil?)
-       (sort-by #(or (-> % second meta :line) 0)))) ;sadly, the namespace stores interned values
+       ;; sadly, the namespace stores interned values
+       (sort-by #(-> % second meta :line (or 0)))))

 (defn- get-compiled-paths
   [namespace]
   (l/debugf "Scanning %s for mappable functions" namespace)
   (->> (get-available-paths namespace)
-       (map (fn [[[request-method path] fun]]
+       (map (fn [[route-method route-path fun]]
               ;; It would be nice if there was a way to qualify the path for when we are nested
               ;; inside a Compojure context, but we'd need the request to do that.
-              (l/debugf "Mapping %s `%s' to %s" (-> request-method name .toUpperCase) path fun)
-              [[request-method (clout/route-compile path)] fun]))
+              (l/debugf "Mapping %s `%s' to %s" (-> route-method name .toUpperCase) route-path fun)
+              [route-method (clout/route-compile route-path) fun]))
        (remove nil?)
        doall))

-(defn- identify-rook-data
+(defn- method-matches?
+  [request route-method]
+  (or (= :all route-method)
+      (= route-method (:request-method request))))
+
+(defn- match-request-to-compiled-path
+  [request [route-method route-path fun]]
+  (when-let [route-params (and (method-matches? request route-method)
+                               (clout/route-matches route-path request))]
+    (-> request
+        ;; Merge params previously identified by Clout/Compojure with those identified
+        ;; by this particular mathc.
+        (update-in [:route-params] merge route-params)
+        (update-in [:rook] merge {:namespace     namespace
+                                  :function      fun
+                                  :metadata      (meta fun)
+                                  :arg-resolvers (:arg-resolvers (meta fun))}))))
+
+(defn- match-against-compiled-paths
   "Uses the compiled paths to identify the matching function to be invoked and returns
-  the rook data to be added to the request. Returns nil on no match, or a map
-  containing :rook and :route-params if there is a match."
+  the rook data to be added to the request. Returns nil on no match, or a modified request map
+  when a match is found."
   [request namespace compiled-paths]
-  (some (fn [[[request-method route] fun]]
-          (when-let [route-params (and (or (= :all (:request-method request))
-                                           (= (:request-method request) request-method))
-                                       (clout/route-matches route request))]
-            {:route-params (merge (:route-params request) route-params)
-             :rook         (merge (:rook request)
-                                  {:namespace     namespace
-                                   :function      fun
-                                   :metadata      (meta fun)
-                                   :arg-resolvers (:arg-resolvers (meta fun))})}))
-        compiled-paths))
+  (some (partial match-request-to-compiled-path request) compiled-paths))

 (defn namespace-middleware
   "Middleware that scans provided namespace and if any of the functions defined there matches the route spec -
@@ -182,9 +191,12 @@
   middleware filters will typically sit between identifying the function and actually invoking it."
   [handler namespace]
   (let [compiled-paths (get-compiled-paths namespace)]
+    #_ (println (clojure.pprint/write compiled-paths))
     (fn [request]
-      (if-let [rook-data (identify-rook-data request namespace compiled-paths)]
-        (handler (merge request rook-data))
+      (if-let [request' (match-against-compiled-paths request namespace compiled-paths)]
+        (handler request')
+        ;; TODO: If there's no match, does it make sense to continue into the handler, towards the rook-handler
+        ;; that will do nothing?
         (handler request)))))

 (defn rook-handler


Specify column types for metadata values

--- src/clj/cglossa/data_import/metadata_values.clj
+++ src/clj/cglossa/data_import/metadata_values.clj
@@ -12,7 +12,8 @@
                      "TRUNCATE CLASS MetadataValue UNSAFE;"]}}]
    :source       {:file {:path "###TSV-PATH###"}}
    :extractor    {:row {}}
-   :transformers [{:csv {:separator "\t"}}
+   :transformers [{:csv {:separator "\t"
+                         :columns   ["corpus_cat:string" "value:string"]}}
                   {:vertex {:class "MetadataValue"}}
                   {:edge
                    {:class                "InCategory"
@@ -105,6 +106,12 @@
                                          :operation "remove"}})
                               other-cats)]
       (spit config-path (-> tids-template
+                            ;; Mark all columns except startpos and endpos as strings
+                            (update-in [:transformers 0 :csv]
+                                       assoc :columns (map (fn [cat] (if (get #{"startpos" "endpos"} cat)
+                                                                       cat
+                                                                       (str cat ":string")))
+                                                           cats))
                             (update-in [:transformers] concat cat-edges field-removals)
                             (cheshire/generate-string {:pretty true})
                             (str/replace "###TSV-PATH###" orig-tsv-path)


fooling around ... and it works :)

fooling around ... and it works :)

--- src/cljs/rksm/websocket_test/simple_sender.cljs
+++ src/cljs/rksm/websocket_test/simple_sender.cljs
@@ -1,4 +1,35 @@
 (ns rksm.websocket-test.simple-sender
+  (:require [cljs.core.async :refer [put! chan <! >! timeout]])
+  (:require-macros [cljs.core.async.macros :refer (go)]))
+
+(def c (chan))
+
+
+(go
+ (<! (timeout 1000))
+ (go (>! c "test"))
+    )
+
+(go (js/console.log (<! c)))
+
+(comment
+ (async/go
+  (js/console.log "foooo?")
+  (let [{:keys [ws-channel error]} (<! (ws-ch "ws://localhost:8081"))]
+    (if-not error
+      (do (>! ws-channel "Hello server from client!")
+        (loop []
+          (if-let [{:keys [message error]} (<! ws-channel)]
+            (if error
+              (js/console.log "Connection error:" error)
+              (do
+                (.log js/console "Got message from server:" (pr-str message))
+                (recur)))
+            (js/console.log "Connection closed")))
+        )
+      (js/console.log "Error:" (pr-str error))))))
+
+(comment (ns rksm.websocket-test.simple-sender
   (:require [chord.client :refer [ws-ch]]
             [cljs.core.async :refer [<! >! put! close!]])
   (:require-macros [cljs.core.async.macros :refer [go]]))
@@ -19,4 +50,5 @@
                (recur)))
            (js/console.log "Connection closed")))
        )
-     (js/console.log "Error:" (pr-str error)))))
+          (js/console.log "Error:" (pr-str error)))))
+)


Generalize the ordering functions for sorting the resources

--- src/com/puppetlabs/puppetdb/query/resources.clj
+++ src/com/puppetlabs/puppetdb/query/resources.clj
@@ -84,25 +84,25 @@
                   (into {} (for [param params :when (:name param)]
                              [(:name param) (json/parse-string (:value param))])))))))

-(defn- build-comp-fn
-  "Given a resource field and order direction, return a comparator
-  function that takes two resources and sorts them in ascending or
-  descending order based on the values of the provided field."
-  [{:keys [field order]}]
-  {:pre  [(keyword? field)
-          (or (= order "ASC")
-              (= order "DESC")
-              (nil? order))]
+(defn ordered-comparator
+  "Given a function and an order (:ascending or :descending),
+  return a comparator function that takes two objects and compares them in
+  ascending or descending order based on the value of applying the function
+  to each."
+  [f order]
+  {:pre  [(ifn? f)
+          (contains? #{:ascending :descending} order)]
    :post [(fn? %)]}
   (fn [x y]
-    (if (or (= order "ASC") (nil? order))
-      (compare (x field) (y field))
-      (compare (y field) (x field)))))
-
-(defn- combine-comp-fns
-  "Given two comparator functions, return a comparator function that
-  delegates to the first comparator, and if the result is equal, then
-  delegates to the second comparator."
+    (if (= order :ascending)
+      (compare (f x) (f y))
+      (compare (f y) (f x)))))
+
+(defn compose-comparators
+  "Composes two comparator functions into a single comparator function
+  which will call the first comparator and return the result if it is
+  non-zero; otherwise it will call the second comparator and return
+  its result."
   [comp-fn1 comp-fn2]
   {:pre  [(fn? comp-fn1)
           (fn? comp-fn2)]
@@ -113,34 +113,61 @@
         (comp-fn2 x y)
         val1))))

-(defn- sort-on-order-by
-  "Sort the results of the query based on the order by clauses."
-  [query-results order-bys]
-  {:pre  [(vector? query-results)
-          (vector? order-bys)
-          (every? map? order-bys)]
-   :post [(vector? %)
-          (= (count %)
-             (count query-results))]}
-  (let [order-bys  (mapv #(update-in % [:field] keyword) order-bys)
-        comp-fns   (map build-comp-fn order-bys)
-        final-comp (reduce combine-comp-fns comp-fns)
-        sorted     (sort final-comp query-results)]
-    (vec sorted)))
+(defn order-by-expr?
+  "Predicate that returns true if the argument is a valid expression for use
+  with the `order-by` function; in other words, returns true if the argument
+  is a 2-item vector whose first element is an `ifn` and whose second element
+  is either `:ascending` or `:descending`."
+  [x]
+  (and
+    (vector? x)
+    (ifn? (first x))
+    (contains? #{:ascending :descending} (second x))))
+
+(defn order-by
+  "Sorts a collection based on a sequence of 'order by' expressions.  Each expression
+  is a tuple containing a fn followed by either `:ascending` or `:descending`;
+  returns a collection that is sorted based on the values of the 'order by' fns
+  being applied to the elements in the original collection.  If multiple 'order by'
+  expressions are passed in, their precedence is determined by their order in
+  the argument list."
+  [order-bys coll]
+  {:pre [(sequential? order-bys)
+         (every? order-by-expr? order-bys)
+         (coll? coll)]}
+  (let [comp-fns    (map (fn [[f order]] (ordered-comparator f order)) order-bys)
+        final-comp  (reduce compose-comparators comp-fns)]
+    (sort final-comp coll)))
+
+(defn- order-by->tuple
+  "Convert an order-by entry from the paging middleware into
+  a tuple valid for use by the `ordered-comparator` fn."
+  ;; TODO: we should handle the conversion from asc/desc strings
+  ;;  to the :ascending :descending keywords in the paging
+  ;;  middleware, which should eliminate most or all of the
+  ;;  need for this function
+  [{:keys [field order]}]
+  {:pre [(string? field)
+         ((some-fn nil? string?) order)]}
+  [(keyword field)
+   (if (or (nil? order) (= "asc" (string/lower-case order)))
+      :ascending
+      :descending)])

 (defn- post-process-results
   "Given the results of the query and the optional order-by paging clauses,
   consolidate the results into a form appropriate for returning to the user
   and sort them based on the order-by clauses, if there are any."
-  [query-results {:keys [order-by]}]
+  [query-results order-bys]
   {:pre  [(vector? query-results)
-          ((some-fn nil? vector?) order-by)
-          (every? map? order-by)]
+          ((some-fn nil? vector?) order-bys)
+          (every? map? order-bys)]
    :post [(vector? %)]}
   (let [consolidated-results (consolidate-resource-params query-results)]
-    (if (empty? order-by)
+    (if (empty? order-bys)
       consolidated-results
-      (sort-on-order-by consolidated-results order-by))))
+      (let [order-bys (map order-by->tuple order-bys)]
+        (vec (order-by order-bys consolidated-results))))))

 (defn limited-query-resources
   "Take a limit, a map of paging options, and a map of SQL queries as
@@ -162,7 +189,10 @@
     (let [[query & params] results-query
           limited-query (add-limit-clause limit query)
           query-results (limited-query-to-vec limit (apply vector limited-query params))
-          results       {:result (post-process-results query-results paging-options)}]
+          results       {:result
+                          (post-process-results
+                            query-results
+                            (:order-by paging-options))}]
       (if count-query
         (assoc results :count (get-result-count count-query))
         results))))


add back missing line in notice in core.clj macro file

--- src/clj/cljs/core.clj
+++ src/clj/cljs/core.clj
@@ -1,4 +1,4 @@
-
+;   Copyright (c) Rich Hickey. All rights reserved.
 ;   The use and distribution terms for this software are covered by the
 ;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
 ;   which can be found in the file epl-v10.html at the root of this distribution.


Include PATH when throwing run errors

Include PATH when throwing run errors

--- src/clj/runbld/io.clj
+++ src/clj/runbld/io.clj
@@ -91,7 +91,8 @@
     (if (zero? (:exit res))
       (.trim (:out res))
       (throw+ {:type ::missing-file
-               :msg (format "can't find %s" name)}))))
+               :msg (format "can't find %s" name)
+               :path (System/getenv "PATH")}))))

 (s/defn readlink
   [path :- s/Str]


Store local value of input field for gateway forms in atom

This prevents the issue where entered characters get dropped when
typing quickly & events are slow

--- src/braid/core/client/gateway/helper_views.cljs
+++ src/braid/core/client/gateway/helper_views.cljs
@@ -1,5 +1,6 @@
 (ns braid.core.client.gateway.helper-views
   (:require
+   [reagent.core :as r]
    [re-frame.core :refer [subscribe dispatch]]))

 (defn with-ns [ns n]
@@ -10,34 +11,37 @@
         value @(subscribe [(with-ns (opts :subs-ns) :field-value) field-id])
         status @(subscribe [(with-ns (opts :subs-ns) :field-status) field-id])
         errors @(subscribe [(with-ns (opts :subs-ns) :field-errors) field-id])
-        on-change-transform (or (opts :on-change-transform) identity)]
-    [:div.option
-     {:class (str (opts :class) " " (name status))}
-     [:h2 (opts :title)]
-     [:label
-      [:div.field
-       (when (opts :pre-input)
-         (opts :pre-input))
-       [:input {:type (opts :type)
-                :placeholder (opts :placeholder)
-                :auto-complete (opts :auto-complete)
-                :auto-correct "off"
-                :auto-capitalize "off"
-                :spell-check "false"
-                :auto-focus (opts :auto-focus)
-                :value value
-                :on-key-down (or (opts :on-key-down) (fn [_]))
-                :on-blur (fn [e]
-                           (when (opts :on-blur)
-                             ((opts :on-blur) e))
-                           (dispatch [(with-ns (opts :disp-ns) :blur) field-id]))
-                :on-change (fn [e]
-                             (let [value (on-change-transform (.. e -target -value))]
-                               (dispatch [(with-ns (opts :disp-ns) :update-value) field-id value])))}]]
-      (when (= :invalid status)
-        [:div.error-message (first errors)])
-      (when (opts :help-text)
-        [:div.explanation (opts :help-text)])]]))
+        on-change-transform (or (opts :on-change-transform) identity)
+        value-atom (r/atom value)]
+    (fn [opts]
+      [:div.option
+       {:class (str (opts :class) " " (name status))}
+       [:h2 (opts :title)]
+       [:label
+        [:div.field
+         (when (opts :pre-input)
+           (opts :pre-input))
+         [:input {:type (opts :type)
+                  :placeholder (opts :placeholder)
+                  :auto-complete (opts :auto-complete)
+                  :auto-correct "off"
+                  :auto-capitalize "off"
+                  :spell-check "false"
+                  :auto-focus (opts :auto-focus)
+                  :value @value-atom
+                  :on-key-down (or (opts :on-key-down) (fn [_]))
+                  :on-blur (fn [e]
+                             (when (opts :on-blur)
+                               ((opts :on-blur) e))
+                             (dispatch [(with-ns (opts :disp-ns) :blur) field-id]))
+                  :on-change (fn [e]
+                               (let [value (on-change-transform (.. e -target -value))]
+                                 (reset! value-atom value)
+                                 (dispatch [(with-ns (opts :disp-ns) :update-value) field-id value])))}]]
+        (when (= :invalid status)
+          [:div.error-message (first errors)])
+        (when (opts :help-text)
+          [:div.explanation (opts :help-text)])]])))

 (defn button-view [opts]
   (let [fields-valid?


Fix indent

Fix indent

--- src/braid/core/client/ui/views/new_message.cljs
+++ src/braid/core/client/ui/views/new_message.cljs
@@ -190,7 +190,7 @@

                 KeyCodes.ESC
                 (do (stop-event! e)
-                  (set-force-close!))
+                    (set-force-close!))

                 KeyCodes.UP
                 (do (stop-event! e)


Add arrow icon for expand contract

Add arrow icon for expand contract

--- src/datadrill/core.cljs
+++ src/datadrill/core.cljs
@@ -13,9 +13,12 @@
 (declare DataDrill)

 (defn ExpandButton [{:keys [expanded? path emit-fn]}]
-  (if expanded?
-    [:button {:onClick #(emit-fn :contract path)} "-"]
-    [:button {:onClick #(emit-fn :expand path)} "+"]))
+  [:button {:style {:border "0"
+                    :backgroundColor "transparent" :width "20px " :height "20px"}
+            :onClick #(emit-fn (if expanded? :contract :expand) path)}
+   [:svg {:viewBox "0 0 100 100"}
+    [:polygon {:points (if expanded? "0,0 100,0 50,100"
+                                     "0,0 0,100 100,50") :stroke "black"}]]])

 (defn CollapseAllButton [emit-fn]
   [:button {:onClick #(emit-fn :collapse-all)} "Collapse all"])


First version of corrent component state.

--- src/cljs/hatnik/web/client/form/add_action.cljs
+++ src/cljs/hatnik/web/client/form/add_action.cljs
@@ -6,6 +6,35 @@
 (defn on-modal-close [component]
   (om/detach-root
    (om/get-node component)))
+
+(defn artifact-input-component [data owner]
+  (reify
+    om/IRender
+    (render [this]
+      (dom/div #js {:className "form-group has-warning"
+                    :id "artifact-input-group"}
+               (dom/label #js {:htmlFor "artifact-input"} "Library")
+               (dom/input #js {:type "text"
+                               :className "form-control"
+                               :placeholder "e.g. org.clojure/clojure"
+                               :onChange #((:handler data) (.. % -target -value))
+                               :value (:value data)})))))
+
+(defn action-input-form [data owner]
+  (reify
+    om/IRender
+    (render [this]
+      (dom/form nil
+                (om/build artifact-input-component (:artifact-value data))))))
+
+(defn action-footer [data owner]
+  (reify
+    om/IRender
+    (render [this]
+      (dom/div nil
+               (dom/p nil "hi: ")
+               (dom/p nil
+                      (:artifact-value data))))))

 (defn- add-action-component [data owner]
   (reify
@@ -26,9 +55,12 @@
                  (dom/h4 nil "Add new action"))

         (dom/div #js {:className "modal-body"}
-                 (dom/p nil "BODY"))
+                 (om/build action-input-form
+                           {:artifact-value
+                            {:value (:artifact-value state)
+                             :handler #(om/set-state! owner :artifact-value %)}}))
         (dom/div #js {:className "modal-footer"}
-                 (dom/p nil "FOOTER")))))
+                 (om/build action-footer state)))))

     om/IDidMount
     (did-mount [this]


use buttons instead of checkboxes for exercise answers

--- src/cljs/daveconservatoire/site/ui/exercises.cljs
+++ src/cljs/daveconservatoire/site/ui/exercises.cljs
@@ -203,18 +203,19 @@
                                       (for [[value label] options]
                                         (dom/li #js {:key value}
                                           (dom/label nil
-                                            (dom/input #js {:type     "radio" :name "exercise-answer"
-                                                            :checked  (= ex-answer value)
-                                                            :value    value
-                                                            :onChange #(um/set-string! parent ::ex-answer :event %)})
-                                            (dom/span #js {:className "value"} label)))))))
-                                (dom/div #js {:className "answer-buttons"}
-                                  (dom/div #js {:className "check-answer-wrapper"}
-                                    (dom/input #js {:className "simple-button green" :type "button" :value "Check Answer"
-                                                    :onClick   check-answer}))
-                                  (dom/input #js {:className "simple-button green" :id "next-question-button" :name "correctnextbutton" :style #js {:display "none"} :type "button" :value "Correct! Next Question..."})
-                                  (dom/div #js {:id "positive-reinforcement" :style #js {:display "none"}}
-                                    (dom/img #js {:src "/images/face-smiley.png"})))))))
+                                            (dom/button #js {:type "button"
+                                                             :onClick #(do
+                                                                        (um/set-string! parent ::ex-answer :value value)
+                                                                        (check-answer))}
+                                              label)))))))
+                                (if (contains? #{:text} opt-type)
+                                  (dom/div #js {:className "answer-buttons"}
+                                    (dom/div #js {:className "check-answer-wrapper"}
+                                      (dom/input #js {:className "simple-button green" :type "button" :value "Check Answer"
+                                                      :onClick   check-answer}))
+                                    (dom/input #js {:className "simple-button green" :id "next-question-button" :name "correctnextbutton" :style #js {:display "none"} :type "button" :value "Correct! Next Question..."})
+                                    (dom/div #js {:id "positive-reinforcement" :style #js {:display "none"}}
+                                      (dom/img #js {:src "/images/face-smiley.png"}))))))))
                         (dom/div #js {:style #js {:clear "both"}})))))))))))))

 (def exercise (om/factory Exercise))


Fixed resize logic.

Fixed resize logic.

--- src/cljs/wombats_web_client/panels/game_play.cljs
+++ src/cljs/wombats_web_client/panels/game_play.cljs
@@ -28,13 +28,10 @@
     (set! (.-width canvas-element) dimension)
     (set! (.-height canvas-element) dimension)))

-(defn- on-resize [arena-atom cmpnt-state]
-  (let [resize-id (:timeout-fn @cmpnt-state)]
-    (js/clearTimeout resize-id)
-    (let [new-resize-id (js/setTimeout
-                                   #(resize-canvas arena-atom)
-                                   500)]
-      (swap! cmpnt-state assoc :timeout-fn new-resize-id))))
+(defn- on-resize [arena-atom]
+  (resize-canvas arena-atom)
+  (js/setTimeout #(resize-canvas arena-atom)
+                 100))

 (defn- show-winner-modal
   [winner]
@@ -47,7 +44,7 @@

 (defn- component-did-mount [arena cmpnt-state]
   ;; Add resize listener
-  (let [resize-fn #(on-resize arena cmpnt-state)]
+  (let [resize-fn (:resize-fn @cmpnt-state)]
     (.addEventListener js/window
                        "resize"
                        resize-fn))
@@ -144,8 +141,7 @@

 (defn game-play [{:keys [game-id]}]
   (let [arena (re-frame/subscribe [:game/arena])
-        cmpnt-state (reagent/atom {:resize-fn nil
-                                   :timeout-fn nil})
+        cmpnt-state (reagent/atom {:resize-fn #(on-resize arena)})
         messages (re-frame/subscribe [:game/messages])
         user (re-frame/subscribe [:current-user])
         games (re-frame/subscribe [:games])]


mk-pipeline returns the state atom as well so other libraries can use it

--- src/lambdacd/core.clj
+++ src/lambdacd/core.clj
@@ -40,4 +40,5 @@
         context {:_pipeline-state state
                  :config config}]
     {:ring-handler (mk-complete-route pipeline-def state)
-     :init (partial start-pipeline-thread pipeline-def context start-next-run-after-first-step-finished)}))+     :init (partial start-pipeline-thread pipeline-def context start-next-run-after-first-step-finished)
+     :state state}))


'when' does 'do' for you

'when' does 'do' for you

--- clojure/src/dnd/core.cljs
+++ clojure/src/dnd/core.cljs
@@ -49,10 +49,9 @@

 (defn drop-handler [level character]
   (let [lastItem (last (:inventory @character))]
-    (if-not (nil? lastItem)
-      (do
-        (character/drop-item! level character lastItem)
-        (show-screen)))))
+    (when-not (nil? lastItem)
+      (character/drop-item! level character lastItem)
+      (show-screen))))

 (defn popper! [queue]
   (go-loop [q queue]


* benchmark/cljs/benchmark_runner.cljs: up range benchmark

--- benchmark/cljs/benchmark_runner.cljs
+++ benchmark/cljs/benchmark_runner.cljs
@@ -58,7 +58,7 @@
 (println)

 (println ";;; range")
-(simple-benchmark [r (range 100000)] (last r) 1)
+(simple-benchmark [r (range 1000000)] (last r) 1)
 (println)

 (println "\n")


Allow files parsed by html-parser generatered parsers to not start with an edn map.

--- src/incise/parsers/html.clj
+++ src/incise/parsers/html.clj
@@ -36,16 +36,32 @@
              :path (meta->write-path meta-with-defaults)
              :date (-> meta-with-defaults :date to-date)))))

+(defn- starts-with-curly-brace? [s] (boolean (re-find #"^\s*\{" s)))
+(defn- read-edn-map-from-beggining-of-string
+  "Returns a map from the edn present at the beginning of the string if it
+  starts with an edn map. Otherwise, return nil."
+  [s]
+  (if (starts-with-curly-brace? s)
+    (try
+      (edn/read-string s)
+      (catch RuntimeException e
+        (throw (ex-info (str "The given string seemed to start with a map, but"
+                             "failed to be interpretted as edn.")
+                        {:string s}
+                        e))))))
+
 (defn File->Parse
   "Read in a file and turn it into a Parse instance."
   [content-fn ^File file]
   (let [file-str (slurp file)
+        parse-meta-from-file (read-edn-map-from-beggining-of-string file-str)
         parse-meta (merge (conf/get :parse-defaults)
-                          (edn/read-string file-str))
-        parse-meta (if (contains? parse-meta :title)
-                     parse-meta
-                     (assoc parse-meta :title (name-without-extension file)))
-        content (content-fn (second (s/split file-str #"\}" 2)))]
+                          {:title (name-without-extension file)
+                           :layout :html-skeleton}
+                          parse-meta-from-file)
+        content (content-fn (if parse-meta-from-file
+                              (second (s/split file-str #"\}" 2))
+                              file-str))]
     (meta-and-content->Parse parse-meta content)))

 (defn write-Parse


[CIRCLE-4532] Update org-picker to reflect builds-page org (#1928)

* Update org-picker to reflect builds-page org

* Clarify when 'org' from navigation is used

--- src-cljs/frontend/controllers/navigation.cljs
+++ src-cljs/frontend/controllers/navigation.cljs
@@ -94,13 +94,13 @@

 (defmethod navigated-to :dashboard
   [history-imp navigation-point args state]
-  (let [org (if (ld/feature-on? "top-bar-ui-v-1")
-              (or (get-in state state/selected-org-path)
-                  {:login (org/name args) :vcs_type (:vcs-type args)})
-              {})] ;; Force state to update with a 'nil' value when NOT in org-centric UI
+  (let [nav-org (if (ld/feature-on? "top-bar-ui-v-1")
+                  (or (get-in state state/selected-org-path)
+                      {:login (org/name args) :vcs_type (:vcs-type args)})
+                  {})] ;; Force state to update with a 'nil' value when NOT in org-centric UI
     (-> state
-        (assoc-in state/selected-org-path org)
-        (state-utils/change-selected-org org)
+        (assoc-in state/selected-org-path nav-org)
+        (state-utils/change-selected-org nav-org)
         state-utils/clear-page-state
         (assoc state/current-view navigation-point
                state/navigation-data args
@@ -108,7 +108,7 @@
         (state-utils/set-dashboard-crumbs args)
         state-utils/reset-current-build
         state-utils/reset-current-project
-        (state-utils/change-selected-org org)
+        (state-utils/change-selected-org nav-org)
         maybe-add-workflow-response-data)))

 (defmethod post-navigated-to! :dashboard
@@ -179,7 +179,9 @@
   (let [maybe-set-container-id (fn [state]
                                  (if (not (nil? container-id))
                                    (assoc-in state state/current-container-path container-id)
-                                   state))]
+                                   state))
+        nav-org {:login org :vcs_type vcs_type}]
+
     (if (and (= :build (state/current-view state))
              (not (state-utils/stale-current-build? state project-name build-num)))
       ;; page didn't change, just switched tabs
@@ -190,6 +192,7 @@
       ;; navigated to page, load everything
       (-> state
         state-utils/clear-page-state
+        (state-utils/change-selected-org nav-org)
         (assoc state/current-view navigation-point
                state/navigation-data (assoc args :show-settings-link? false)
                :project-settings-project-name project-name)
@@ -248,7 +251,7 @@
 (defmethod navigated-to :add-projects
   [history-imp navigation-point args state]
   (let [current-user (get-in state state/user-path)
-        org (not-empty (select-keys args [:login :vcs_type]))]
+        nav-org (not-empty (select-keys args [:login :vcs_type]))]
     (-> state
         state-utils/clear-page-state
         (assoc state/current-view navigation-point
@@ -258,10 +261,10 @@
         (assoc-in state/github-repos-loading-path (user/github-authorized? current-user))
         (assoc-in state/bitbucket-repos-loading-path (user/bitbucket-authorized? current-user))
         (assoc-in state/crumbs-path [{:type :add-projects}])
-        (assoc-in state/add-projects-selected-org-path org)
+        (assoc-in state/add-projects-selected-org-path nav-org)
         (assoc-in [:settings :add-projects :repo-filter-string] "")
         (state-utils/reset-current-org)
-        (state-utils/change-selected-org org))))
+        (state-utils/change-selected-org nav-org))))

 (defn- nav-to-selected-org
   [selected-org nav-ch]
@@ -294,12 +297,12 @@

 (defmethod navigated-to :build-insights
   [history-imp navigation-point args state]
-  (let [org (not-empty (select-keys args [:login :vcs_type]))]
+  (let [nav-org (not-empty (select-keys args [:login :vcs_type]))]
     (-> state
       (assoc state/current-view navigation-point
              state/navigation-data args)
       state-utils/clear-page-state
-      (state-utils/change-selected-org org)
+      (state-utils/change-selected-org nav-org)
       (assoc-in state/crumbs-path [{:type :build-insights}]))))

 (defmethod post-navigated-to! :build-insights


Add dev-mode? fn - returns true if app is running in dev mode.

--- namespaces/common/src/main/clojure/immutant/util.clj
+++ namespaces/common/src/main/clojure/immutant/util.clj
@@ -195,3 +195,9 @@
   (if (instance? IDeref v)
     (apply deref v args)
     v))
+
+(defn dev-mode?
+  "Returns true if the app is running in dev mode."
+  []
+  (not (or (System/getenv "LEIN_NO_DEV")
+           (->> (registry/get :project) meta :active-profiles (not-any? #{:dev})))))


Add dynamic var for setting verbosity

Add dynamic var for setting verbosity

--- src/less4clj/util.clj
+++ src/less4clj/util.clj
@@ -4,6 +4,8 @@
 ;; Debugging
 ;; from boot.util
 ;;
+
+(def ^:dynamic *verbosity* 1)

 ; Hack to detect boot verbosity
 (defn- get-verbosity []
@@ -12,7 +14,7 @@
     ; Deref var and atom
     @@(resolve 'boot.util/*verbosity*)
     (catch Exception _
-      1)))
+      *verbosity*)))

 (defn- print*
   [verbosity args]