Remove modal option that doesn't seem to play well with Devcards

--- devcards_src/bootstrap_cljs_devcards.cljs
+++ devcards_src/bootstrap_cljs_devcards.cljs
@@ -379,7 +379,6 @@
                  (bs/button {:on-click #(om/set-state! owner :visible? true)} "Show Modal")
                  (when visible?
                    (bs/modal {:title "Example modal"
-                              :backdrop false
                               :animated false
                               :on-request-hide #(om/set-state! owner :visible? false)}
                              (dom/div {:class "modal-body"}


Provide a rill.event-channel.CaughtUp event

--- src/rill/event_channel.clj
+++ src/rill/event_channel.clj
@@ -1,7 +1,10 @@
 (ns rill.event-channel
   (:require [clojure.core.async :refer [thread >!! chan]]
             [rill.event-store :as store]
-            [clojure.tools.logging :as log]))
+            [rill.message :refer [defevent]]
+            [clojure.tools.logging :as log]
+            [schema.core :as s])
+  (:import (java.util Date)))

 (def long-poll-seconds 20)

@@ -25,12 +28,19 @@
     (log/debug "pushed - " r)
     r))

+;; This is the event you get from a channel when it has
+;; caught up with the current head of the event stream
+
+(defevent CaughtUp
+  :timestamp s/Inst)
+
 (defn event-channel-listen!!
   "Push events from stream into ch. Blocking"
   [event-store stream-id cursor ch]
   (loop [cursor cursor]
     (log/debug [:listen!! stream-id cursor])
     (when-let [new-cursor (push-events!! ch cursor (store/retrieve-events-since event-store stream-id cursor long-poll-seconds))]
+      (push-event!! ch (caught-up (Date.)))
       (recur new-cursor))))

 (defn event-channel


Implement topological alias sorting.

Implement topological alias sorting.

--- src/smallex/reductions.clj
+++ src/smallex/reductions.clj
@@ -14,7 +14,7 @@
   (fnil conj #{}))

 (defn- transpose-graph
-  "Given a mapping from a vertex to a set of vertices, reverse the edge
+  "Given a mapping from a vertex to a set of vertices, reverses the edge
   direction."
   [graph]
   (reduce-kv
@@ -27,11 +27,41 @@
    {}
    graph))

-(defn check-cyclic-aliases
-  "Given a grammar, returns an error if there is a cyclic alias. Returns nil if
-  the aliases aren't cyclic."
+(defn- track-cycle
+  "Returns a vector with the elements of _some_ cycle which contains root. Root
+  will be both first and last element."
+  [graph root]
+  ;; TODO
+  )
+
+(defn- toposort-transposed
+  "Returns a topological sort of transposed graph, and throws an exception if
+  the graph is cyclic."
+  [graph]
+  (let [inv (transpose-graph graph)]
+    ;; Can, strictly speaking, do an (vec (rseq original)) instead
+    (letfn [(dfs [[stack visited] to-visit]
+              (case (get visited to-visit :not-visited)
+                :walking
+                (throw (ex-info "Found cycle."
+                                {:type :cycle
+                                 :cycle (track-cycle graph to-visit)}))
+                :completed [stack visited]
+                :not-visited
+                (let [visited (assoc visited to-visit :walking)
+                      [stack visited]
+                      (reduce dfs [stack visited] (get inv to-visit))]
+                  [(conj stack to-visit)
+                   (assoc visited to-visit :completed)])))]
+      (first
+       (reduce dfs [[] {}] (keys graph))))))
+
+(defn expand-alias-order
+  "Given a grammar, returns the order to expand aliases in definitions, which
+  ensures no alias is unexpanded. Throws an error if there is a cyclic alias."
   [grammar]
-  (let [alias-deps (into {} (for [[k v] (:aliases grammar)]
-                              [k (find-alias-deps v)]))]
-    ;; TODO: Topological sort here.
-    ))
+  (let [alias-deps (into (zipmap (keys (:aliases grammar))
+                                 (repeat #{}))
+                         (for [[k v] (:aliases grammar)]
+                           [k (find-alias-deps v)]))]
+    (toposort-transposed alias-deps)))


started with import

started with import

--- src/tango/cljs/client.cljs
+++ src/tango/cljs/client.cljs
@@ -20,29 +20,6 @@
 (defn log [m]
   (.log js/console m))

-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Init DB
-(defonce conn (d/create-conn uidb/schema))
-
-(defn init-app []
-  (d/transact! conn [{:db/id -1 :app/id 1}
-                     {:db/id -1 :selected-page :competitions}
-                     ;{:db/id -1 :app/selected-competition {}}
-                     ]))
-
-(defn app-started? [conn]
-  (not
-   (empty? (d/q '[:find ?e
-                  :where
-                  [?e :app/id 1]] (d/db conn)))))
-
-(log conn)
-;;  (d/q '[:find [(pull ?c [:class/name]) ...]
-;;         :where
-;;         [?e :competition/name "A"]
-;;         [?e :competition/classes ?c]]
-;;       (d/db conn)))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Sente Socket setup

@@ -57,29 +34,41 @@
   )

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Init DB
+(defonce conn (d/create-conn uidb/schema))
+
+(defn init-app []
+  (d/transact! conn [{:db/id -1 :app/id 1}
+                     {:db/id -1 :selected-page :competitions}
+                     ;{:db/id -1 :app/selected-competition {}}
+                     ]))
+
+(defn app-started? [conn]
+  (not
+   (empty? (d/q '[:find ?e
+                  :where
+                  [?e :app/id 1]] (d/db conn)))))
+
+;(log conn)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Server message handling

 (declare reconciler)
 (defn handle-query-result [d]
-  (let [clean-data  (uidb/sanitize d)]
-    ;;{:competition/name "TestNamn" :competition/location "Location"}
-    (log "Handle Q R")
-     ;(log clean-data)
-    ;(log (apply str (map :competition/name clean-data)))
-                                        ;(d/transact! (d/db conn) )
-    ;;(d/transact! conn [clean-data])
-    ;; (log (d/q '[:find [(pull ?c [:class/name]) ...]
-    ;;             :where
-    ;;             [?e :competition/name "Rikstävling disco"]
-    ;;             [?e :competition/classes ?c]]
-    ;;           (d/db conn)))
-    ;(d/transact! conn [{:db/id 1 :competition/name (apply str (map :competition/name clean-data))}])
-    ;(om/transact! reconciler `[(app/add-competition `{:X "X"}) :app/competitions])
-    ;(log clean-data)
-    ;; (om/transact! reconciler `[(app/add-competition ~clean-data) :app/competitions
-    ;;                            ])
-    (om/transact! reconciler `[(app/add-competition ~clean-data) :app/competitions])
-    ))
+  (log "Handle Q R")
+    ;; VERY TEMPORARY (KILL ME IF I DO NOT FIX IT)
+    ;; Need to make difference between query for all comps. vs query for details for a comp.
+
+  (if (vector? d)
+    (let [clean-data  {:competitions d}      ;(uidb/sanitize (first d))
+          ]
+      (log "Compsss")
+      (om/transact! reconciler `[(app/add-competition ~clean-data) :app/competitions])
+      )
+    (let [clean-data (uidb/sanitize d)]
+      (log "Crazzzy")
+      (om/transact! reconciler `[(app/add-competition ~clean-data) :app/competitions]))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Sente message handling
@@ -87,8 +76,11 @@
 (defmulti event-msg-handler :id) ; Dispatch on event-id
 ;; Wrap for logging, catching, etc.:
 (defn event-msg-handler* [{:keys [id ?data event] :as ev-msg}]
-  (event-msg-handler {:id (first ev-msg)
-                      :?data (second ev-msg)}))
+  (do
+    (log "Enter event-msg-handler*")
+    (event-msg-handler {:id (first ev-msg)
+                        :?data (second ev-msg)})
+    (log "Exit event-msg-handler*")))

 (defmethod event-msg-handler :default ; Fallback
   [{:keys [event] :as ev-msg}]
@@ -96,30 +88,49 @@

 (defmethod event-msg-handler :chsk/state
   [{:as ev-msg :keys [?data]}]
-  (if (= ?data {:first-open? true})
-    (log "Channel socket successfully established!")
+  (if (:first-open? ?data)
+    (do
+      (log "Channel socket successfully established!")
+      (log "Fetch initilize data from Tango server")
+      (chsk-send! [:event-manager/query [[:competition/name :competition/location]]]))
     (log (str "Channel socket state change: " ?data))))

 (defmethod event-msg-handler :chsk/recv
   [{:as ev-msg :keys [?data]}]
   (let [[topic payload] ?data]
-    ;(log (str "Push event from server: " ev-msg))
     (log (str "Push event from server: " topic))
     (when (= topic :event-manager/query-result)
-      (handle-query-result (second ?data)))))
+      (if (vector? payload)
+        (handle-query-result payload)
+        (handle-query-result (second ?data))))
+    (when (= topic :event-manager/transaction-result)
+      (chsk-send! [:event-manager/query [[:competition/name :competition/location]]]))
+    (log "Exit event-msg-handler")))

 (defmethod event-msg-handler :chsk/handshake
   [{:as ev-msg :keys [?data]}]
   (let [[?uid ?csrf-token ?handshake-data] ?data]
     (log (str "Handshake: " ?data))))

-(defmethod event-msg-handler :event-manager/query-result
-  [{:as ev-msg :keys [?data]}]
-  (log (str "Event Manager Query Result " ?data)))
-
 (defonce chsk-router
   (sente/start-chsk-router-loop! event-msg-handler* ch-chsk))

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Import
+
+(defn on-file-read [e file-reader]
+  (let [result (.-result file-reader)]
+    (log "On file read : send :file/import")
+    (chsk-send! [:file/import {:content result}])))
+
+(defn on-click-import-file [e]
+  (log "Import clicked")
+  (let [file (.item (.. e -target -files) 0)
+        r (js/FileReader.)]
+    (set! (.-onload r) #(on-file-read % r))
+    (.readAsText r file)
+    ;(swap! app-state merge {:import-status :import-started})
+    ))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Read
@@ -183,9 +194,12 @@
      :action (fn []
                (do
                  (log "Add Competition")
-                 (d/transact! state [params])
-                 ;(log conn)
-                 ))}))
+                 (if params
+                   (if (:competitions params)
+                     (do
+                       (log "Compsss")
+                       (d/transact! state (:competitions params)))
+                     (d/transact! state [params])))))}))

 (defmethod mutate 'app/select-page
   [{:keys [state]} key {:keys [page] :as params}]
@@ -338,7 +352,10 @@
    (let [competition (om/props this)
          name (:competition/name competition)]
      (dom/tr
-      #js {:onClick #(om/transact! this `[(app/select-competition {:name ~name})])}
+      ;; TODO - this should be handle be some remote mechanism
+      #js {:onClick #(do
+                       (chsk-send! [:event-manager/query ['[*] [:competition/name name]]])
+                       (om/transact! this `[(app/select-competition {:name ~name})]))}
       (dom/td nil name)
       (dom/td nil (:competition/location competition))))))

@@ -357,14 +374,20 @@
        nil
        "Mina tävlingar")
       (dom/table
-       nil
+       #js {:className "table table-hover"}
        (dom/thead
         nil
         (dom/tr
          nil
          (dom/th nil "Namn")
          (dom/th nil "Plats")))
-       (apply dom/tbody nil (map competition competitions)))))))
+       (apply dom/tbody nil (map competition competitions)))
+
+
+      (dom/div
+       nil
+       (dom/span #js {:className "btn btn-default btn-file"} "Importera.."
+                 (dom/input #js {:type "file" :onChange #(on-click-import-file %)})))))))

 ;;;;;;;;;;;;;;;;;;;;
 ;; Classes
@@ -466,9 +489,9 @@
      ;(log activites)
      (dom/div
       nil
-      (dom/h2 {:className "sub-header"} "Time Schedule")
+      (dom/h2 nil "Time Schedule")
       (dom/table
-       #js {:className "table"}
+       #js {:className "table table-hover table-condensed"}
        (dom/thead
         nil
         (dom/tr
@@ -520,6 +543,7 @@
   Object
   (render
    [this]
+   (log "Renderz")
    (let [competitions (:app/competitions (om/props this))
          spage (:app/selected-page (om/props this))
          selected-competition (:app/selected-competition (om/props this))
@@ -564,22 +588,24 @@

       (dom/div #js {:className "container-fluid"}
                (dom/div #js {:className "row"}
-                        (dom/div #js {:className "col-sm-3 col-md-2 sidebar"}
-                                 (apply dom/ul #js {:className "nav nav-sidebar"}
-                                        (map (fn [[name key]] (make-button name key))
-                                             [["Properties" :properties]
-                                              ["Classes" :classes]
-                                              ["Time Schedule" :schedule]
-                                              ["Adjudicators" :adjudicators]
-                                              ["Adjudicator Panels" :adjudicator-panels]]))
-                                         ;; (dom/li #js {:className "active"
-                                         ;;              :onClick  #(log "click")}
-                                         ;;         (dom/a {:href "#"} "Classer"))
-                                         ;; (dom/li nil (dom/a {:href "#"} "Time Schedule"))
-                                         )
+                        (when selected-competition
+                          (dom/div #js {:className "col-sm-2 col-md-2 sidebar"}
+                                   (dom/div nil (dom/u nil (:competition/name selected-competition)) )
+                                   (apply dom/ul #js {:className "nav nav-sidebar"}
+                                          (map (fn [[name key]] (make-button name key))
+                                               [["Properties" :properties]
+                                                ["Classes" :classes]
+                                                ["Time Schedule" :schedule]
+                                                ["Adjudicators" :adjudicators]
+                                                ["Adjudicator Panels" :adjudicator-panels]]))
+                                   ;; (dom/li #js {:className "active"
+                                   ;;              :onClick  #(log "click")}
+                                   ;;         (dom/a {:href "#"} "Classer"))
+                                   ;; (dom/li nil (dom/a {:href "#"} "Time Schedule"))
+                                   ))

-                        (dom/div #js {:className "col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"}
-                                 (dom/h1 #js {:className "page-header"} "Rikstävling yada yada")
+                        (dom/div #js {:className "col-sm-10 col-sm-offset-2 col-md-10 col-md-offset-2 main"}
+                                 ;(dom/h1 #js {:className "page-header"} "Rikstävling yada yada")
                                  (condp = spage
                                    :properties ((om/factory PropertiesView) selected-competition)
                                    :classes ((om/factory ClassesView) selected-competition)


Added functions to pre-compile tag names and attributes

--- src/hiccup.clj
+++ src/hiccup.clj
@@ -31,9 +31,10 @@
        (= 'quote (first x))))

 (defn literal?
-  "True if the value is a not a list or a quoted value."
+  "True if the value is a literal value."
   [x]
-  (or (not (list? x))
+  (or (and (not (list? x))
+           (not (symbol? x)))
       (quoted? x)))

 (defn- format-attr
@@ -107,6 +108,30 @@
   [x]
   (list (as-str x)))

+(defn compile-tag
+  "Attempt to pre-render a HTML tag."
+  [tag-name content]
+  (if (literal? tag-name)
+    `(list ~@(render-tag tag-name content))
+    `(render-tag ~tag-name ~content)))
+
+(defn compile-attrs
+  "Attempt to pre-render an attribute map."
+  [attrs content]
+  (if (map? attrs)
+    `(list ~@(render-attrs attrs content))
+    `(render-attrs ~attrs ~content)))
+
+;(defn compile-content
+;  "Attempt to pre-render the contents of a tag."
+;  [content]
+;  (list*
+;    ">"
+;    (render-html
+;      (if (map? (first content))
+;        (rest content)
+;        content))))
+
 (defn collapse-strs
   "Concatenate adjacent strings in a sequence."
   [coll]


move to dev local

move to dev local

--- tutorial/query_for_ids_not_idents.clj
+++ tutorial/query_for_ids_not_idents.clj
@@ -6,15 +6,12 @@
 ;   the terms of this license.
 ;   You must not remove this notice, or any other, from this software.

-(require '[datomic.client.api :as d]
-         '[datomic.samples.repl :as repl])
-(import '(java.util UUID))
+(require '[datomic.client.api :as d])
+(import 'java.util.UUID)

-(def client-cfg (read-string (slurp "config.edn")))
-(def client (d/client client-cfg))
-(def db-name (str "scratch-" (UUID/randomUUID)))
-(d/create-database client {:db-name db-name})
-(def conn (d/connect client {:db-name db-name}))
+(def client (d/client {:server-type :dev-local :system "day-of-datomic-cloud"}))
+(d/create-database client {:db-name "query-for-ids"})
+(def conn (d/connect client {:db-name "query-for-ids"}))

 (set! *print-length* 10)

@@ -45,6 +42,4 @@
   (time (d/q '[:find (count ?item)
                :where [?item :item/color ?color]
                [?color :db/ident :color/green]]
-             db)))
-
-(d/delete-database client {:db-name db-name})
+             db)))


added filtering for constraints

added filtering for constraints

--- infant/src/infant/constraint/constraint.clj
+++ infant/src/infant/constraint/constraint.clj
@@ -3,13 +3,13 @@

 (defprotocol Satisfiable
-  (satisfied? [x]))
+  (satisfied? [self y]))

 (defrecord Constraint
   [name description properties strict satisfy-fn]
   Satisfiable
-  (satisfied? [x]
-    (satisfy-fn x)))
+  (satisfied? [self y]
+    (satisfy-fn y)))

 (def field-constraints [(->Constraint
                           "aggregate-op-supported-by-type"
@@ -89,7 +89,7 @@
                                   has-y false]
                              (let [first-field (first curr-fields)
                                    rest-fields (rest curr-fields)]
-                               (if (not (empty curr-fields))
+                               (if (seq curr-fields)
                                  (cond
                                    (= (::sp/channel first-field) ::sp/x)
                                    (recur rest-fields
@@ -97,12 +97,9 @@
                                    (= (::sp/channel first-field) ::sp/y)
                                    (recur rest-fields
                                           has-enumerated-non-position-or-facet-channel has-x true)
-                                   (not= (::sp/channel first-field) ::sp/?)
-                                   (if (sp/is-channel-enumerated? spec)
-                                     (recur rest-fields
-                                            true has-x has-y)
-                                     (recur rest-fields
-                                            has-enumerated-non-position-or-facet-channel has-x has-y)))
+                                   :else
+                                   (recur rest-fields
+                                          true has-x has-y))
                                  (if has-enumerated-non-position-or-facet-channel
                                    (and has-x has-y)
                                    true)))
@@ -124,14 +121,13 @@
                                      rest-fields (rest curr-fields)]
                                  (if (not (empty curr-fields))
                                    (if (not (::sp/aggregate curr-fields))
-                                     (if (and (or (= (::sp/channel first-field) ::sp/row)
-                                                  (= (::sp/channel first-field) ::sp/column))
-                                              (sp/is-channel-enumerated? spec))
+                                     (if (or (= (::sp/channel first-field) ::sp/row)
+                                             (= (::sp/channel first-field) ::sp/column))
                                        (recur rest-fields has-non-facet-dim true true)
                                        (recur rest-fields has-non-facet-dim true has-enumerated-facet-dim))
                                      (recur rest-fields true has-dim has-enumerated-facet-dim))
                                    (if (and has-dim (not has-non-facet-dim))
-                                     (if (has-enumerated-facet-dim)
+                                     (if has-enumerated-facet-dim
                                        false
                                        true)
                                      true))))
@@ -152,14 +148,34 @@
                                (if (not (empty curr-fields))
                                  (if (not= (::sp/channel first-field) ::sp/?)
                                    (if (not (sp/is-spatial-channel? (::sp/channel first-field)))
-                                     (if (sp/is-channel-enumerated? spec)
-                                       (if (and
-                                             (> non-positional-channel-count 1)
-                                             (has-enumerated-non-positional-channel))
-                                         (recur rest-fields (+ non-positional-channel-count 1) true (and result false))
-                                         (recur rest-fields (+ non-positional-channel-count 1) true (and result true)))
-                                       (recur rest-fields (+ non-positional-channel-count 1) false (and result true)))
+                                     (if (and
+                                           (> non-positional-channel-count 1)
+                                           (has-enumerated-non-positional-channel))
+                                       (recur rest-fields (+ non-positional-channel-count 1) true (and result false))
+                                       (recur rest-fields (+ non-positional-channel-count 1) true (and result true)))
                                      (recur rest-fields non-positional-channel-count false (and result true)))
                                    (recur rest-fields non-positional-channel-count false (and result true)))
                                  result
-                                 )))))])
+                                 )))))
+                       ])
+
+
+(defn field-constraints-satisfied?
+  [fields constraints]
+  (loop [curr-fields fields res true]
+    (if (not (seq curr-fields))
+      res
+      (recur (rest curr-fields)
+        (reduce (fn [x y] (and x (satisfied? y (first curr-fields)))) res constraints)))))
+
+
+(defn spec-constraints-satisfied?
+  [spec constraints]
+  (reduce (fn [x y] (and x (satisfied? y spec))) true constraints))
+
+
+(defn filter-invalid-specs
+  [specs]
+  (->> specs
+       (filter (fn [x] (field-constraints-satisfied? (::sp/fields x) field-constraints)))
+       (filter (fn [x] (spec-constraints-satisfied? x spec-constraints)))))


reinstate one-at-at-time vector append benchmark

--- scripts/benchmarks.clj
+++ scripts/benchmarks.clj
@@ -163,12 +163,21 @@
     (setval END toappend [])
     (setval END! toappend (transient []))))

+(let [toappend (range 1000)]
+  (run-benchmark "transient comparison: building up vectors one at a time"
+    10000
+    (reduce (fn [v i] (conj v i)) [] toappend)
+    (reduce (fn [v i] (conj! v i)) (transient []) toappend)
+    (reduce (fn [v i] (setval END [i] v)) [] toappend)
+    (reduce (fn [v i] (setval END! [i] v)) (transient []) toappend)
+    ))
+
 (let [data (vec (range 1000))
       tdata (transient data)
       tdata2 (transient data)
       idx 600]
   (run-benchmark "transient comparison: assoc'ing in vectors"
-    500000
+    2500000
     (assoc data idx 0)
     (assoc! tdata idx 0)
     (setval (keypath idx) 0 data)
@@ -180,7 +189,7 @@
       tdata2 (transient data)
       idx 600]
   (run-benchmark "transient comparison: assoc'ing in maps"
-    500000
+    2500000
     (assoc data idx 0)
     (assoc! tdata idx 0)
     (setval (keypath idx) 0 data)


add transducer cases to map vals benchmarks

--- scripts/benchmarks.clj
+++ scripts/benchmarks.clj
@@ -151,8 +151,10 @@
     (transform MAP-VALS inc data)
     (zipmap (keys data) (map inc (vals data)))
     (into {} (map (fn [e] [(key e) (inc (val e))]) data))
+    (into {} (map (fn [e] [(key e) (inc (val e))])) data)
     (map-vals-map-iterable data inc)
-    (map-vals-map-iterable-transient data inc)))
+    (map-vals-map-iterable-transient data inc)
+    ))

 (let [data (->> (for [i (range 1000)] [i i]) (into {}))]
@@ -166,6 +168,7 @@
     (transform MAP-VALS inc data)
     (zipmap (keys data) (map inc (vals data)))
     (into {} (map (fn [e] [(key e) (inc (val e))]) data))
+    (into {} (map (fn [e] [(key e) (inc (val e))])) data)
     (map-vals-map-iterable data inc)
     (map-vals-map-iterable-transient data inc)))


Upgrade refactor-nrepl

Upgrade refactor-nrepl

--- roles/clojure/files/profiles.clj
+++ roles/clojure/files/profiles.clj
@@ -23,7 +23,7 @@
                   [lein-swank "1.4.4"]
                   [lein-try "0.4.3"]
                   [lein-typed "0.3.5"]
-                  [refactor-nrepl "1.1.0-SNAPSHOT"]]
+                  [refactor-nrepl "1.2.0-SNAPSHOT"]]

         :global-vars {*warn-on-reflection* true}


replace predicate fn with case statement.

--- main/clojure/src/org/zproto/hydra_server.clj
+++ main/clojure/src/org/zproto/hydra_server.clj
@@ -31,12 +31,6 @@
                                               " state, but had "
                                               current-state))))))))

-(defn ensure-state
-  [atom routing-id expected-state]
-  (when (= (get @atom routing-id)
-              expected-state)
-    expected-state))
-
 (defn maybe-setup-session [state routing-id]
   (if (get state routing-id)
     state
@@ -45,38 +39,43 @@
 (defrecord Server [socket state backend]
   HydraServer
   (hello [this routing-id]
-    (if (ensure-state state routing-id :start)
-      (do (next-state state routing-id :start :connected)
-          (let [post-id (get-latest-post backend)]
-            (msg/hello-ok socket routing-id post-id)))
+    (case (get @state routing-id)
+      :start (let [post-id (get-latest-post backend)]
+               (msg/hello-ok socket routing-id post-id)
+               (next-state state routing-id :start :connected))
+
       (invalid this routing-id)))

   (get-tags [this routing-id]
-    (if (ensure-state state routing-id :connected)
-      (let [tags (get-all-tags backend)]
-        (msg/get-tags-ok socket routing-id tags))
+    (case (get @state routing-id)
+      :connected (let [tags (get-all-tags backend)]
+                   (msg/get-tags-ok socket routing-id tags))
+
       (invalid this routing-id)))

   (get-tag [this routing-id tag]
-    (if (ensure-state state routing-id :connected)
-      (if-let [post-id (get-single-tag backend tag)]
-        (msg/get-tag-ok socket routing-id tag post-id)
-        (msg/failed socket routing-id (format "no post for tag %s" tag)))
+    (case (get @state routing-id)
+      :connected (if-let [post-id (get-single-tag backend tag)]
+                   (msg/get-tag-ok socket routing-id tag post-id)
+                   (msg/failed socket routing-id (format "no post for tag %s" tag)))
       (invalid this routing-id)))

   (get-post [this routing-id post-id]
-    (if (ensure-state state routing-id :connected)
-      (if-let [post-data (get-single-post backend post-id)]
-        (apply msg/get-post-ok socket routing-id post-data)
-        (msg/failed socket routing-id (format "post not found: %s" post-id)))
+    (case (get @state routing-id)
+      :connected (if-let [post-data (get-single-post backend post-id)]
+                   (apply msg/get-post-ok socket routing-id post-data)
+                   (msg/failed socket
+                               routing-id
+                               (format "post not found: %s" post-id)))
+
       (invalid this routing-id)))

   (invalid [this routing-id]
     (msg/invalid socket routing-id))

   (goodbye [this routing-id]
-    (if (ensure-state state routing-id :connected)
-      (msg/goodbye-ok socket routing-id)
+    (case (get @state routing-id)
+      :connected  (msg/goodbye-ok socket routing-id)
       (invalid this routing-id))))


remove deprecated menuitem element, replace by div (for now)

--- web-app/src/cljs/potato/core.cljs
+++ web-app/src/cljs/potato/core.cljs
@@ -683,10 +683,10 @@
     (render [_]
       (apply om.dom/menu #js {:id "chat-popup-menu" :type "popup"}
              (map (fn [menuentry]
-                    (om.dom/menuitem #js {:label        (:label menuentry)
-                                          :onClick      (:onclick menuentry)
-                                          :onMouseEnter #(goog.dom.classlist/add    (.-currentTarget %) "chat-popup-item-active")
-                                          :onMouseLeave #(goog.dom.classlist/remove (.-currentTarget %) "chat-popup-item-active")}
+                    (om.dom/div #js {:label        (:label menuentry)
+                                     :onClick      (:onclick menuentry)
+                                     :onMouseEnter #(goog.dom.classlist/add    (.-currentTarget %) "chat-popup-item-active")
+                                     :onMouseLeave #(goog.dom.classlist/remove (.-currentTarget %) "chat-popup-item-active")}
                       (:label menuentry)))
                   (concat [{:label "Hide" :onclick #(toggle-hidden message)}]
                           (if (:can-edit-p opts)
@@ -1306,11 +1306,11 @@
                    (if (> (count found-items) 0)
                      (let [selected (or (get-selected-entry) (select-default-entry))]
                        (map (fn [item]
-                              (om.dom/menuitem #js {:className    (if (= (:id item) (:id selected)) "active")
-                                                    :onMouseEnter #(select-entry item)
-                                                    :onClick      #(potato.keyboard/key-on-default
-                                                                    (om/get-shared owner :keyboard-control)
-                                                                    potato.keyboard/ENTER)}
+                              (om.dom/div #js {:className    (if (= (:id item) (:id selected)) "active")
+                                               :onMouseEnter #(select-entry item)
+                                               :onClick      #(potato.keyboard/key-on-default
+                                                               (om/get-shared owner :keyboard-control)
+                                                               potato.keyboard/ENTER)}
                                 (if (= (:special item) "emoji") (potato.emoji/span item) (:text item))))
                             found-items))
                      [(om.dom/div #js {:className "notice"} "no match")]))))))))


debugger bug fixed: same file can now be loaded twice in a row

--- examples/_common/middleware/devtools.cljs
+++ examples/_common/middleware/devtools.cljs
@@ -273,7 +273,10 @@
                                file-reader (js/FileReader.)]
                            (set! (.-onload file-reader)
                                  #(on-load (-> % .-target .-result)))
-                           (.readAsText file-reader file)))}]])
+                           (.readAsText file-reader file)))
+
+            ; hack to allow on-change be fired when the same file is selected twice in a row
+            :value     ""}]])

 (defn -menu
   [persist? toggle-visibility-shortcut dispatch]


Set proper order on page creation.

Set proper order on page creation.

--- frontend/src/uxbox/main/data/pages.cljs
+++ frontend/src/uxbox/main/data/pages.cljs
@@ -198,6 +198,8 @@

 ;; --- Create Page

+(declare reorder-pages)
+
 (deftype CreatePage [name project width height layout]
   ptk/WatchEvent
   (watch [this state s]
@@ -207,18 +209,24 @@
                   :metadata {:width width
                              :height height
                              :layout layout
-                             :order 0}}]
-      (->> (rp/req :create/page params)
-           (rx/map :payload)
-           (rx/map page-created)))))
+                             :order -100}}]
+      (rx/concat
+       (->> (rp/req :create/page params)
+            (rx/map :payload)
+            (rx/map page-created))
+       (rx/of (reorder-pages))))))

 (s/def ::create-page-event
-  (s/keys :req-un [::name ::project ::width ::height ::layout]))
+  (s/keys :req-un [::name
+                   ::project
+                   ::width
+                   ::height
+                   ::layout]))

 (defn create-page
   [{:keys [name project width height layout] :as data}]
   {:pre [(us/valid? ::create-page-event data)]}
-  (->CreatePage name project width height layout))
+  (CreatePage. name project width height layout))

 ;; --- Page Persisted


Fix path to default.hecuba.edn

Fix path to default.hecuba.edn

--- src/clj/kixi/hecuba/application/system.clj
+++ src/clj/kixi/hecuba/application/system.clj
@@ -40,7 +40,7 @@
       (combine
        (clojure.tools.reader/read
         (indexing-push-back-reader
-         (java.io.PushbackReader. (io/reader "resources/default.hecuba.edn")))) ;; TODO change path once we deploy from jar
+         (java.io.PushbackReader. (io/reader "default.hecuba.edn"))))
        (clojure.tools.reader/read
         (indexing-push-back-reader
          (java.io.PushbackReader. (io/reader f))))))))


Fix issue #1

Fix issue #1

--- src/alfresco_technical_validation/binary_validation.clj
+++ src/alfresco_technical_validation/binary_validation.clj
@@ -209,7 +209,25 @@
                     (empty? res)
                     (if (empty? res) "The code has been compiled for JVM 1.6 or greater." message))))

-(defn- com09-stb07-stb14-search-apis
+(defn- com09-prefer-cmisql
+  []
+  (let [res (cy/tquery "
+                         START n=NODE(*)
+                         MATCH (n)-->(m)
+                         WHERE HAS(n.name)
+                           AND HAS(m.name)
+                           AND m.name = 'org.alfresco.service.cmr.search.SearchService'
+                        RETURN n.name AS ClassName
+                         ORDER BY n.name
+                       ")
+        message (str "The following class(es) use SearchService:\n"
+                     (s/join "\n" (map #(get % "ClassName") res))
+                     "\n#### Manual followup required - check search language. ####")]
+    (if (empty? res)
+      (declare-result "COM09" true "The technology does not use the Search APIs.")
+      (declare-result "COM09" message))))
+
+(defn- stb07-stb14-search-apis
   []
   (let [res (cy/tquery "
                          START n=NODE(*)
@@ -224,7 +242,6 @@
                          ORDER BY n.name
                        ")]
     (vector
-      (standard-validation "COM09" res true "The technology does not use the Search APIs." #(if (empty? %) true nil))
       (standard-validation "STB07" res true "The technology does not use the Search APIs." #(if (empty? %) true nil))
       (standard-validation "STB14" res true "The technology does not use the Search APIs." #(if (empty? %) true nil)))))

@@ -394,6 +411,7 @@
        (com01-unique-java-package)
        (com04-prefer-repository-actions)
        (com06-compiled-jvm-version)
+       (com09-prefer-cmisql)
        (sec02-minimise-manual-authentication)
        (sec04-process-exec-builder)
        (stb03-servlets-servlet-filters)
@@ -403,5 +421,5 @@
        (stb10-threading)
        (stb12-logging)
      )
-     (com09-stb07-stb14-search-apis)
+     (stb07-stb14-search-apis)
    )])


This instance of fn? should have been left alone.

--- src/afterglow/show.clj
+++ src/afterglow/show.clj
@@ -956,7 +956,7 @@
   (cond (keyword? initial-value)
         (get-variable initial-value)

-        (ifn? initial-value)
+        (fn? initial-value)
         (initial-value)

         :else


comments and reordering

comments and reordering

--- src/babel/workbook.clj
+++ src/babel/workbook.clj
@@ -3,15 +3,29 @@
   (:require
    [babel.engine :refer [generate]]
    [babel.enrich :refer [against-pred]]
+
    [babel.english.grammar :as eng]
-   [babel.english.writer :as en]
    [babel.english.lexicon :as enl]
    [babel.english.morphology :as enm]
+   [babel.english.writer :as en]
+
    [babel.espanol.grammar :as esg]
+   [babel.espanol.lexicon :as esl]
+   [babel.espanol.morphology :as esm]
    [babel.espanol.writer :as es]
+
    [babel.forest :refer [lightning-bolt]]
-;   [babel.francais.grammar :as fr]
-;   [babel.italiano.grammar :as it]
+
+   [babel.francais.grammar :as frg]
+   [babel.francais.lexicon :as frl]
+   [babel.francais.morphology :as frm]
+   [babel.francais.writer :as fr]
+
+   [babel.italiano.grammar :as itg]
+   [babel.italiano.lexicon :as itl]
+   [babel.italiano.morphology :as itm]
+   [babel.italiano.writer :as it]
+
    [babel.over :refer [over overh overhc]]
    [babel.html :as html]
    [babel.korma :as korma]
@@ -176,7 +190,7 @@
           search-query
           "(+ 1 1)")
         ]
-       [:button {:onclick "workbook()"} "evaluate"]]
+       [:button {:onclick "workbook('/workbook')"} "evaluate"]]
       [:div#workbooka
        (if search-query
          (workbookq search-query))]])))


Revert "Boot show --predantic formatting tweaks"

This reverts commit e070877243976de67bf68f39815b13677ea643f3.

--- boot/pod/src/boot/pedantic.clj
+++ boot/pod/src/boot/pedantic.clj
@@ -40,23 +40,17 @@
   (->> env pod/resolve-dependencies (map #(vec (take 2 (:dep %)))) (into {})))

 (defn prn-conflicts [env]
-  (let [check-mark "\u2714"
-        version-of (resolved-versions env)]
-    (doseq [[dep versions] (dep-conflicts env)]
-      (let [explicit? (contains? (reduce into #{} (vals versions)) dep)
-            dep-mark  (if explicit? check-mark "-")]
-        (print (ansi/bold-white (format "[%s] %s\n" dep-mark dep)))
-        (doseq [[version vias] (reverse versions)]
-          (let [chosen?  (= version (version-of dep))
-                norm     (if chosen? ansi/green ansi/yellow)
-                bold     (if chosen? ansi/bold-green ansi/bold-yellow)
-                ver-mark (if chosen? dep-mark " ")]
-            (print (bold (format "    [%s] %s\n" ver-mark version)))
-            (doseq [via vias]
-              (let [given?    (= dep via)
-                    excluded? (not chosen?)
-                    color     (if given? bold norm)
-                    via-mark  (cond given?    check-mark
-                                    excluded? " "
-                                    :else     "-")]
-                (print (color (format "        [%s] %s\n" via-mark via)))))))))))
+  (let [version (resolved-versions env)
+        deps    (->> env :dependencies (map #(vec (take 2 %))) (into {}))]
+    (doseq [[k v] (dep-conflicts env)
+            m     (if (deps k) "\u2714" "!")]
+      (print (ansi/bold-white (format "[%s] %s\n" m k)))
+      (doseq [[k' v'] (reverse v)
+              :let [v? (= k' (version k))
+                    m  (if v? "\u2714" "\u2718")
+                    c1 #((cond (= k %) ansi/bold-green
+                               v?      ansi/green
+                               :else   ansi/yellow) %)
+                    c2 (if v? ansi/bold-green ansi/bold-yellow)]]
+        (print (->> (string/join "\n      " (map c1 (sort v')))
+                    (format "    %s %s\n      %s\n" (c2 m) (c2 k'))))))))


fix zoom reset

fix zoom reset

--- src-cljs/frontend/camera.cljs
+++ src-cljs/frontend/camera.cljs
@@ -8,7 +8,7 @@
   (:camera state))

 (defn reset [camera]
-  (assoc camera :x 0 :y 0 :zf 1 :zf-exact 1))
+  (assoc camera :x 0 :y 0 :zf 1 :z-exact 1))

 (defn snap [increment value]
   (js/parseFloat (.toFixed (* increment (js/Math.round (/ value increment))) 2)))


update request-animation-frame, refactor raf-start-time as local binding

--- src/clojure/freactive/dom.cljs
+++ src/clojure/freactive/dom.cljs
@@ -171,8 +171,6 @@

 ;; ## Polyfills

-(def ^:private raf-start-time (.getTime (js/Date.)))
-
 (def request-animation-frame
   (or
    (.-requestAnimationFrame js/window)
@@ -180,10 +178,11 @@
    (.-mozRequestAnimationFrame js/window)
    (.-msRequestAnimationFrame js/window)
    (.-oRequestAnimationFrame js/window)
-   (fn [f]
-     (js/setTimeout
-      #(f (- (.getTime (js/Date.)) raf-start-time))
-      16.66666))))
+   (let [t0 (.getTime (js/Date.))]
+     (fn [f]
+       (js/setTimeout
+        #(f (- (.getTime (js/Date.)) t0))
+        16.66666)))))

 ;; Render Loop


Get rid of fast process method

Get rid of fast process method

--- src/clojure/nightcode/lein.clj
+++ src/clojure/nightcode/lein.clj
@@ -93,7 +93,7 @@

 (defonce class-name (str *ns*))

-(defn start-slow-process
+(defn start-self-process
   [process path & args]
   (let [project-map (read-project-clj path)
         java-cmd (or (:java-cmd project-map) (System/getenv "JAVA_CMD") "java")
@@ -112,23 +112,6 @@
                      (.getCanonicalPath jar-file))
                    args)))

-(defn start-fast-process
-  [process path func]
-  (let [project-map (-> (read-project-clj path)
-                        (assoc :eval-in :trampoline))
-        forms leiningen.core.eval/trampoline-forms
-        profiles leiningen.core.eval/trampoline-profiles]
-    (reset! forms [])
-    (reset! profiles [])
-    (func path project-map)
-    (doseq [i (range (count @forms))]
-      (->> (let [form (nth @forms i)
-                 profile (nth @profiles i)
-                 project-map (leiningen.core.project/set-profiles
-                               project-map [profile])]
-             (leiningen.core.eval/shell-command project-map form))
-           (start-process process path)))))
-
 (defn stop-process
   [process]
   (when @process
@@ -193,43 +176,35 @@
   [process in out path]
   (stop-process process)
   (->> (do (println (utils/get-string :running))
-         (if (is-clojurescript-project? path)
-           (start-slow-process process path class-name "run")
-           (start-fast-process process path run-project-task)))
+         (start-self-process process path class-name "run"))
        (start-thread in out)))

 (defn run-repl-project
   [process in out path]
   (stop-process process)
   (->> (do (println (utils/get-string :running_with_repl))
-         (start-slow-process process path class-name "repl"))
+         (start-self-process process path class-name "repl"))
        (start-thread in out)))

 (defn build-project
   [process in out path]
   (stop-process process)
   (->> (do (println (utils/get-string :building))
-         (if (is-clojurescript-project? path)
-           (start-slow-process process path class-name "build")
-           (start-fast-process process path build-project-task)))
+         (start-self-process process path class-name "build"))
        (start-thread in out)))

 (defn test-project
   [process in out path]
   (stop-process process)
   (->> (do (println (utils/get-string :testing))
-         (if (is-clojurescript-project? path)
-           (start-slow-process process path class-name "test")
-           (start-fast-process process path test-project-task)))
+         (start-self-process process path class-name "test"))
        (start-thread in out)))

 (defn clean-project
   [process in out path]
   (stop-process process)
   (->> (do (println (utils/get-string :cleaning))
-         (if (is-clojurescript-project? path)
-           (start-slow-process process path class-name "clean")
-           (start-fast-process process path clean-project-task)))
+         (start-self-process process path class-name "clean"))
        (start-thread in out)))

 (defn new-project
@@ -246,7 +221,7 @@
 (defn run-repl
   [process in out]
   (stop-process process)
-  (->> (start-slow-process process nil "clojure.main")
+  (->> (start-self-process process nil "clojure.main")
        (start-thread in out)))

 (defn run-logcat


CMR-183: Added API for querying cache.

CMR-183: Added API for querying cache.

--- src/cmr/indexer/api/routes.clj
+++ src/cmr/indexer/api/routes.clj
@@ -52,6 +52,29 @@
         (index-svc/update-indexes context))
       {:status 200})

+    ;; Querying cache
+    (context "/caches" []
+      (GET "/" {:keys [params]}
+        {:status 200})
+      (GET "/:cache-name" {{:keys [cache-name] :as params} :params
+                           request-context :request-context
+                           headers :headers}
+        (let [context (acl/add-authentication-to-context request-context params headers)
+              ;_ (acl/verify-ingest-management-permission context :read)
+              result (keys (get-in context [:system :caches (keyword cache-name)]))]
+          (println (str "LOOKING FOR CACHE [" (keyword cache-name) "]"))
+          (println "CACHES.....")
+          (println (get-in context [:system :caches]))
+          (when result {:status 200
+                        :body result})))
+
+      (GET "/:cache-name/:cache-key" {{:keys [cache-name cache-key] :as params} :params
+                                      request-context :request-context
+                                      headers :headers}
+        (let [context (acl/add-authentication-to-context request-context params headers)]
+          (acl/verify-ingest-management-permission context :read)
+          (identity))))
+
     (POST "/clear-cache" {:keys [request-context params headers]}
       (let [context (acl/add-authentication-to-context request-context params headers)]
         (acl/verify-ingest-management-permission context :update)


don't generate cake.clj context for cake itself

--- src/cake/tasks/jar.clj
+++ src/cake/tasks/jar.clj
@@ -50,15 +50,16 @@
     (add-zipfileset task {:dir (file "src" "jvm") :prefix prefix :includes "**/*.java"})))

 (defn build-context []
-  (mkdir (file "build" "jar"))
-  (with-open [cake-clj (writer (file "build" "jar" "cake.clj"))]
-    (copy (if (current-context)
-            (format "(ns cake)\n(def *project* %s)\n(def *context* nil)"
-                    (pr-str *project*))
-            (format "(ns cake)\n(def *project* %s)\n(def *context* %s)"
-                    (pr-str (.getRoot #'*project*))
-                    (pr-str *context*)))
-          cake-clj)))
+  (when-not (= "cake" (:artifact-id *project*))
+    (mkdir (file "build" "jar"))
+    (with-open [cake-clj (writer (file "build" "jar" "cake.clj"))]
+      (copy (if (current-context)
+              (format "(ns cake)\n(def *project* %s)\n(def *context* nil)"
+                      (pr-str *project*))
+              (format "(ns cake)\n(def *project* %s)\n(def *context* %s)"
+                      (pr-str (.getRoot #'*project*))
+                      (pr-str *context*)))
+            cake-clj))))

 (defn build-jar []
   (let [maven (format "META-INF/maven/%s/%s" (:group-id *project*) (:artifact-id *project*))


fix resolve-var impl

fix resolve-var impl

--- src/main/clojure/cljs/core.clj
+++ src/main/clojure/cljs/core.clj
@@ -661,9 +661,9 @@
   (symbol (core/str "-" sym)))

 (defn resolve-var [env sym]
-  (let [ret (-> (dissoc env :locals)
-              (utils/resolve-var sym env)
-              :name)]
+  (let [ret (->> (dissoc env :locals)
+                (utils/resolve-var sym)
+                :name)]
     (assert ret (core/str "Can't resolve: " sym))
     ret))


better coordinates for text

better coordinates for text

--- src-cljs/frontend/controllers/errors.cljs
+++ src-cljs/frontend/controllers/errors.cljs
@@ -77,8 +77,8 @@
                         :layer/start-x start-x
                         :layer/start-y start-y
                         :db/id 1
-                        :layer/end-x 600
-                        :layer/end-y 175}]
+                        :layer/end-x (+ start-x 300)
+                        :layer/end-y (- start-y 23)}]
                  {:bot-layer true})))

 (defmethod post-error! :subscribe-to-document-error


Indentation fix.

Indentation fix.

--- src/clojush/random.clj
+++ src/clojush/random.clj
@@ -81,8 +81,8 @@
     (random-plush-genome max-genome-size atom-generators {}))
   ([max-genome-size atom-generators argmap]
     (random-plush-genome-with-size (inc (lrand-int max-genome-size))
-                           atom-generators
-                           argmap)))
+                                   atom-generators
+                                   argmap)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; random Push code generator


Added missing closing } to sparql-string in the root_concept_identifier_gen rule

--- kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/pre-identifier-merge/step_a-ontology_to_ice/step_a/root_concept_identifier_gen.clj
+++ kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/pre-identifier-merge/step_a-ontology_to_ice/step_a/root_concept_identifier_gen.clj
@@ -10,5 +10,6 @@
   :sparql-string "select ?root {
 		  ?root rdf:type owl:Class .
 		  minus{?root rdfs:subClassOf ?class}
-		minus{?root owl:deprecated true}  "
+		minus{?root owl:deprecated true}
+		}"
 }


feat: wkt geometry, with srid

feat: wkt geometry, with srid

--- src/main/clojure/pdok/featured/feature.clj
+++ src/main/clojure/pdok/featured/feature.clj
@@ -12,7 +12,7 @@
            [pdok.featured.xslt TransformXSLT]
            [pdok.featured.converters Transformer]
            [com.vividsolutions.jts.geom Geometry]
-           [com.vividsolutions.jts.io WKTWriter]))
+           [com.vividsolutions.jts.io WKTWriter WKTReader]))

 (def lower-case
   (fnil str/lower-case ""))
@@ -70,6 +70,7 @@
       nil)))

 (def wkt-writer (WKTWriter.))
+(def wkt-reader (WKTReader.))

 (defn jts-as-wkt [jts]
   (if-not (nil? jts)
@@ -79,6 +80,8 @@
 (defmethod valid-geometry? :default [_] nil)
 (defmethod valid-geometry? "gml" [obj]
   (if (get obj "gml") true false))
+(defmethod valid-geometry? "wkt" [obj]
+  (if (get obj "wkt") true false))

 (defmethod valid-geometry? "jts" [obj]
   true)
@@ -92,6 +95,7 @@
 (defmethod as-jts :default [_] nil)

 (def gml->jts-cache (atom (cache/lu-cache-factory {} :threshold 30000)))
+
 (defmethod as-jts "gml" [obj]
  (when-let [gml (get obj "gml")]
    (if (cache/has? @gml->jts-cache gml)
@@ -102,6 +106,13 @@

 (defmethod as-jts "jts" [obj]
   (get obj "jts"))
+
+(defmethod as-jts "wkt" [obj]
+  (let [jts (.read ^WKTReader wkt-reader ^String (get obj "wkt"))]
+    (when-let [srid (get obj "srid")]
+      ; srid should be an integer, but it might be a string
+      (doto jts (.setSRID (if (string? srid) (Integer/parseInt srid) srid))))
+    jts))

 (defn as-rd [^Geometry geometry]
   (when geometry
@@ -170,3 +181,8 @@
 (defmethod geometry-group "jts" [obj]
   (let [type (.getGeometryType ^Geometry (get obj "jts"))]
     (geometry-group* jts-point-types jts-line-types type)))
+
+(defmethod geometry-group "wkt" [obj]
+  (let [jts (as-jts obj)
+        type (.getGeometryType ^Geometry jts)]
+    (geometry-group* jts-point-types jts-line-types type)))


Move the tiled-map* conditional to the renderer constructors

--- src/play_clj/core_graphics.clj
+++ src/play_clj/core_graphics.clj
@@ -94,11 +94,9 @@
 (defn tiled-map*
   ([]
     (TiledMap.))
-  ([s]
-    (if (string? s)
-      (or (u/load-asset s TiledMap)
-          (.load (TmxMapLoader.) s))
-      s)))
+  ([^String path]
+    (or (u/load-asset path TiledMap)
+        (.load (TmxMapLoader.) path))))

 (defmacro tiled-map
   "Returns a [TiledMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMap.html).
@@ -368,7 +366,10 @@

 (defn orthogonal-tiled-map*
   [path unit]
-  (OrthogonalTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit))
+  (OrthogonalTiledMapRenderer. ^TiledMap (if (string? path)
+                                           (tiled-map* path)
+                                           path)
+                               ^double unit))

 (defmacro orthogonal-tiled-map
   "Returns an [OrthogonalTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/OrthogonalTiledMapRenderer.html)
@@ -387,7 +388,10 @@

 (defn isometric-tiled-map*
   [path unit]
-  (IsometricTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit))
+  (IsometricTiledMapRenderer. ^TiledMap (if (string? path)
+                                           (tiled-map* path)
+                                           path)
+                              ^double unit))

 (defmacro isometric-tiled-map
   "Returns an [IsometricTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/IsometricTiledMapRenderer.html)
@@ -406,7 +410,9 @@

 (defn isometric-staggered-tiled-map*
   [path unit]
-  (IsometricStaggeredTiledMapRenderer. ^TiledMap (tiled-map* path)
+  (IsometricStaggeredTiledMapRenderer. ^TiledMap (if (string? path)
+                                                   (tiled-map* path)
+                                                   path)
                                        ^double unit))

 (defmacro isometric-staggered-tiled-map
@@ -428,7 +434,10 @@

 (defn hexagonal-tiled-map*
   [path unit]
-  (HexagonalTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit))
+  (HexagonalTiledMapRenderer. ^TiledMap (if (string? path)
+                                          (tiled-map* path)
+                                          path)
+                              ^double unit))

 (defmacro hexagonal-tiled-map
   "Returns a [HexagonalTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/HexagonalTiledMapRenderer.html)


Fix add button

Fix add button

--- src/airhead_cljs/components.cljs
+++ src/airhead_cljs/components.cljs
@@ -54,10 +54,6 @@
    [:span "Now playing:"]
    [track-component (@app-state :now-playing)]])

-(defn next-component []
-  [:section
-   [tracks-table (@app-state :playlist) playlist-remove-component]])
-
 (defn playlist-component []
   [:section#playlist
    [:h2 "Playlist"]
@@ -81,7 +77,7 @@
   [:section#library
    [:h2 "Library"]
    [search-component]
-   [tracks-table (@app-state :library) playlist-remove-component]])
+   [tracks-table (@app-state :library) playlist-add-component]])

 (defn page-component []
   [:main


Change indentation

Change indentation

--- src/afrey/boot_asset_fingerprint/impl.clj
+++ src/afrey/boot_asset_fingerprint/impl.clj
@@ -29,15 +29,16 @@
 (defn template [input-file {:keys [skip file-hashes input-root]}]
   (html/template (html/html-resource input-file)
     []
-    [html/any-node] (html/replace-vars
-                      (fn [asset-name]
-                        (let [asset-path (subs (str asset-name) 1)]
-                          (if skip
-                            asset-path
+    [html/any-node]
+    (html/replace-vars
+      (fn [asset-name]
+        (let [asset-path (subs (str asset-name) 1)]
+          (if skip
+            asset-path

-                            (let [full-path (asset-full-path asset-path input-root)
-                                  fingerprint (get file-hashes full-path)]
-                              (fingerprint-asset asset-path fingerprint))))))))
+            (let [full-path (asset-full-path asset-path input-root)
+                  fingerprint (get file-hashes full-path)]
+              (fingerprint-asset asset-path fingerprint))))))))

 (defn fingerprint


pre-compute nickname->user

pre-compute nickname->user

--- src/chat/server/email_digest.clj
+++ src/chat/server/email_digest.clj
@@ -32,11 +32,17 @@

 (defn updates-for-user-since
   [user-id cutoff]
-  (into ()
-        (comp (filter thread-unseen?)
-              (filter (partial last-message-after? cutoff)))
-        (db/with-conn
-          (db/get-open-threads-for-user user-id))))
+  (db/with-conn
+    (let [id->nick (into {} (map (juxt :id :nickname))
+                         (db/fetch-users-for-user user-id))]
+      (into ()
+            (comp (filter thread-unseen?)
+                  (filter (partial last-message-after? cutoff))
+                  (map (fn [t]
+                         (map (fn [m]
+                                (assoc m :sender (-> (m :user-id) id->nick)))
+                              (t :messages)))))
+            (db/get-open-threads-for-user user-id)))))

 (defn daily-update-users
   "Find all ids for users that want daily digest updates"


Store contact details in the DB.

Store contact details in the DB.

--- src/circleci/web/views/index.clj
+++ src/circleci/web/views/index.clj
@@ -14,6 +14,7 @@
 (defpage [:post "/"] {:as request}
   (with-conn
                (beta/insert {:email (:email request)
+                             :contact (= "true" (:contact request))
                              :environment ""
                              :features ""})
                (cookies/put! :signed-up "1")


playing around with core.logic databases

--- src/clj/eventsourcing/custom.clj
+++ src/clj/eventsourcing/custom.clj
@@ -1,6 +1,7 @@
 (ns eventsourcing.custom
   (:require [clojure.edn :as edn]
             [clojure.core.logic :as l]
+            [clojure.core.logic.pldb :as lp]
             [korma.core :as db]
             [eventsourcing.db :as evdb]))

@@ -165,3 +166,26 @@
       (l/== a2 :comment/author)
       (l/== q [e2 a2 v2 t2])))
 #_(get-entity 1)
+
+#_(lp/db-rel fact e a v t)
+#_(def facts
+    (lp/db
+     [fact 10 :user/name "walter" 1]
+
+     [fact 20 :comment/text "comment walter 1" 2]
+     [fact 20 :comment/date #inst"2017-01-01" 2]
+     [fact 20 :comment/author 10 2]
+
+     [fact 21 :comment/text "comment walter 2" 3]
+     [fact 21 :comment/date #inst"2017-01-02" 3]
+     [fact 21 :comment/author 10 3]))
+#_(lp/with-db facts
+    (l/run* [q]
+      (l/fresh [eu au vu tu
+                ec ac vc tc]
+        (fact eu au vu tu)
+        (l/== eu 10)
+        (fact ec :comment/author eu tc)
+        (l/== ac :comment/text)
+        (fact ec ac vc tc)
+        (l/== q [ec ac vc tc]))))


Disable save button if hyphenation is not valid

--- src/cljs/hyphen_keeper/core.cljs
+++ src/cljs/hyphen_keeper/core.cljs
@@ -112,7 +112,8 @@
      [:td
       [:div.btn-group
        [:button.btn.btn-default
-        {:on-click save}
+        {:on-click save
+         :disabled (when-not valid? "disabled")}
         [:span.glyphicon.glyphicon-ok {:aria-hidden true}] " Save"]
        [:button.btn.btn-default
         {:on-click stop}


Implement editing of existing hyphenations

--- src/cljs/hyphen_keeper/core.cljs
+++ src/cljs/hyphen_keeper/core.cljs
@@ -80,50 +80,58 @@
        (string/includes? s "-")
        (re-matches #"[a-z\xDF-\xFF-]+" s)))

-(defn hyphenation-pattern-editable-item [{:keys [hyphenation]}]
+(defn- hyphenation-pattern-readonly-ui
+  [word hyphenation start remove]
+  [:tr
+   [:td word]
+   [:td hyphenation]
+   [:td
+    [:div.btn-group
+     [:button.btn.btn-default
+      {:on-click start}
+      [:span.glyphicon.glyphicon-edit {:aria-hidden true}] " Edit"]
+     [:button.btn.btn-default
+      {:on-click remove}
+      [:span.glyphicon.glyphicon-trash {:aria-hidden true}] " Delete"]]]])
+
+(defn- hyphenation-pattern-edit-ui
+  [word new-hyphenation stop save]
+  [:tr
+   [:td word]
+   [:td
+    [:input.form-control
+     {:type "text"
+      :auto-focus true
+      :on-change #(reset! new-hyphenation (-> % .-target .-value))
+      :on-key-down #(case (.-which %)
+                      27 (stop)
+                      nil)
+      :value @new-hyphenation}]]
+   [:td
+    [:div.btn-group
+     [:button.btn.btn-default
+      {:on-click save}
+      [:span.glyphicon.glyphicon-ok {:aria-hidden true}] " Save"]
+     [:button.btn.btn-default
+      {:on-click stop}
+      [:span.glyphicon.glyphicon-remove {:aria-hidden true}] " Cancel"]]]])
+
+(defn hyphenation-pattern-item-ui [{:keys [hyphenation] :as pattern}]
   (let [editing (reagent/atom false)
         new-hyphenation (reagent/atom hyphenation)]
     (fn [{:keys [word hyphenation] :as pattern}]
-      (if-not @editing
-        [:tr
-         [:td word]
-         [:td hyphenation]
-         [:td
-          [:div.btn-group
-           [:button.btn.btn-default
-            {:on-click #(reset! editing true)}
-            [:span.glyphicon.glyphicon-edit {:aria-hidden true}] " Edit"]
-           [:button.btn.btn-default
-            {:on-click #(remove-hyphenation-pattern! pattern)}
-            [:span.glyphicon.glyphicon-trash {:aria-hidden true}] " Delete"]]]]
-        [:tr
-         [:td word]
-         [:td
-          [:input.form-control
-           {:type "text"
-            :auto-focus true
-            :on-change #(reset! new-hyphenation (-> % .-target .-value))
-            :on-key-down #(case (.-which %)
-                            27 (do
-                                 (reset! new-hyphenation hyphenation)
-                                 (reset! editing false))
-                            nil)
-            :value @new-hyphenation}]]
-         [:td
-          [:div.btn-group
-           [:button.btn.btn-default
-            {:on-click #(do (when (hyphenation-valid? @new-hyphenation)
-                              (add-hyphenation-pattern!
-                               (assoc pattern :hyphenation @new-hyphenation)))
-                            (reset! editing false))}
-            [:span.glyphicon.glyphicon-ok {:aria-hidden true}] " Save"]
-           [:button.btn.btn-default
-            {:on-click #(do
-                          (reset! new-hyphenation hyphenation)
-                          (reset! editing false))}
-            [:span.glyphicon.glyphicon-remove {:aria-hidden true}] " Cancel"]]]]))))
-
-(defn word-field []
+      (let [stop #(do (reset! new-hyphenation hyphenation)
+                      (reset! editing false))
+            start #(reset! editing true)
+            save #(do (when (hyphenation-valid? @new-hyphenation)
+                        (add-hyphenation-pattern! (assoc pattern :hyphenation @new-hyphenation)))
+                      (reset! editing false))
+            remove #(remove-hyphenation-pattern! pattern)]
+        (if-not @editing
+          [hyphenation-pattern-readonly-ui word hyphenation start remove]
+          [hyphenation-pattern-edit-ui word new-hyphenation stop save])))))
+
+(defn word-ui []
   [:div.form-group
    [:label {:for "wordInput"} "Word"]
    [:input.form-control


Main.clj: refer command-list to command the bot from main

--- src/clojure/life/daemon/main.clj
+++ src/clojure/life/daemon/main.clj
@@ -6,7 +6,8 @@
               [neko.find-view :refer [find-view]]
               [neko.threading :refer [on-ui]]
               [life.daemon.brocas-area :as brocas-area]
-              [life.daemon.motor-cortex :as motor-cortex])
+              [life.daemon.motor-cortex :as motor-cortex]
+              [life.daemon.list-of-motor-commands :as commands])
     (:import android.widget.EditText
              [android.speech.tts TextToSpeech$OnInitListener]
              [android.view View]))


Revert "Lower the timeout"

Revert "Lower the timeout"

This reverts commit 21e4627b4cdd68ac5fa4de0660321a66c11b26be.

--- src/clojure/nightmod/sandbox.clj
+++ src/clojure/nightmod/sandbox.clj
@@ -42,7 +42,7 @@

 (def sb (jail/sandbox tester
                       :context context
-                      :timeout 3000
+                      :timeout 5000
                       :namespace u/game-ns
                       :max-defs Integer/MAX_VALUE
                       :init '(do


sorry,sorry

sorry,sorry

--- src/Miscellaneous/purui.clj
+++ src/Miscellaneous/purui.clj
@@ -133,6 +133,7 @@
 (def query-9 "SELECT brand, pubtime FROM purui0214_2013_spam_dupliremov_media;")
 (def query-10 "SELECT origin FROM purui0208_2013_spam;")
 (def query-11 "SELECT origin FROM purui0214_2013_spam_dupliremov_media;")
+(def query-12 "SELECT * FROM purui0208_2013_spam;")

@@ -247,7 +248,7 @@
      (sort #(> (:all-counts %1) (:all-counts %2)))
      (toCSV/toCSV2 [:origin :all-counts :unique-counts] address-1))

-(->> (fromCSV/lazy-read-csv "E:/数据/朴睿/everything.csv/everything.csv")
+#_(->> (fromCSV/lazy-read-csv "E:/数据/朴睿/everything.csv/everything.csv")
      ;(drop 2000)
      map-csv
      (map #(correct-nil "uk" :extracted %))
@@ -271,7 +272,9 @@
      )

-
+(->> (jdbc/query db-spec2 [query-12])
+     (toCSV/toCSV2 [:origin :topic :brand :kw :pubtime :url] address-1)
+     )

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;tips;;;;;;;;;;;;;;;;;;;;;;;;


Convert lesson 07 to function-first-api

Convert lesson 07 to function-first-api

--- src/cljs/gampg/learn_gamma/lesson_07.cljs
+++ src/cljs/gampg/learn_gamma/lesson_07.cljs
@@ -1,14 +1,10 @@
 (ns gampg.learn-gamma.lesson-07
-    (:require [clojure.string :as s]
-            [gamma.api :as g]
+  (:require [gamma.api :as g]
             [gamma.program :as p]
-            [gamma.tools :as gt]
+            [gamma-driver.api :as gd]
             [gamma-driver.drivers.basic :as driver]
-            [gamma-driver.protocols :as dp]
-            [goog.webgl :as ggl]
             [thi.ng.geom.core :as geom]
-            [thi.ng.geom.core.matrix :as mat :refer [M44]]
-            [thi.ng.geom.webgl.arrays :as arrays]))
+            [thi.ng.geom.core.matrix :as mat :refer [M44]]))

 (def title
   "7. Basic directional and ambient lighting")
@@ -247,13 +243,13 @@
                    (geom/translate [x 0 -7])
                    (geom/rotate-around-axis [1 0 0] cube-rotation)
                    (geom/rotate-around-axis [0 -1 0] cube-rotation))]
-        (driver/draw-elements driver program
-                          (assoc (get-data p mv cube-vertices cube-normals texture cube-texture-coords)
-                            {:tag :element-index} cube-indices)
+        (gd/draw-elements driver (gd/bind driver program
+                                          (assoc (get-data p mv cube-vertices cube-normals texture cube-texture-coords)
+                                                 {:tag :element-index} cube-indices))
                           {:draw-mode :triangles
-                           :first 0
+                           :first     0
                            ;; Hard-coded
-                           :count 36})))))
+                           :count     36})))))

 (defn animate [draw-fn step-fn current-value]
   (js/requestAnimationFrame
@@ -279,7 +275,7 @@
   (let [width     (.-clientWidth node)
         height    (.-clientHeight node)
         driver    (driver/basic-driver gl)
-        program   (dp/program driver program-source)
+        program   program-source
         state (app-state width height)]
     (reset-gl-canvas! node)
     (.enable gl (.-DEPTH_TEST gl))
@@ -287,10 +283,10 @@
     (.clear gl (bit-or (.-COLOR_BUFFER_BIT gl) (.-DEPTH_BUFFER_BIT gl)))
     (let [image (js/Image.)]
       (aset image "onload"
-            (fn [] (let [texture {:data {:data       image
-                                        :filter     {:min :linear
-                                                     :mag :nearest}
-                                        :flip-y     true
-                                        :texture-id 0}}]
+            (fn [] (let [texture {:data       image
+                                 :filter     {:min :linear
+                                              :mag :nearest}
+                                 :flip-y     true
+                                 :texture-id 0}]
                     (animate (draw-fn gl driver program) tick (assoc-in state [:scene :texture] texture)))))
       (aset image "src" "/images/crate.gif"))))


Refactoring

Refactoring

--- src/cljs/gtfve/components/side_panel.cljs
+++ src/cljs/gtfve/components/side_panel.cljs
@@ -26,34 +26,33 @@
          (when active? "active")
          (when in? "in")]))

-(defn stop-search-results [data owner]
+(defn stop-search-results [{:keys [data query]} owner]
   (reify
     om/IDisplayName (display-name [_] "Stop Search Results")
     om/IRender
     (render [_]
       (html
-       (let [{:keys [query]} (om/get-state owner)]
-         (cond
-           (empty? query) nil
-           (empty? data) [:div.alert.alert-danger
-                          [:p "No stops found matching "
-                           [:i query]]]
-           :else (into [:div.list-group]
-                       (map (fn [stop]
-                              [:a.list-group-item {:key (:db/id stop)
-                                                   :href "#"}
-                               [:h5.list-group-item-heading (:stop/name stop)]
-                               [:p.list-group-item-text (str (:stop/latitude stop)
-                                                             "/"
-                                                             (:stop/longitude stop))]])
-                            data))))))))
+       (cond
+         (empty? query) nil
+         (empty? data) [:div.alert.alert-danger
+                        [:p "No stops found matching "
+                         [:i query]]]
+         :else (into [:div.list-group]
+                     (map (fn [stop]
+                            [:a.list-group-item {:key (:db/id stop)
+                                                 :href "#"}
+                             [:h5.list-group-item-heading (:stop/name stop)]
+                             [:p.list-group-item-text (str (:stop/latitude stop)
+                                                           "/"
+                                                           (:stop/longitude stop))]])
+                          data)))))))

 (defn stop-panel [{:keys [tab panel data active? in?]} owner]
   (reify
     om/IDisplayName (display-name [_] "Stop Panel")
     om/IRender
     (render [_]
-      (let [query (:query panel)]
+      (let [{:keys [query last-query]} panel]
         (html
          [:div {:className (tab-class active? in?)}
           [:div.tab-content-wrapper
@@ -70,7 +69,7 @@
                  :placeholder "Search"
                  :value query
                  :on-change #(utils/edit-input owner :input-stops-search %)}]]]]]
-           (om/build stop-search-results data {:state {:query (:last-query panel)}})
+           (om/build stop-search-results {:data data :query last-query})
            [:button.btn.btn-default.btn-block {:href "#"} "Load More"]]])))))

 (defn route-panel [{:keys [tab data active? in?]} owner]


added conn function

added conn function

--- modules/datomic/src/modular/datomic.clj
+++ modules/datomic/src/modular/datomic.clj
@@ -8,6 +8,9 @@
    [datomic.api :as d]
    [schema.core :as s]
    clojure.tools.reader))
+
+(defn conn [connection-comp]
+      (:connection connection-comp))

 (defrecord EphemeralDatabase [uri]
   component/Lifecycle
@@ -53,7 +56,7 @@
   component/Lifecycle
   (start [this]
     (with-open [rdr (java.io.PushbackReader. (io/reader res))]
-      @(d/transact (get-in this [:connection :connection])
+      @(d/transact (conn (this :connection))
                    (binding [clojure.tools.reader/*data-readers*
                              {'db/id datomic.db/id-literal
                               'db/fn datomic.function/construct
@@ -79,7 +82,7 @@
 (defrecord DatomicFunctions [functions]
   component/Lifecycle
   (start [this]
-    @(d/transact (get-in this [:connection :connection]) (create-functions functions))
+    @(d/transact (conn (this :connection)) (create-functions functions))
     this)
   (stop [this] this))


Remove unned commas

Remove unned commas

--- src-cljs/search.cljs
+++ src-cljs/search.cljs
@@ -19,7 +19,7 @@

 (defn result-line
   "Search result line"
-  [{:keys [url, name, show, season, episode, source, lang, version]}]
+  [{:keys [url name show season episode source lang version]}]
   [:a.list-group-item.search-result {:href url
                                      :target "_blank"}
    [:h3


Add ws-port option to change port that the websocket connects to

Useful when the reload websocket is an upstream client of a reverse proxy (like nginx)

--- src/adzerk/boot_reload.clj
+++ src/adzerk/boot_reload.clj
@@ -23,11 +23,11 @@
          (map tmp-path)
          (remove static-files))))

-(defn- start-server [pod {:keys [ip port ws-host secure?] :as opts}]
+(defn- start-server [pod {:keys [ip port ws-host ws-port secure?] :as opts}]
   (let [{:keys [ip port]} (pod/with-call-in pod (adzerk.boot-reload.server/start ~opts))
         host              (cond ws-host ws-host (= ip "0.0.0.0") "localhost" :else ip)
         proto             (if secure? "wss" "ws")]
-    (util/with-let [url (format "%s://%s:%d" proto host port)]
+    (util/with-let [url (format "%s://%s:%d" proto host (or ws-port port))]
       (util/info "Starting reload server on %s\n" url))))

 (defn- write-cljs! [f url ws-host on-jsload asset-host]
@@ -94,6 +94,7 @@
    ;; Websocket Server
    i ip ADDR         str  "The IP address for the websocket server to listen on. (optional)"
    p port PORT       int  "The port the websocket server listens on. (optional)"
+   _ ws-port PORT    int  "The port the websocket will connect to. (optional)"
    w ws-host WSADDR  str  "The websocket host clients connect to. Defaults to current host. (optional)"
    s secure          bool "Flag to indicate whether the client should connect via wss. Defaults to false."
    ;; Other Configuration
@@ -110,7 +111,8 @@
         prev-pre (atom nil)
         prev (atom nil)
         out  (doto (io/file src "adzerk" "boot_reload.cljs") io/make-parents)
-        url  (start-server @pod {:ip ip :port port :ws-host ws-host :secure? secure
+        url  (start-server @pod {:ip ip :port port :ws-host ws-host
+                                 :ws-port ws-port :secure? secure
                                  :open-file open-file})]
     (set-env! :source-paths #(conj % (.getPath src)))
     (write-cljs! out url ws-host on-jsload asset-host)


Have use-push pass along configuration.

Have use-push pass along configuration.

--- src/afterglow/examples.clj
+++ src/afterglow/examples.clj
@@ -887,6 +887,9 @@
 (defn use-push
   "A trivial reminder of how to connect the Ableton Push to run the
   show. But also sets up the cues, if you haven't yet."
-  []
+  [& {:keys [device-filter refresh-interval display-name]
+           :or {device-filter "User Port"
+                refresh-interval (/ 1000 15)
+                display-name "Ableton Push"}}]
   (make-cues)
-  (push/auto-bind *show*))
+  (push/auto-bind *show* :device-filter device-filter :refresh-interval refresh-interval :display-name display-name))


fix exception on tooltip hover

fix exception on tooltip hover

- exception is

    Uncaught TypeError: Cannot read property 'tagName' of undefined

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -1068,7 +1068,7 @@
           (utils/tooltip (str "#commit-line-tooltip-hack-" commit)
                          {:placement "bottom"
                           :animation false
-                          :viewport "#build-log-container"})))
+                          :viewport ".build-commits-container"})))
       om/IRender
       (render [_]
         (html


Clean up

Clean up

--- src/advent_2017/day_21.cljc
+++ src/advent_2017/day_21.cljc
@@ -35,7 +35,10 @@
   (let [size (if (zero? (rem (count (first input)) 2))
                2
                3)]
-    (into [] (comp (split-xf size) (map #(map pattern-map %)) join-xf) input)))
+    (into [] (comp (split-xf size)
+                   (map #(map pattern-map %))
+                   join-xf)
+      input)))

 (defn solve [iterations]
   (let [step (partial step* (make-pattern-map input))]


you can't buy events

you can't buy events

--- src/babel/encyclopedia.cljc
+++ src/babel/encyclopedia.cljc
@@ -67,7 +67,8 @@
    {:edible true}    {:consumable true
                       :drinkable false}

-   {:event true}     {:physical-object false
+   {:event true}     {:buyable false
+                      :physical-object false
                       :speakable false}

    {:furniture true} {:artifact true


~(defn park): simplify to only allow non-phrasal heads

--- src/babel/italiano/lab.cljc
+++ src/babel/italiano/lab.cljc
@@ -163,14 +163,21 @@
        specs))

 (defn park []
-  (repeatedly
-   #(println (morph (time
-                     (generate
-                      (unify
-                       (nth vedere-specs (rand-int (count vedere-specs)))
-                       {:head {:phrasal false}
-                        :comp {:phrasal false}})
-                      model))))))
+  (let [vedere-specs
+        [{:synsem {:subcat (), :cat :verb, :essere false},
+          :modified false,
+          :phrasal true,
+          :head {:phrasal false},
+          :comp {:phrasal false},
+          :root {:italiano {:italiano "vedere"}}}]]
+    (repeatedly
+     #(println (morph (time
+                       (generate
+                        (unify
+                         (nth vedere-specs (rand-int (count vedere-specs)))
+                         {:head {:phrasal false}
+                          :comp {:phrasal false}})
+                        model)))))))

 (defn downtown []
   (let [spec


Update getting-started with less names

Update getting-started with less names

--- src/css-guide/styles/getting_started.cljs
+++ src/css-guide/styles/getting_started.cljs
@@ -7,31 +7,32 @@
             [om.dom :as dom]))

 (defarticle intro
-"# What is Untangled Stylekit?
+"# What is this?

-Stylekit is a user interface library of patterns for web applications and websites built with a custom PostCSS preprocessor.
+A styleguide of user interface patterns for web applications and websites built with a custom PostCSS preprocessor
+rendered with ClojureScript.

-#### History of Stylekit
+#### History of this project

-## What is Stylekit for?
+## What is this for?

 This project is meant to suppliment your next project with a wide array of components that are styled for your HTML or
 Clojurescript project. If you are using Untangled UI, you will automatically get these styles by default.

-## What problem does Stylekit solve?
+## What problem does this solve?

-## What design principles underlie Stylekit?
+## What design principles underlie this UI?

 Based on the ITCSS methodology by Harry Roberts, this project is composed by settings, elements, components, objects and
 utilities and produces a stylesheet that has a healthy inclining specificity graph.

-## How does Stylekit accomplish it's goals?
+## How does this UI accomplish it's goals?

 # Getting Started


Solving 5.13 - solved via unfold - map, take and take-while (zip-with and zip-all pending)

--- src/fpinscala/strictness_and_laziness.clj
+++ src/fpinscala/strictness_and_laziness.clj
@@ -259,4 +259,36 @@
   "Ones via my wrong implementation of unfold"
   []
   (map first (unfold [1 1] #(when-let [[x0 x1] %]
-                             [x0 x1]))))+                             [x0 x1]))))
+
+;5.13 - map
+;mine
+(defn map-via-unfold [f s]
+  (unfold-fpins s #(let [[h & t] %]
+                    (when h
+                      [(f h) t]))))
+;fpins - more or less the same
+;as fpins variant is using pattern match with function which (raw) Clojure lacks
+
+;5.13 - take
+;mine
+(defn take-via-unfold
+  "Take via unfold for exercise 5.13 of fpins"
+  [n s]
+  (unfold-fpins [s 1] #(let [[[h & t] cnt] %]
+                        (when (and h (<= cnt n))
+                          [h [t (inc cnt)]]))))
+;fpins
+;conceptually - the same, just counting backwards and pattern matching on 1
+;which I am awoiding as I am sticking to raw clojure without involving core.match
+
+;5.13 - takeWhile
+;mine
+(defn take-while-via-unfold
+  "Take-while via unfold for exercise 5.13 of fpins"
+  [f s]
+  (unfold-fpins s #(let [[h & t] %]
+                    (when (and h (f h))
+                      [h t]))))
+;fpins
+;conceptually - the same


s/(log/info)/(println)/

s/(log/info)/(println)/

--- src/babel/english.cljc
+++ src/babel/english.cljc
@@ -20,9 +20,9 @@
            (realized? medium-model))
     @medium-model
     @(do
-       (log/info (str "creating model..(will be slow the first time).."))
+       (println (str "creating model..(will be slow the first time).."))
        (let [result (deliver medium-model (grammar/medium))]
-         (log/info (str "done."))
+         (println (str "done."))
          result))))

 (declare morph)


cleanup

cleanup

--- src/babel/english.cljc
+++ src/babel/english.cljc
@@ -73,7 +73,6 @@
   ([input model]
    (parse/parse (preprocess input) model)))

-
 (defn sentences [ & [count spec model]]
   (let [count (or (Integer. count) 100)
         model (or model (medium))
@@ -97,11 +96,3 @@
                              "."))]
                   (println (str (+ 1 num) ". " to-print)))))
             (range 0 count)))))
-
-
-
-
-
-
-
-


remove test in om

remove test in om

--- frontend/components/landing.cljs
+++ frontend/components/landing.cljs
@@ -51,9 +51,7 @@
       [:h3 "CircleCI gives web developers powerful Continuous Integration and Deployment with easy setup and maintenance."]
       [:h3 "CircleCI is Continuous Integration and Delivery for modern web development."])
     [:div.how.row-fluid
-     (if (:hero_graphic ab-tests)
-       hero-graphic
-       shared/stories-procedure)]
+       hero-graphic]
     [:div.row-fluid
      [:div.hero-unit-cta
       (home-cta controls-ch)]]]])


prompt for java.library.path

prompt for java.library.path

--- src/cake/tasks/compile.clj
+++ src/cake/tasks/compile.clj
@@ -2,7 +2,7 @@
   (:use cake cake.core cake.ant cake.file
         [cake.project :only [verbose? debug? log]]
         [cake.utils.find-namespaces :only [find-clojure-sources-in-dir read-file-ns-decl]]
-        [cake.utils :only [os-name os-arch sudo]]
+        [cake.utils :only [os-name os-arch sudo prompt-read]]
         [cake.utils.useful :only [pluralize]]
 	[cake.ant :only [fileset-seq]])
   (:import [org.apache.tools.ant.taskdefs Copy Javac Java]))
@@ -79,7 +79,11 @@
 ;; see http://github.com/lancepantz/tokyocabinet for an example
 (deftask compile-native)

-(deftask install-native
+(deftask install-native #{compile-native}
+  (copy-native)
   (let [files (vec (map str (fileset-seq {:dir (file "lib" "native")
-					  :includes "*"})))]
-    (apply sudo "cp" (conj files "/usr/local/lib/"))))+					  :includes "*"})))
+	default "/usr/lib/java/"
+	dest (prompt-read (format "java.library.path [%s]:" default))
+	dest (if (= "" dest) default dest)]
+    (apply sudo "cp" (conj files dest))))


Add a level to the heading generation

Add a level to the heading generation

so we can adjust the headings for the individual output formats

--- src/catalog/layout/fop.clj
+++ src/catalog/layout/fop.clj
@@ -269,33 +269,36 @@
   [:fo:list-block
    (for [item items] (entry-sexp item))])

-(defn subgenre-sexp [items fmt genre subgenre]
+(defn- level-to-h [level]
+  (keyword (str "h" level)))
+
+(defn subgenre-sexp [items fmt genre subgenre level]
   (when-let [items (subgenre items)]
-    [(heading :h3 subgenre [fmt genre subgenre])
+    [(heading (level-to-h level) subgenre [fmt genre subgenre])
      (when-not (#{:kinder-und-jugendbücher} genre)
        (set-marker (layout/translations subgenre)))
      (entries-sexp items)]))

-(defn subgenres-sexp [items fmt genre]
-  (mapcat #(subgenre-sexp items fmt genre %) (order (keys items))))
-
-(defn genre-sexp [items fmt genre]
+(defn subgenres-sexp [items fmt genre level]
+  (mapcat #(subgenre-sexp items fmt genre % level) (order (keys items))))
+
+(defn genre-sexp [items fmt genre level]
   (when-let [items (genre items)]
-    [(heading :h2 genre [fmt genre])
+    [(heading (level-to-h level) genre [fmt genre])
      (set-marker (layout/translations genre))
      (cond
-       (#{:kinder-und-jugendbücher} genre) (subgenres-sexp items fmt genre)
-       (#{:hörbuch} fmt) (subgenres-sexp items fmt genre)
+       (#{:kinder-und-jugendbücher} genre) (subgenres-sexp items fmt genre (inc level))
+       (#{:hörbuch} fmt) (subgenres-sexp items fmt genre (inc level))
        :else (entries-sexp items))]))

-(defn format-sexp [items fmt]
+(defn format-sexp [items fmt level]
   (when-let [items (fmt items)]
-    [(heading :h1 fmt [fmt])
+    [(heading (level-to-h level) fmt [fmt])
      (toc items [fmt] 3)
      (set-marker (layout/translations fmt))
      (case fmt
        (:hörfilm :ludo) (entries-sexp items)
-       (mapcat #(genre-sexp items fmt %) (order (keys items))))]))
+       (mapcat #(genre-sexp items fmt % (inc level)) (order (keys items))))]))

 (defn- page-number []
   [:fo:inline
@@ -404,7 +407,7 @@
          (toc subitems [fmt] 3 :heading? true :editorial? true)
          (heading :h1 :editorial [fmt :editorial])
          (heading :h1 :recommendation [fmt :recommendations])
-         (mapcat #(genre-sexp subitems fmt %) (order (keys subitems)))])]]))
+         (mapcat #(genre-sexp subitems fmt % 1) (order (keys subitems)))])]]))

 (defmethod document-sexp :hörbuch
   [items fmt {:keys [description date]}]
@@ -426,7 +429,7 @@
        (block {:break-before "odd-page"}) ;; the very first format should start on recto
        (heading :h1 :editorial [fmt :editorial])
        (heading :h1 :hörbuch [fmt :hörbuch])
-       (mapcat #(genre-sexp subitems fmt %) (order (keys subitems)))
+       (mapcat #(genre-sexp subitems fmt % 1) (order (keys subitems)))
        (heading :h1 :recommendations [fmt :recommendations])])]])

 (defmethod document-sexp :all-formats
@@ -446,7 +449,7 @@
     [:fo:flow {:flow-name "xsl-region-body"}
      (toc items [] 1 :heading? true)
      (block {:break-before "odd-page"}) ;; the very first format should start on recto
-     (mapcat #(format-sexp items %) (order (keys items)))]]])
+     (mapcat #(format-sexp items % 1) (order (keys items)))]]])

 (defn document [items fmt & args]
   (-> items


check for duplicates in namespace map literals

--- src/main/clojure/clojure/tools/reader.clj
+++ src/main/clojure/clojure/tools/reader.clj
@@ -762,7 +762,7 @@
               (reader-error rdr "Map literal must contain an even number of forms"))
             (let [keys (take-nth 2 items)
                   vals (take-nth 2 (rest items))]
-              (zipmap (namespace-keys (str ns) keys) vals)))
+              (RT/map (to-array (mapcat list (namespace-keys (str ns) keys) vals)))))
           (reader-error rdr "Namespaced map must specify a map")))
       (reader-error rdr "Invalid token used as namespace in namespaced map: " token))))


moving over to desktop

moving over to desktop

--- src/main/clojure/org/dada/demo/whales.clj
+++ src/main/clojure/org/dada/demo/whales.clj
@@ -91,17 +91,18 @@
 (def #^Metadata whale-metadata (apply metadata Whale :time :version attributes))
 (def #^Model whales (model "Whales" whale-metadata))

+(def num-whales 10000)
+(def start-time (System/currentTimeMillis))
+
 (insert *metamodel* whales)

 ;; create 10,000 whales and insert them into model
 (insert-n
  whales
- (let [num-whales 10000
-       time (System/currentTimeMillis)
-       #^Creator creator (.getCreator whale-metadata)
+ (let [#^Creator creator (.getCreator whale-metadata)
        max-length-x-100 (* max-length 100)
        max-weight-x-100 (* max-weight 100)]
-   (for [id (range time (+ time num-whales))]
+   (for [id (range start-time (+ start-time num-whales))]
      (.create
       creator
       (into-array
@@ -207,6 +208,17 @@
        )
    ))

+;; (do-split
+;;    whales
+;;    :time
+;;    false
+;;    #(mod % 10)
+;;    #(aget route-to-type #^Integer %)
+;;    (fn [#^Model model value]
+;;        (insert *metamodel* model)
+;;        model)
+;;    )
+
 ;; TODO: Reducers need to support variable length set of attribute keys

 ;;----------------------------------------
@@ -231,3 +243,7 @@

 ;; TODO - factory comes from core

+;;----------------------------------------
+;; TODO
+;; simplify splitting - Sparse splitting should use Object keys, not only int
+;; transform needs to suppport synthetic attributes


remove debug

remove debug

--- src/chessground/chess.cljs
+++ src/chessground/chess.cljs
@@ -22,10 +22,10 @@
 (defn put-piece [chess key piece] (assoc-in chess [:pieces key] piece))

 (defn set-pieces [chess changes]
-  (pp (update-in chess [:pieces]
+  (update-in chess [:pieces]
              (fn [pieces] (reduce (fn [ps [key p]]
                                     (if p (assoc ps key p) (dissoc ps key)))
-                                  pieces changes)))))
+                                  pieces changes))))

 (defn- count-pieces [chess] (count (:pieces chess)))


Remove debug output

Remove debug output

--- src/circle/backend/ec2.clj
+++ src/circle/backend/ec2.clj
@@ -302,7 +302,6 @@
                   :or {timeout (time/secs 30)
                        sleep-interval (time/secs 10)}}]
   (infof "block-until-running: waiting for instance %s to start" instance-id)
-  (infof "block-until-running: sleep-interval: %s %s" sleep-interval timeout)
   (try
     (wait-for
      {:sleep sleep-interval


Terminate instances when we fail to SSH

Terminate instances when we fail to SSH

--- src/circle/backend/ec2.clj
+++ src/circle/backend/ec2.clj
@@ -330,7 +330,9 @@
       (cond
        @success true
        (pos? timeout) (do (Thread/sleep (* sleep-interval 1000)) (recur (- timeout sleep-interval)))
-       :else (throwf "failed to SSH into %s" instance-id)))))
+       :else (do
+               (terminate-instances! instance-id)
+               (throwf "failed to SSH into %s" instance-id))))))

 (defn start-instances*
   "Starts one or more instances. Returns a seq of instance-ids."


Better logging of test performed - git url and branch name are stored as well

--- src/emender_service/rest_api.clj
+++ src/emender_service/rest_api.clj
@@ -164,8 +164,8 @@
     (map #(str path-to-tests "/" % ".lua") tests))

 (defn process-results
-    [job-name results]
-        (db-interface/log-job-results job-name results)
+    [job-name repo-url branch results]
+        (db-interface/log-job-results job-name repo-url branch results)
         (println "job name" job-name)
         (println "results:" results)
         ;(results/add-new-results job-name results)
@@ -174,7 +174,7 @@
                         :results results}))

 (defn run-emend
-    [job-name path-to-emender path-to-tests tests book-directory delete-workdirs?]
+    [job-name repo-url branch path-to-emender path-to-tests tests book-directory delete-workdirs?]
     (println "Starting Emend against the book directory" book-directory)
     (println book-directory)
     (println (type book-directory))
@@ -186,8 +186,8 @@
                 (if delete-workdirs?
                     (file-utils/remove-temporary-directory book-directory))
                 (if results
-                    (process-results job-name results))
-                    (send-response {:status :reading-job-result-failed}))
+                    (process-results job-name repo-url branch results)
+                    (send-response {:status :reading-job-result-failed})))
             (catch Exception e
                 (if delete-workdirs?
                     (file-utils/remove-temporary-directory book-directory))
@@ -213,7 +213,8 @@
         (let [;clone-results {:directory (new java.io.File "/tmp/emender-service-1460560704093/")}]
               clone-results (git-utils/clone-remote-repository repo-url branch)]
              (if (= (:status clone-results) :ok)
-                 (run-emend job-name path-to-emend path-to-tests tests
+                 (run-emend job-name repo-url branch
+                            path-to-emend path-to-tests tests
                             (.getAbsolutePath (:directory clone-results))
                             delete-workdirs?)
                  (do


more logging

more logging

--- src/babel/parse.cljc
+++ src/babel/parse.cljc
@@ -26,6 +26,7 @@
 (defn lookup [{lookup :lookup
                lexical-cache :lexical-cache
                default-fn :default-fn} k]
+  (log/debug (str "lookup: k=" k))
   (let [pre-default
         (if (or (= false parse-with-lexical-caching)
                 (nil? lexical-cache))
@@ -38,6 +39,8 @@
             (let [cache-value (get @lexical-cache k)]
               (if (= cache-value :none) nil
                   cache-value))))]
+    (log/debug (str "default-fn: nil? " (nil? default-fn)))
+    (log/debug (str "pre-default: count: " (count pre-default)))
     (cond (nil? default-fn)
           pre-default
           true
@@ -138,6 +141,7 @@
     (= n 1) input
     (> n 1)
     (let [minus-1 (parses input (- n 1) model span-map parse-with-truncate)]
+      (log/debug (str "parses: input=" input))
       (merge minus-1
              (reduce (fn [x y]
                        (merge-with concat x y))


test shares

test shares

--- src/clj/ceres/analyzer.clj
+++ src/clj/ceres/analyzer.clj
@@ -15,7 +15,9 @@
             [clj-time.periodic :as p]
             [clojure.pprint :refer [pprint]]
             [opennlp.nlp :refer [make-tokenizer make-detokenizer]]
+            [incanter.core :refer [view]]
             [incanter.stats :refer [mean variance quantile]]
+            [incanter.charts :as charts]
             [loom.graph :as lg]
             [loom.io :as lio]
             [ceres.collector :refer [db custom-formatter news-accounts store]])
@@ -66,6 +68,7 @@
          loc tree]
     (if (zip/end? loc)
       {:size size
+       :source (-> (zip/root tree) :source)
        :height max-path}
       (recur
        (if (zip/node loc) (inc size) size)
@@ -121,6 +124,36 @@
           (take 25)
           (map (fn [[k v]] [(:screen_name (mc/find-map-by-id @db "users" k))
                            v])))]))
+
+
+(defn create-d3-graph
+  "Converts zipper into d3 readable format"
+  [tree]
+  (loop [counter 0
+         types {}
+         nodes []
+         links []
+         loc tree]
+    (if (zip/end? loc)
+      {:nodes nodes
+       :types types
+       :links links}
+      (recur
+       (if (zip/node loc)
+         (inc counter)
+         counter)
+       (if-let [node (zip/node loc)]
+         (assoc types (-> node :source :_id str) (-> node :source :type))
+         types)
+       (if-let [node (zip/node loc)]
+         (conj nodes (-> node :source :_id str))
+         nodes)
+       (if-let [node (zip/node loc)]
+         (if-not (= node (zip/root tree))
+           (conj links {:source counter :target (.indexOf nodes (-> loc zip/up zip/node :source :_id str))})
+           links)
+         links)
+       (zip/next loc)))))

 (comment
@@ -168,5 +201,67 @@
          (sort-by first >)
          time))

-
-  )
+  (def all-delays
+    (let [users (map :_id (mc/find-maps @db "users" {:screen_name {$in news-accounts}}))]
+      (->> (mc/find-maps @db "publications" {:user {$in users}
+                                             :ts {$lt (t/date-time 2014 9 1)}})
+           (pmap (comp :delays analyze-delays full-reaction-tree :_id)))))
+
+  (defn dispatch-types [type]
+    (case type
+      "source" 0
+      "retweet" 1
+      "reply" 2
+      "share" 3
+      4))
+
+  (let [source-uids (map :_id (mc/find-maps @db "users" {:screen_name {$in news-accounts}}))
+        graph (->> (mc/find-maps @db "publications" {:user {$in source-uids}})
+             (pmap (comp summary reaction-tree :_id))
+             (sort-by :size >)
+             (take 3)
+             last
+             :source
+             full-reaction-tree
+             create-d3-graph)
+        types (:types graph)
+        cleaned-graph (update-in
+                       (dissoc graph :types)
+                       [:nodes]
+                       #(mapv
+                         (fn [k]
+                           {:name k
+                            :group (dispatch-types (get types k))})
+                         %))]
+    (with-open [w (clojure.java.io/writer "resources/graph-3b.edn")]
+      (binding [*print-length* false
+                *out* w]
+        (pr cleaned-graph))))
+
+
+  ;; find all related shares
+  (let [origins (mc/find-maps @db "origins" {:source nil
+                                             :ts {$gt (t/date-time 2014 8 1)
+                                                  $lt (t/date-time 2014 9 1)}})]
+    (->> origins
+         (map (comp :in_reply_to_status_id #(mc/find-map-by-id @db "tweets" (:tweet %))))
+         (take 10)
+         aprint))
+
+
+  (->> (mc/find-maps @db "publications" {:type :share})
+       (pmap (comp #(mc/find-one-as-map @db "reactions" {:publication %}) :_id))
+       (remove nil?)
+       count
+       aprint
+       time)
+
+  ((comp float /) (mc/count @db "reactions" {:source nil})
+     (mc/count @db "reactions"))
+
+
+  (mc/find-maps @db "origins" {:source nil
+                               :ts {$gt (t/date-time 2014 8 1)
+                                    $lt (t/date-time 2014 9 1)}})
+
+)


fully implement Bandwidth

fully implement Bandwidth

--- src/clj/game/cards-ice.clj
+++ src/clj/game/cards-ice.clj
@@ -46,7 +46,14 @@
     :rez-cost-bonus (req (* -3 (or (:advance-counter card) 0)))}

    "Bandwidth"
-   {:abilities [{:msg "give the Runner 1 tag" :effect (effect (tag-runner :runner 1))}]}
+   {:abilities [{:msg "give the Runner 1 tag"
+                 :effect (effect (tag-runner :runner 1)
+                                 (register-events
+                                   {:successful-run {:effect (effect (lose :runner :tag 1))
+                                                     :msg "make the Runner lose 1 tag"}
+                                    :run-ends {:effect (effect (unregister-events card))}}
+                                  card))}]
+    :events {:successful-run nil :run-ends nil}}

    "Bastion"
    {:abilities [end-the-run]}


Fix docstring.

Fix docstring.

--- src/clj_ravendb/client.clj
+++ src/clj_ravendb/client.clj
@@ -49,13 +49,14 @@
 (defn put-index!
   "Creates or updates an index, where an index takes
   the form:
-  idx {:index index-name
-       :where [[:== :field \"value\"]]
-       :select [:field]}
+
+  `(let [idx {:index index-name
+             :where [[:== :field \"value\"]]
+             :select [:field]}])`

   Invoke using the following:

-  `(put-index client idx options)
+  `(put-index client idx options)`

   Optionally takes a map of options.
   :request-builder is a custom request builder fn.


some cleanup

some cleanup

--- src/cljs/signet/graph.cljs
+++ src/cljs/signet/graph.cljs
@@ -222,8 +222,6 @@
                                      (text d)))))))))

-
-
 (defn ^:export renderGraph
   [data container]
   (let [cg (read-string data)]