make :loade-mode :eval the default for :browser

seems like Chrome is often running out of resources when
fetching too many files separately. It seems to be more
restrictive in newer Chrome versions. :loader-mode :eval
seems to have helped 100% of people running into these
issues and works better in most situations anyways.

--- src/main/shadow/build/targets/browser.clj
+++ src/main/shadow/build/targets/browser.clj
@@ -83,7 +83,7 @@
                     default
                     []

-                    (or release? (= :eval (get-in config [:devtools :loader-mode])))
+                    (or release? (= :eval (get-in config [:devtools :loader-mode] :eval)))
                     [(str asset-path "/" (:output-name module))]

                     :else ;; dev-mode
@@ -465,22 +465,23 @@
 (def ^Escaper js-escaper
   (SourceCodeEscapers/javascriptEscaper))

-(defn eval-load-sources [state sources]
+(defn generate-eval-js-output [state {:keys [sources] :as mod}]
   (->> sources
        (remove #{output/goog-base-id})
-       (map #(data/get-source-by-id state %))
-       (map (fn [{:keys [output-name] :as rc}]
-              (let [{:keys [js] :as output} (data/get-output! state rc)
-
-                    source-map?
-                    (output/has-source-map? output)]
-                (str "SHADOW_ENV.evalLoad(\"" output-name "\", " source-map? " , \"" (.escape js-escaper ^String js) "\");")
-                )))
-       (str/join "\n")))
-
-(defn flush-unoptimized-module-eval!
-  [{:keys [unoptimizable build-options] :as state}
-   {:keys [goog-base output-name prepend append sources web-worker] :as mod}
+       (reduce
+         (fn [state src-id]
+           (let [{:keys [output-name] :as rc} (data/get-source-by-id state src-id)
+                 {:keys [js eval-js] :as output} (data/get-output! state rc)]
+             (if eval-js
+               state
+               (let [source-map? (output/has-source-map? output)
+                     eval-js (str "SHADOW_ENV.evalLoad(\"" output-name "\", " source-map? " , \"" (.escape js-escaper ^String js) "\");")]
+                 (assoc-in state [:output src-id :eval-js] eval-js)))))
+         state)))
+
+(defn flush-unoptimized-module-eval
+  [{:keys [unoptimizable] :as state}
+   {:keys [goog-base prepend append sources web-worker] :as mod}
    target]

   (let [sources
@@ -492,7 +493,9 @@
                 (into sources))))

         source-loads
-        (eval-load-sources state sources)
+        (->> sources
+             (map #(get-in state [:output % :eval-js]))
+             (str/join "\n"))

         out
         (str prepend
@@ -534,9 +537,10 @@
           out)]

     (io/make-parents target)
-    (spit target out)))
-
-(defn flush-unoptimized-module-fetch!
+    (spit target out))
+  state)
+
+(defn flush-unoptimized-module-fetch
   [{:keys [unoptimizable build-options] :as state}
    {:keys [goog-base output-name prepend append sources web-worker] :as mod}
    target]
@@ -631,15 +635,19 @@
           out)]

     (io/make-parents target)
-    (spit target out)))
-
-(defn flush-unoptimized-module!
+    (spit target out))
+
+  state)
+
+(defn flush-unoptimized-module
   [state module target]
-  (if (= :eval (get-in state [:shadow.build/config :devtools :loader-mode]))
-    (flush-unoptimized-module-eval! state module target)
-    (flush-unoptimized-module-fetch! state module target)))
-
-(defn flush-unoptimized!
+  (if (= :eval (get-in state [:shadow.build/config :devtools :loader-mode] :eval))
+    (-> state
+        (generate-eval-js-output module)
+        (flush-unoptimized-module-eval module target))
+    (flush-unoptimized-module-fetch state module target)))
+
+(defn flush-unoptimized
   [{:keys [build-modules] :as state}]

   ;; FIXME: this always flushes
@@ -656,17 +664,11 @@
   (util/with-logged-time
     [state {:type :flush-unoptimized}]

-    (doseq [{:keys [output-name] :as mod} build-modules]
-      (flush-unoptimized-module! state mod (data/output-file state output-name)))
-
-    state
-    ))
-
-(defn flush-unoptimized
-  [state]
-  "util for ->"
-  (flush-unoptimized! state)
-  state)
+    (reduce
+      (fn [state {:keys [output-name] :as mod}]
+        (flush-unoptimized-module state mod (data/output-file state output-name)))
+      state
+      build-modules)))

 (defn flush [state mode {:keys [module-loader module-hash-names] :as config}]
   (case mode
@@ -700,8 +702,6 @@
           (flush-module-data))
         (flush-manifest))))

-
-
 (defn make-web-worker-prepend [state mod]
   (let [all
         (get-all-module-deps state mod)


Window resizing when dragging corners

Window resizing when dragging corners

--- flatguiwidgets/src/flatgui/widgets/resizeablebar.clj
+++ flatguiwidgets/src/flatgui/widgets/resizeablebar.clj
@@ -27,37 +27,28 @@
         (let [mabsx (mouse/get-mouse-x component)
               mabsy (mouse/get-mouse-y component)
               mrelx (mouse/get-mouse-rel-x component)
-              mrely (mouse/get-mouse-rel-y component)]
-          (cond
-            (flatgui.widgets.floatingbar/mouse-in-area capture-area-left mrelx mrely) {:edge :left :x mabsx :y mabsy :position-matrix pm :clip-size cs}
-            (flatgui.widgets.floatingbar/mouse-in-area capture-area-right mrelx mrely) {:edge :right :x mabsx :y mabsy :position-matrix pm :clip-size cs}
-            (flatgui.widgets.floatingbar/mouse-in-area capture-area-top mrelx mrely) {:edge :top :x mabsx :y mabsy :position-matrix pm :clip-size cs}
-            (flatgui.widgets.floatingbar/mouse-in-area capture-area-bottom mrelx mrely) {:edge :bottom :x mabsx :y mabsy :position-matrix pm :clip-size cs}
-            :else old-mouse-capture-edges))
+              mrely (mouse/get-mouse-rel-y component)
+              left (flatgui.widgets.floatingbar/mouse-in-area capture-area-left mrelx mrely)
+              right (flatgui.widgets.floatingbar/mouse-in-area capture-area-right mrelx mrely)
+              top (flatgui.widgets.floatingbar/mouse-in-area capture-area-top mrelx mrely)
+              bottom (flatgui.widgets.floatingbar/mouse-in-area capture-area-bottom mrelx mrely)]
+          (if (or left right top bottom)
+            {:edges {:left left :right right :top top :bottom bottom} :x mabsx :y mabsy :position-matrix pm :clip-size cs}
+            old-mouse-capture-edges))
         old-mouse-capture-edges))))

 (fg/defevolverfn resizeablebar-clip-size-evolver :clip-size
   (if (mouse/is-mouse-event? component)
     (if-let [mce (get-property component [:this] :mouse-capture-edges)]
-      (let [new-size (condp = (:edge mce)
-
-                       ;; TODO temporarily disabled, because table does not behave well when _decreasing_ vertical size
-                       ;;
-                       :bottom (m/defpoint
-                                 (m/x old-clip-size)
-                                 (do ;(println " (get-mouse-y component) " (float (get-mouse-y component)) " (:y mce) " (float (:y mce)))
-                                   (+ (m/y (:clip-size mce)) (- (mouse/get-mouse-y component) (:y mce)))))
-                       :top (m/defpoint
-                              (m/x old-clip-size)
-                              (do ;(println " (get-mouse-y component) " (float (get-mouse-y component)) " (:y mce) " (float (:y mce)))
-                                (+ (m/y (:clip-size mce)) (max 0 (- (mouse/get-mouse-y component) (:y mce))))))
-                       :left (m/defpoint
-                               (- (m/x (:clip-size mce)) (- (mouse/get-mouse-x component) (:x mce)))
-                               (m/y old-clip-size))
-                       :right (m/defpoint
-                                (+ (m/x (:clip-size mce)) (- (mouse/get-mouse-x component) (:x mce)))
-                                (m/y old-clip-size))
-                       old-clip-size)]
+      (let [new-size (m/defpoint
+                       (cond
+                         (:left (:edges mce)) (- (m/x (:clip-size mce)) (- (mouse/get-mouse-x component) (:x mce)))
+                         (:right (:edges mce)) (+ (m/x (:clip-size mce)) (- (mouse/get-mouse-x component) (:x mce)))
+                         :else (m/x old-clip-size))
+                       (cond
+                         (:bottom (:edges mce)) (+ (m/y (:clip-size mce)) (- (mouse/get-mouse-y component) (:y mce)))
+                         (:top (:edges mce)) (+ (m/y (:clip-size mce)) (max 0 (- (mouse/get-mouse-y component) (:y mce))))
+                         :else (m/y old-clip-size)))]
         (m/defpoint
           (if (< (m/x new-size) (m/x old-clip-size)) (if (layout/can-shrink-x component) (m/x new-size) (m/x old-clip-size)) (m/x new-size))
           (if (< (m/y new-size) (m/y old-clip-size)) (if (layout/can-shrink-y component) (m/y new-size) (m/y old-clip-size)) (m/y new-size))))


add :js-options :hide-warnings-for to hide closure warnings

certain npm packages (eg. ndarray) cause a lot of compiler
warnings despite working perfectly fine. need an option to ignore
warnings for certain files.

   :js-options
   {:hide-warnings-for
    #{"node_modules/ndarray/ndarray.js"}}

will disabled all 50 warnings for that file.

--- src/main/shadow/build/closure.clj
+++ src/main/shadow/build/closure.clj
@@ -1172,7 +1172,17 @@
   ([{::keys [compiler result] :as state}]
    (log-warnings state compiler result))
   ([state compiler result]
-   (let [warnings (into [] (js-error-xf state compiler) (.warnings result))]
+   (let [ignore
+         (get-in state [:js-options :hide-warnings-for] #{})
+
+         warnings
+         (into []
+           (comp
+             (js-error-xf state compiler)
+             (remove
+               (fn [{:keys [resource-name]}]
+                 (contains? ignore resource-name))))
+           (.warnings result))]
      (when (seq warnings)
        (util/warn state {:type ::warnings
                          :warnings warnings})))


Trim whitespace from game names when reading from steam

--- src/backloggery/data/steam.clj
+++ src/backloggery/data/steam.clj
@@ -1,6 +1,7 @@
 (ns backloggery.data.steam
   (:require [clj-http.client :as http])
   (:require [clojure.data.xml :as xml])
+  (:require [clojure.string :refer [trim]])
   (:require [backloggery.flags :refer :all])
   (:require [backloggery.data.default :refer [read-games]]))

@@ -16,6 +17,6 @@
   (let [name (:steam-name *opts*)
         url (str "http://steamcommunity.com/id/" name "/games?tab=all&xml=1")]
     (->> url http/get :body xml/parse-str xml-seq (filter #(= :game (:tag %)))
-      (map (comp :name xml-to-map))
+      (map (comp trim :name xml-to-map))
       sort
       (map (fn [name] { :name name :platform (:steam-platform *opts*) :progress "unplayed" })))))


Training uses new pattern recognition functions.

--- src/cadence/views/training.clj
+++ src/cadence/views/training.clj
@@ -1,6 +1,7 @@
 (ns cadence.views.training
   (:require [cadence.views.common :as common]
             [cadence.model :as model]
+            [cadence.pattern-recognition :as patrec]
             [cadence.model.validators :as is-valid]
             [noir.validation :as vali]
             (noir [response :as resp]
@@ -20,31 +21,48 @@
     [:div#train_well.well.container-fluid
      [:p.help "Simply type the following phrase in the form repeatedly until I"
       " tell you to stop."]
-     (let [train-count (sess/put! :train-count 0)
-           phrase (model/get-phrase)]
+     (let [phrase (model/get-phrase)]
        (html [:div.row-fluid
               [:div#training-phrase.input-xlarge.uneditable-input.span12
                phrase]]
              [:form#trainer.row-fluid
               (common/input {:type "text"
                              :eclass ".phrase.input-xlarge.span12"
-                             :name (str "phrase-"
-                                        (sess/get :train-count))
+                             :name "phrase"
                              :placeholder phrase})]))
      [:div#feedback.row-fluid]
      [:div#completion.row-fluid
-      [:h3.span2 "Completion: "]
-      [:div.progress.progress-success.span10 [:div.bar {:style "width: 0%;"}]]]]))
+      (let [trcount (count (patrec/kept-cadences))]
+        (html
+          [:div.progress.progress-success.progress-striped.span10
+           [:div.bar
+            {:style (str "width: "
+                         (* 100.0 (/ trcount @patrec/training-min))
+                         "%;")}]]
+          (if (>= trcount @patrec/training-min)
+            [:button.btn.btn-large.btn-success.span2 "I'm done"]
+            [:button.btn.btn-large.disabled.span2 "Complete"])))]]))

 (defpage post-training [:post "/user/training"] {:as unkeyed-cad}
+  ; I like maps with keyword keys
   (let [cadence (keywordize-keys unkeyed-cad)]
+    ; Ensure that the supplied data is really what I want it to be and not some
+    ; glitch or fabrication. (This uses noir.validation)
     (if (is-valid/cadence? cadence)
-      (if (model/add-cadence cadence)
+      (if (patrec/keep-cadence cadence)
+        (let [trnmin @patrec/training-min
+              kept (patrec/kept-cadences)
+              trcount (count kept)
+              done (<= trnmin trcount)]
+          (resp/json {:success true
+                      :done done
+                      :session kept
+                      :progress (* 100.0 (/ trcount @patrec/training-min))}))
         (resp/json {:success true
-                    :progress 20})
-        (resp/json {:success true
+                    :done false
                     :progress 0}))
-      (do
-        (resp/json {:success false
-                    :errors (vali/get-errors :cadence)
-                    :progress 0})))))
+      ; If bad data was received then tell the client we were not successful
+      (resp/json {:success false
+                  ; Grab errors put on the cadence field using noir.validation
+                  :errors (vali/get-errors :cadence)
+                  :progress 0}))))


Housekeeping

Housekeeping

--- src/taoensso/carmine/protocol.clj
+++ src/taoensso/carmine/protocol.clj
@@ -181,7 +181,7 @@
   BLOCKS to receive queued (pipelined) replies from Redis server. Applies all
   parsing and returns the result. Note that Redis returns replies as a FIFO
   queue per connection."
-  [always-as-vec?]
+  [as-bulk?]
   (let [^DataInputStream in (or (:in-stream *context*)
                                 (throw no-context-error))
         parsers     @(:parser-queue *context*)
@@ -191,7 +191,7 @@
       ;; (swap! (:parser-queue *context*) #(subvec % reply-count))
       (reset! (:parser-queue *context*) [])

-      (if (and (= reply-count 1) (not always-as-vec?))
+      (if (and (= reply-count 1) (not as-bulk?))
         (get-reply! in true (nth parsers 0))
         (utils/mapv* #(get-reply! in false %) parsers)))))


Update datomic utils, return corrtectly formatted json

--- src/clj/traveler/api/users.clj
+++ src/clj/traveler/api/users.clj
@@ -1,44 +0,0 @@
-(ns traveler.api.users
-  (:require [traveler.api.api :refer [gen-response]]
-            [traveler.datomic.utils :refer [user->db]]
-            [traveler.utils :refer [get-param]]
-            [clojure.walk :refer [keywordize-keys]]
-            [valip.core :refer [validate]]
-            [valip.predicates :refer [digits? email-address? present?]]))
-
-;; Required Fields
-;;  id-sk (unique)
-;;  username (unique)
-;;  password
-;;  privilege
-;;  lastname
-;;  firstname
-;;  email
-;;  policies_assent_date
-;;
-;; Optional Fields (default to false)
-;;  istest
-;;  can-masquerade
-(defn validate-add-user
-  "Validate user map"
-  [user]
-  (validate user
-    [:id-sk present? "must be present"]
-    [:id-sk digits? "must consist of digits"]
-    [:username present? "must be present"]
-    [:password present? "must be present"]
-    [:privilege present? "must be present"]
-    [:lastname present? "must be present"]
-    [:firstname present? "must be present"]
-    [:email present? "must be present"]
-    [:policies-assent-date present? "must be present"]))
-
-(defn add-user
-  "Public facing add-user endpoint"
-  [ctx]
-  (let [user (keywordize-keys (get-in ctx [:request :params]))]
-    (if (nil? (validate-add-user user))
-      (do
-        (user->db user)
-        (gen-response))
-      (gen-response (validate-add-user user)))))


Made encryption for session data mandatory for cookie sessions

--- src/compojure/http/session.clj
+++ src/compojure/http/session.clj
@@ -82,11 +82,11 @@

 ;; Cookie sessions
 (def *default-encryption*
-     {:algorithm      "AES/CBC/PKCS5Padding"
-      :secret-key     (gen-key "AES" 128)
-      :cbc-params     (gen-iv-param 16)
-      :hash-key       (secure-random-bytes 32)
-      :hash-algorithm "HmacSHA256"})
+  {:algorithm      "AES/CBC/PKCS5Padding"
+   :secret-key     (gen-key "AES" 128)
+   :cbc-params     (gen-iv-param 16)
+   :hash-key       (secure-random-bytes 32)
+   :hash-algorithm "HmacSHA256"})

 (defn session-hmac
   "Calculate a HMAC for a marshalled session.  Uses the :hash-key and
@@ -99,6 +99,7 @@
     (hmac hash-key hash-algorithm cookie-data)))

 (defn session-crypt
+  "Encrypt or decrypt session data."
   [f session]
   (let [encryption-opts (merge *default-encryption*
                                (:encryption *session-repo*))
@@ -111,10 +112,7 @@

 (defmethod session-cookie :cookie
   [new? session]
-  (let [cookie-data
-        (if (contains? *session-repo* :encryption)
-          (session-crypt encrypt (marshal session))
-          (marshal session))]
+  (let [cookie-data (session-crypt encrypt (marshal session))]
     (if (> (count cookie-data) 4000)
       (throwf "Session data exceeds 4K")
       (str cookie-data "--" (session-hmac cookie-data)))))
@@ -123,10 +121,7 @@
   [data]
   (let [[session mac] (.split data "--")]
     (if (= mac (session-hmac session))
-      (if (contains? *session-repo* :encryption)
-        (unmarshal (session-crypt decrypt session))
-        (unmarshal session)))))
-
+      (unmarshal (session-crypt decrypt session)))))

 ; Do nothing for write or destroy
 (defmethod write-session :cookie [session])


Add bezier-tangent to curve/bezier.cljs example.

--- src/quil_cljs_examples/curves/bezier.cljs
+++ src/quil_cljs_examples/curves/bezier.cljs
@@ -11,9 +11,17 @@

 	(q/fill 255)
 	(doseq [i (range 10)]
-		(q/ellipse (q/bezier-point 85 10 90 15 (/ i 10.0))
-				   (q/bezier-point 20 10 90 80 (/ i 10.0))
-				   5 5)))
+		(let [x  (q/bezier-point 85 10 90 15 (/ i 10.0))
+			  y  (q/bezier-point 20 10 90 80 (/ i 10.0))
+			  tx (q/bezier-tangent 85 19 90 15 (/ i 10.0))
+			  ty (q/bezier-tangent 20 10 90 80 (/ i 10.0))
+			  a  (+ q/PI (q/atan2 ty tx))
+			  x2 (+ x (* 30 (q/cos a)))
+			  y2 (+ y (* 30 (q/sin a)))]
+			  (q/stroke 255 102 0)
+			  (q/line x y x2 y2)
+			  (q/stroke 0)
+			  (q/ellipse x y 5 5))))

 (defsketch bezier


fixed issue with matches

fixed issue with matches

--- src/cljs_bjj_tournament/handlers.cljs
+++ src/cljs_bjj_tournament/handlers.cljs
@@ -59,12 +59,15 @@

 (register-handler
   :add-competitors
-  (path [:competitors])
-  (fn [old_competitors [_ competitors]]
-    (let [competitors (map make-competitor-from-map competitors)]
-      (into {}
-            (for [c competitors]
-              [(:guid c) c])))))
+  (fn [db [_ competitors]]
+    (let [competitors (map make-competitor-from-map competitors)
+          competitors-map (into {}
+                                (for [c competitors]
+                                  [(:guid c) c]))]
+      ;add the competitors and delete the matches
+      (-> db
+          (assoc :competitors competitors-map)
+          (assoc :matches [])))))

 (register-handler
   :delete-competitor


Add bezier-point to curve/bezier.cljs example.

--- src/quil_cljs_examples/curves/bezier.cljs
+++ src/quil_cljs_examples/curves/bezier.cljs
@@ -7,7 +7,13 @@
 	(q/background 255)
 	(q/no-fill)
 	(q/stroke 0 0 0)
-	(q/bezier 85 20 10 10 90 90 15 80))
+	(q/bezier 85 20 10 10 90 90 15 80)
+
+	(q/fill 255)
+	(doseq [i (range 10)]
+		(q/ellipse (q/bezier-point 85 10 90 15 (/ i 10.0))
+				   (q/bezier-point 20 10 90 80 (/ i 10.0))
+				   5 5)))

 (defsketch bezier


Made changes for bootstrap app to fix out of memory error.

--- src/cmr/bootstrap/data/bulk_index.clj
+++ src/cmr/bootstrap/data/bulk_index.clj
@@ -33,17 +33,21 @@
         params {:concept-type :granule
                 :provider-id provider-id
                 :parent-collection-id collection-id}
-        concepts (db/find-concepts-in-batches db params (:db-batch-size system))]
-    (index/bulk-index {:system (:indexer system)} concepts (:bulk-index-batch-size system))
-    (info "Indexed" (count concepts) "granule(s) for provider" provider-id " collection" collection-id)))
+        concept-batches (db/find-concepts-in-batches db params (:db-batch-size system))
+        num-granules (index/bulk-index {:system (:indexer system)} concept-batches)]
+        (info "Indexed" num-granules "granule(s) for provider" provider-id "collection" collection-id)))

 (defn- index-granules-for-provider
   "Index the granule data for every collection for a given provider."
   [system provider-id]
   (info "Indexing granule data for provider" provider-id)
-  (dorun (pmap
+  #_(dorun (pmap
            (partial index-granules-for-collection system provider-id)
            (get-provider-collection-list system provider-id)))
+
+  (doseq [collection-id (get-provider-collection-list system provider-id)]
+    (index-granules-for-collection system provider-id collection-id))
+
   (info "Indexing of granule data for provider" provider-id "completed."))

 (defn- index-provider-collections
@@ -52,8 +56,8 @@
   (let [db (get-in system [:metadata-db :db])
         params {:concept-type :collection
                 :provider-id provider-id}
-        concepts (db/find-concepts db params)]
-    (index/bulk-index {:system (:indexer system)} concepts (:bulk-index-batch-size system))))
+        concept-batches (db/find-concepts-in-batches db params (:db-batch-size system))]
+    (index/bulk-index {:system (:indexer system)} concept-batches)))

 (defn- unindex-provider


also show success icon after submission; remove submission button after submission

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_config_editor.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_config_editor.cljs
@@ -167,9 +167,11 @@
        [:div {:style {:padding "22px 48px 40px" :backgroundColor (:background-gray style/colors)}}
         (if (:launch-result @state)
           [:div {}
-           (when (:launch-exception @state)
+           (if (:launch-exception @state)
              (icons/font-icon {:style {:fontSize "200%" :color (:exception-red style/colors)}}
-               :status-warning-triangle))
+               :status-warning-triangle)
+             (icons/font-icon {:style {:fontSize "200%" :color (:success-green style/colors)}}
+                            :status-done))
            (:launch-result @state)]
           [:div {}
            (style/create-form-label "Select Entity Type")
@@ -205,6 +207,8 @@
                           (:entities @state))}])])
            (style/create-form-label "Define Expression")
            (style/create-text-field {:ref "expressionname" :defaultValue "" :placeholder "leave blank for default"})])]
+
+       (when-not (:launch-result @state)
        [:div {:style {:fontSize "106%" :lineHeight 1 :textAlign "center"}}
         [:div {:style {:padding "0.7em 0" :cursor "pointer"
                        :backgroundColor (:button-blue style/colors)
@@ -252,7 +256,7 @@
                                                                                "entityName" "sample_01"},
                                                                         "submitter" "davidan@broadinstitute.org"}])
                                                       :status 200 :delay-ms (rand-int 1000)}})
-                                 ))} "Launch"]]
+                                 ))} "Launch"]])
        ])}])

 (defn- render-main-display [state refs config editing?]


Tail recursion

Tail recursion

--- src/euler/helper.clj
+++ src/euler/helper.clj
@@ -154,39 +154,38 @@
   "**get-primes :: Int -> [Int]** Get the prime divisors of n."
   ;; entry point - start with the list of primes and [] as accumulator
   ([n] (get-primes n primes []))
-  ([n ps acc]
-   (let [[f & r] ps]
-     (cond
-       ;; no more factors - stop iteration
-       (< n f) acc
-       ;; if factor - add to set of prime factors
-       (factor? n f) (get-primes (/ n f) ps (conj acc f))
-       ;; no match - next iteration
-       :else (get-primes n r acc)))))
+  ([n [car & cdr :as ps] acc]
+   (cond
+    ;; no more factors - stop iteration
+     (< n car) acc
+    ;; if factor - add to set of prime factors
+     (factor? n car) (recur (/ n car) ps (conj acc car))
+    ;; no match - next iteration
+     :else (recur n cdr acc))))

 (defn max-prime
   "**max-prime :: Int, [Int] -> Int**
   Given a number n and a list of prime numbers ps,
   returns the largest prime factor of n."
-  [n ps]
-  (let [div (first ps)] ;; local variable - head of prime list
-    (cond
-      ;; termination - found max prime
-      (= n div) div
-      (factor? n div) (max-prime (/ n div) ps)
-      ;; list eater
-      :else (max-prime n (rest ps)))))
+  [n [car & cdr :as ps]]
+  (cond
+   ; termination - found max prime
+    (= n car) car
+   ; shrinking
+    (factor? n car) (recur (/ n car) ps)
+   ; list eater
+    :else (recur n cdr)))

 (defn prime-factors
   "** prime-factors :: Int -> [Int]**
   Given a number, returns the list of prime factors of n.
   Example: (prime-factors 12) => (2 2 3)"
   ([n] (prime-factors n [] primes))
-  ([number factors ps]         ;; TODO use destructuring
+  ([number factors ps]
    (cond
      (= 1 number) factors
      (factor? number (first ps)) (prime-factors (/ number (first ps))
-                                                (conj factors (first ps)) ps)
+                               (conj factors (first ps)) ps)
      :else (prime-factors number factors (rest ps)))))

 (defn count-divisors


CMR-2054: Moved comments around.

CMR-2054: Moved comments around.

--- system-int-test/test/cmr/system_int_test/search/tagging/collection_tag_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/tagging/collection_tag_search_test.clj
@@ -265,7 +265,10 @@
                                                                       :provider "PROV1"}))))))

 (defn- add-tags-to-collections
-  "Returns the collections with the tags associated based on the given dataset-id-tags mapping"
+  "Returns the collections with the tags associated based on the given dataset-id-tags mapping.
+  dataset-id-tags is a map of collection dataset-id to tags that should be associated with the
+  collection. The tags are in tuples of tag namespace and value which is the same as tags in
+  the JSON response. It is used to construct the tags field in the expected JSON."
   [colls dataset-id-tags]
   (map (fn [c]
          (if-let [tags (dataset-id-tags (:dataset-id c))]
@@ -308,9 +311,6 @@
     (index/wait-until-indexed)

     (testing "include-tags in json format has proper tags added to json response."
-      ;; dataset-id-tags is a map of collection dataset-id to tags that should be associated
-      ;; with the collection. The tags are in tuples of tag namespace and value which is the same
-      ;; as tags in the JSON response. It is used to construct the tags field in the expected JSON.
       (are2 [include-tags dataset-id-tags]
             (let [feed-id (->> (-> include-tags
                                    (str/replace "?" "%3F")


Rename mread to multi-read.

Rename mread to multi-read.

--- src/fleetdb/core.clj
+++ src/fleetdb/core.clj
@@ -182,7 +182,7 @@

 (declare exec)

-(defn- q-mread [db queries]
+(defn- q-multi-read [db queries]
   (vec
     (map (fn [query] (exec db query))
          queries)))
@@ -196,7 +196,7 @@
    :create-index q-create-index
    :drop-index   q-drop-index
    :list-indexes q-list-indexes
-   :mread        q-mread})
+   :multi-read   q-multi-read})

 (defn exec [db [query-type opts]]
   (if-let [queryfn (query-fns query-type)]


Tidy up, add more fields to api request, remove add-type when api call was successful

--- src/discuss/communication.cljs
+++ src/discuss/communication.cljs
@@ -5,7 +5,6 @@
             [cognitect.transit :as transit]
             [discuss.config :as config]
             [discuss.debug :as debug]
-            [discuss.history :as history]
             [discuss.lib :as lib]))

 ;; Auxiliary functions
@@ -48,6 +47,7 @@
       (.log js/console error)
       (do
         (lib/hide-add-form)
+        (lib/update-state-item! :layout :add-type (fn [_] nil))
         (ajax-get url)))))

 (defn init!
@@ -59,13 +59,24 @@

 ;; Discussion-related functions
+(defn get-conclusion-id
+  "Returns statement id to which the newly added statement is referred to.
+   Currently this is stored in the data_statement_uid of the first bubble."
+  []
+  (let [bubble (first (lib/get-bubbles))]
+    (:data_statement_uid bubble)))
+
 (defn post-statement [statement reference add-type]
-  (let [id   (get-in @lib/app-state [:issues :uid])
-        slug (get-in @lib/app-state [:issues :slug])
-        url  (str (:base config/api) (get-in config/api [:add add-type]))]
+  (let [id            (get-in @lib/app-state [:issues :uid])
+        slug          (get-in @lib/app-state [:issues :slug])
+        conclusion-id (get-conclusion-id)          ; Relevant for add-start-premise
+        supportive?   (get-in @lib/app-state [:discussion :is_supportive])
+        url           (str (:base config/api) (get-in config/api [:add add-type]))]
     (POST (make-url url)
           {:body            (lib/clj->json {:statement statement
                                             :reference reference
+                                            :conclusion_id conclusion-id
+                                            :supportive supportive?
                                             :issue_id id
                                             :slug slug})
            :handler         success-handler
@@ -74,8 +85,7 @@
            :response-format :json
            :headers         (merge {"Content-Type" "application/json"}
                                    (token-header))
-           :keywords?       true})
-    (lib/update-state-item! :layout :add-type (fn [_] nil))))
+           :keywords?       true})))

 (defn dispatch-add-action
   "Check which action needs to be performed based on the type previously stored in the app-state."
@@ -83,8 +93,8 @@
   (let [action (get-in @lib/app-state [:layout :add-type])]
     (cond
       (= action :add-start-statement) (post-statement statement reference :add-start-statement)
-      (= action :add-start-premise)   (post-statement statement reference :add-start-premise)
-      (= action :add-justify-premise) (post-statement statement reference :add-justify-premise)
+      (= action :add-start-premise)   (post-statement [statement] reference :add-start-premise)
+      (= action :add-justify-premise) (post-statement [statement] reference :add-justify-premise)
       :else (println "Action not found:" action))))

 (defn prepare-add


grabing service file

grabing service file

--- src/gce/provider.clj
+++ src/gce/provider.clj
@@ -8,7 +8,7 @@
    [celestial.core :refer (Vm)]
    [taoensso.timbre :as timbre]
    [celestial.persistency.systems :as s]
-   [celestial.model :refer (translate vconstruct)])
+   [celestial.model :refer (translate vconstruct hypervisor)])
   (:import
     (com.google.api.services.compute.model Instance)
     (com.google.api.client.googleapis.javanet GoogleNetHttpTransport)
@@ -86,17 +86,18 @@
   "Construcuting machine transformations"
    {:image (fn [os] (:image ((os->template :gce) os)))})

-(defmethod translate :gce [{:keys [machine gce] :as spec} system-id]
+(defmethod translate :gce [{:keys [machine gce system-id] :as spec}]
     "Convert the general model into a gce instance"
     (-> (merge machine gce {:system-id system-id})
       (mappings {:os :image})
       (transform (machine-ts machine))
-      ((juxt into-gce (select-keys [:system-id :project-id])))
+      ((juxt into-gce (partial select-keys [:system-id :project-id])))
     ))

 (defn validate [spec &]
   (validate-provider spec) spec)

-(defmethod vconstruct :gce [{:keys [system-id] :as spec}]
-  (apply ->GCEInstance [(build-compute "") (validate (translate spec)) system-id]))
+(defmethod vconstruct :gce [spec]
+  (let [compute (build-compute (hypervisor :gce :service-file))]
+   (apply (partial ->GCEInstance compute) (validate (translate spec)))))


New REST API endpoint: /job-results-html

--- src/emender_service/server.clj
+++ src/emender_service/server.clj
@@ -143,17 +143,18 @@
 (defn api-call-handler
     [request uri method]
     (condp = [method (get-api-command request uri)]
-        [:get  "/info"]         (rest-api/info-handler request (get-hostname))
-        [:get  "/job-list"]     (rest-api/get-job-list-handler request)
-        [:get  "/jobs"]         (rest-api/get-job-list-handler request)
-        [:get  "/book-list"]    (rest-api/get-book-list-handler request)
-        [:get  "/books"]        (rest-api/get-book-list-handler request)
-        [:get  "/job-info"]     (rest-api/get-job-info-handler request)
-        [:post "/job-started"]  (rest-api/job-started-handler  request)
-        [:post "/job-finished"] (rest-api/job-finished-handler request)
-        [:post "/job-results"]  (rest-api/job-results-handler  request)
-        [:post "/run-test"]     (rest-api/run-test-handler     request)
-                                (rest-api/unknown-call-handler uri method)))
+        [:get  "/info"]             (rest-api/info-handler request (get-hostname))
+        [:get  "/job-list"]         (rest-api/get-job-list-handler request)
+        [:get  "/jobs"]             (rest-api/get-job-list-handler request)
+        [:get  "/book-list"]        (rest-api/get-book-list-handler request)
+        [:get  "/books"]            (rest-api/get-book-list-handler request)
+        [:get  "/job-info"]         (rest-api/get-job-info-handler request)
+        [:post "/job-started"]      (rest-api/job-started-handler  request)
+        [:post "/job-finished"]     (rest-api/job-finished-handler request)
+        [:post "/job-results"]      (rest-api/job-results-handler  request)
+        [:post "/job-results-html"] (rest-api/job-results-html-handler request)
+        [:post "/run-test"]         (rest-api/run-test-handler     request)
+                                    (rest-api/unknown-call-handler uri method)))

 (defn non-api-call-handler
     [request uri]


Don't rely on select internally.

Don't rely on select internally.

--- src/fleetdb/core.clj
+++ src/fleetdb/core.clj
@@ -210,7 +210,7 @@
         o-plans (map #(order-plan % order) w-plans)]
     (least-by quantify-cost o-plans)))

-(defn- select-plan [db where order offset limit only]
+(defn- find-plan [db where order offset limit only]
   (-> (wo-plan db where order)
     (offset-plan offset)
     (limit-plan limit)
@@ -240,12 +240,15 @@
   (let [only (:only plan)]
     (map #(select-keys % only) (exec-source db plan))))

-(defn- q-select [db {:keys [where order offset limit only]}]
+(defn- find-records [db {:keys [where order offset limit only]}]
   (exec db
-    (select-plan db where order offset limit only)))
+    (find-plan db where order offset limit only)))
+
+(defn- q-select [db opts]
+  (find-records db opts))

 (defn- q-count [db opts]
-  (count (q-select db opts)))
+  (count (find-records db opts)))

 (defn- db-apply [db records apply-fn]
   (let [{old-rmap :rmap old-imap :imap} db
@@ -261,14 +264,14 @@

 (defn- q-update [db {:keys [with] :as opts}]
   (assert with)
-    (db-apply db (q-select db opts)
+    (db-apply db (find-records db opts)
       (fn [[int-rmap int-imap] old-record]
         (let [new-record (merge-compact old-record with)]
           [(rmap-update int-rmap old-record new-record)
            (imap-update int-imap old-record new-record)]))))

 (defn- q-delete [db opts]
-  (db-apply db (q-select db opts)
+  (db-apply db (find-records db opts)
     (fn [[int-rmap int-imap] old-record]
       [(rmap-delete int-rmap old-record)
        (imap-delete int-imap old-record)])))
@@ -276,7 +279,7 @@
 (defn- q-explain [db {[query-type opts] :query :as explain-opts}]
   (assert (= query-type :select))
   (let [{:keys [where order offset limit only]} opts]
-    (select-plan db where order offset limit only)))
+    (find-plan db where order offset limit only)))

 (defn- q-create-index [db {:keys [on where]}]
   (assert (not (on (:imap db))))


Function keep-word? working great

Function keep-word? working great

--- src/hangman/core.clj
+++ src/hangman/core.clj
@@ -33,7 +33,7 @@
   vector the length of the target word consisting of either letters (for correctly guessed
   letters) or nil (for incorrect guesses)."
   [tgt-word guessed-chars]
-  (vec (for [ letter tgt-word ] (get guessed-chars letter \- ))) )
+  (str/join (for [ letter tgt-word ] (get guessed-chars letter \- ))) )

 (defn complement-char-class
   "Generate the regex for the complement of a set of characters."
@@ -62,7 +62,8 @@
             (not-any? #(= \- %) word) ]
     :post [] }
   (let [ patt-str (clue-to-regex clue guessed-chars) ]
-    (re-find (re-pattern patt-str) word ) ))
+    (re-find (re-pattern patt-str) word )
+   ))

 (defn word-has-letter?
   "Returns true if a letter appears in a word, else nil."
@@ -134,19 +135,19 @@
     (assert (not (re-find (re-pattern patt-str) "xxxd" )))

     ; Test if keep word
-    (assert      (keep-word? "abcd" "abcd"             #{}            )  )
-    (assert      (keep-word? "abcd" "a---"  #{}            )  )
-    (assert      (keep-word? "abcd" "ab--"  #{}            )  )
-    (assert      (keep-word? "abcd" "----"  #{}            )  )
-    (assert      (keep-word? "abcd" "ab--"   guessed-chars )  )
-    (assert (not (keep-word? "abcd" "a---"   guessed-chars ) ))
+    (assert      (keep-word? "abcd" "----"  #{}      )  )
+    (assert      (keep-word? "abcd" "abcd"  #{}      )  )
+    (assert      (keep-word? "abcd" "a---"  #{}      )  )
+    (assert      (keep-word? "abcd" "ab--"  #{}      )  )
+    (assert      (keep-word? "abcd" "-b--"  #{\b \s} )  )
+    (assert (not (keep-word? "abcd" "a---"  #{\b \s} ) ))

   )
   (let [tst-words       [ "abcd" "xbcd" "xxcd" "xxxd" ]
         words-map       (group-by count tst-words)
         word-list       (words-map 4)
         clue            "-b--"
-        keep-words      (filter #(keep-word? % clue #{} ) word-list)
+        keep-words      (filter #(keep-word? % clue #{\b} ) word-list)
   ]
     (assert (= words-map   {4 ["abcd" "xbcd" "xxcd" "xxxd"]} ))
     (assert (= word-list      ["abcd" "xbcd" "xxcd" "xxxd"]  ))
@@ -171,7 +172,7 @@
             ]
         (println )
         (let [
-          keep-words      (filter #(keep-word? % clue #{} ) word-list) ]
+          keep-words      (filter #(keep-word? % clue guessed-chars ) word-list) ]
             (print "clue: " clue "  ")
             (show-info "keep-words" keep-words)
             (if (= 1 (count keep-words))


Multiline textfield

Multiline textfield

--- src/flatgui/widgets/componentbase.clj
+++ src/flatgui/widgets/componentbase.clj
@@ -366,7 +366,12 @@
         this-container (if (or (not changed-only) (get-in aux (fgc/conjv k :changed-properties)))
                          (let [ look-fn (:look container)]
                            (if look-fn
-                             (assoc container :look-vec (look-fn container dirty-rect))
+                             (try
+                               (assoc container :look-vec (look-fn container dirty-rect))
+                               (catch Exception ex
+                                 (do
+                                   (fg/log-error "Error painting " target-id-path ":" (.getMessage ex))
+                                   (.printStackTrace ex))))
                              container))
                          container)]
     (assoc


Fixed typo (#318)

Fixed typo (#318)

--- server/src/spacon/components/kafka/core.clj
+++ server/src/spacon/components/kafka/core.clj
@@ -206,7 +206,6 @@
     (log/debug "Stopping Kafka Component")
     (async/close! (:publish-channel this))
     (async/close! (:subscribe-channel this))
-    ((:publish-channel))
     this)
   (publish [this msg]
     (publish this msg))


Fix using the :protocol' keyword to change the encoding protocol

--- src/mavlink/core.clj
+++ src/mavlink/core.clj
@@ -294,7 +294,7 @@
                       new-seq-id (if msg-seq-id
                                    (mod msg-seq-id 256)
                                    (mod (inc @sequence-id) 256))]
-                  (if-let [packet (case (or (:mavlink'protocol message)
+                  (if-let [packet (case (or (:protocol' message)
                                             @protocol)
                                       :mavlink1
                                         (if (>= (:msg-id message-info) 256)


exp: use system agent

exp: use system agent

--- src/leiningen/remote_test_refresh.clj
+++ src/leiningen/remote_test_refresh.clj
@@ -40,7 +40,7 @@
                  "git reset --hard;"
                  (str "git apply --whitespace=warn " remote-patch-file-name ";")
                  "rm -f " remote-patch-file-name ";")
-        result-apply-patch (ssh/ssh session {:cmd cmd})]
+        result-apply-patch (ssh/ssh session {:cmd cmd :agent-forwarding true})]
     (if (= 0 (:exit result-apply-patch))
       {:step :apply-patch :status :success}
       {:step :apply-patch :status :failed :error (:err result-apply-patch)})))
@@ -123,7 +123,7 @@
      (recur console session dirs parameters new-tracker))))

 (defn run-command-remotely [{run-command :command repo :repo path :remote-path} session]
-  (let [output (->> {:cmd (str "cd " path repo ";" run-command ";") :out :stream :pty true}
+  (let [output (->> {:cmd (str "cd " path repo ";" run-command ";") :out :stream :pty true :agent-forwarding true}
                     (ssh/ssh session)
                     (:out-stream))]
     (with-open [rdr (io/reader output)]
@@ -162,7 +162,6 @@

 (defn session-option [parameters]
   {:username                 (:user parameters)
-   :password                 (:password parameters)
    :strict-host-key-checking :no})

 (defn remote-test-refresh [project & _]
@@ -170,7 +169,7 @@
   (try
     (let [asset-paths (find-asset-paths project)
           parameters (start-parameters project)
-          agent (ssh/ssh-agent {:use-system-ssh-agent false})
+          agent (ssh/ssh-agent {})
           session (ssh/session agent (:host parameters) (session-option parameters))]
       (m/info "* Starting with the parameters:" (assoc parameters :password "***") "\n")
       (ssh/connect session)


Set state when archiving

Set state when archiving

--- src/mdr2/archive.clj
+++ src/mdr2/archive.clj
@@ -147,7 +147,8 @@
 (defmethod archive "book"
   [production]
   (archive-sektion production :master)
-  (archive-sektion production :dist-master))
+  (archive-sektion production :dist-master)
+  (prod/set-state! production "archived"))

 (defmethod archive "periodical"
   [production]
@@ -168,7 +169,8 @@
         (doseq [volume (range 1 (inc (:volumes production)))]
           (let [iso-archive-name (str dam-number (when multi-volume? (str "_" volume)) ".iso")
                 iso-archive-path (.getPath (file archive-path "produkt" iso-archive-name))]
-            (fs/copy+ (path/iso-name production volume) iso-archive-path)))))))
+            (fs/copy+ (path/iso-name production volume) iso-archive-path)))
+        (prod/set-state! production "archived")))))

 (defmethod archive "other"
   [production]
@@ -179,4 +181,5 @@
     (doseq [volume (range 1 (inc (:volumes production)))]
       (let [iso-archive-name (str product_number (when multi-volume? (str "_" volume)) ".iso")
             iso-archive-path (.getPath (file other-spool-dir iso-archive-name))]
-        (fs/copy (path/iso-name production volume) iso-archive-path)))))
+        (fs/copy (path/iso-name production volume) iso-archive-path)))
+    (prod/set-state! production "archived")))


Insert a date when a date is required

Insert a date when a date is required

--- src/mdr2/archive.clj
+++ src/mdr2/archive.clj
@@ -35,6 +35,7 @@
             [clojure.tools.logging :as log]
             [environ.core :refer [env]]
             [clj-time.core :as t]
+            [clj-time.coerce :refer [to-date]]
             [me.raynes.fs :as fs]
             [mdr2.production :as prod]
             [mdr2.production.path :as path]
@@ -100,7 +101,7 @@
   (let [new-job
         {:verzeichnis (container-id production sektion)
          :sektion (case sektion :master "master" :dist-master "cdimage")
-         :datum (t/now)}
+         :datum (to-date (t/now))}
         job (merge default-job new-job)]
     (jdbc/insert! db :container job)))


part 2

part 2

--- 2018/day-3/src/day_3/core.clj
+++ 2018/day-3/src/day_3/core.clj
@@ -52,21 +52,39 @@
       (filter #(> % 1) $)
       (count $))))

-(defn similar?
-  [s1 s2]
-  (let [->v #(map-indexed vector %)
-        v1 (->v s1)
-        v2 (->v s2)
-        [a b _] (clojure.data/diff v1 v2)
-        r1 (->> (flatten a) (remove nil?))
-        r2 (->> (flatten b) (remove nil?))]
-    #_(println (count r1) (count r2))
-    (= (count r1) (count r2) 1)))
+(defn conj-sqr
+  [i [id [x y] [w h]]]
+  (let [positions (for [dx (range 0 w)
+                        dy (range 0 h)]
+                    [(+ x dx) (+ y dy)])]
+    (reduce
+      (fn [[ids s] pos]
+        (let [s' (update-in s pos conj id)
+              ins (get-in s' pos)
+              ids' (if (> (count ins) 1)
+                     (apply disj ids ins)
+                     ids)]
+            [ids' s']))
+      i
+      positions)))

 (defn part-2
   []
-  (for [w my-i']
-    (filter #(similar? w %) my-i')))
+  (let [l (range 0 1000)
+        ids (set (map first claims))
+        sqr (->>
+              (for [_ l]
+                (->>
+                  (for [_ l]
+                    #{})
+                  vec))
+              vec)]
+    (as-> sqr $
+      (reduce
+        conj-sqr
+        [ids $]
+        claims)
+      (first $))))

 (defn -main
   "I don't do a whole lot ... yet."


lose debug crud

lose debug crud

--- src/merlion/core.clj
+++ src/merlion/core.clj
@@ -30,15 +30,12 @@
   (let [[address port] (str/split a #":")]
     {:address address :port (Integer/parseInt port)}))

-
 (defn make-backend-channel [backend]
   (let [ch (chan)
         backend-addr (parse-address (:listen-address backend))]
     (go
       (loop []
         (when-let [[req out-ch] (<! ch)]
-          (println [:got-backend-req
-                    backend-addr])
           (>! out-ch
               (http/request (assoc req
                                    :raw-stream? true
@@ -46,8 +43,7 @@
                                    :server-name (:address backend-addr)
                                    :server-port (:port  backend-addr))))
           (close! out-ch)
-          (println "done")
-          (recur )))
+          (recur)))
       (println [:shutdown backend]))
     ch))

@@ -84,9 +80,6 @@
                                  (make-backend-channel v)))))
                {}
                (apply dissoc new-backends deleted))))
-
-(defn print-state [l b]
-  (pprint {:listeners l :backends b}))

 (defn s->millepoch-time [s]
   (.getTimeInMillis (clojure.instant/read-instant-calendar s)))


Even the landing page should be authenticated

--- src/mdr2/handler.clj
+++ src/mdr2/handler.clj
@@ -15,7 +15,7 @@

 (defroutes app-routes
   "Main routes for the application"
-  (GET "/" request (views/home request))
+  (GET "/" request (friend/authenticated (views/home request)))

   ;; bulk import of productions
   (GET "/production/upload" request


Work around a ring bug that only occurs in-container

Thanks to tcrawley

--- src/mdr2/handler.clj
+++ src/mdr2/handler.clj
@@ -67,5 +67,5 @@
        {:credential-fn (partial creds/bcrypt-credential-fn db/get-user)
         :workflows [(workflows/interactive-form)]
         :unauthorized-handler views/unauthorized})
-      (wrap-defaults site-defaults)
+      (wrap-defaults (assoc-in site-defaults [:static :resources] false))
       wrap-base-url))


some minor cosmetic tweaks;

some minor cosmetic tweaks;

--- src/mustached_hipster/core.clj
+++ src/mustached_hipster/core.clj
@@ -1,5 +1,5 @@
 (ns mustached-hipster.core
-   (:require [clojure.string  :as s    :only [replace split-lines]])
+   (:require [clojure.string  :only [replace split-lines]])
    (:require [clj-http.client :as http :only [get]])
    (:gen-class))

@@ -8,17 +8,17 @@

    (let [
       before (System/nanoTime)
-      after #(* (- (System/nanoTime) before) 1e-9)
+      elapsed #(* (- (System/nanoTime) before) 1e-9)
       grab-and-process (comp
-         (partial map #(s/replace % #"\?.*" "\n"))
+         (partial map #(clojure.string/replace % #"\?.*" "\n"))
          (partial filter #(not= \# (first %)))
-         s/split-lines
+         clojure.string/split-lines
          :body
          http/get)]

       (let
          [playlist (grab-and-process m3u8)]
-         (println "the request took" (after) "seconds")
+         (println "fetching the playlist request took" (elapsed) "seconds")
          playlist)))

 (defn -main


Fix docstring.

Fix docstring.

--- src/oc/storage/util/ziggeo.clj
+++ src/oc/storage/util/ziggeo.clj
@@ -23,14 +23,14 @@

 (defn video
   "
-    https://ziggeo.com/docs/api/resources/video The data structure returned
-    from the api call.
+  https://ziggeo.com/docs/api/resources/video The data structure returned
+  from the api call.

-    Info we are interested in ':state' if this is greater than 4 , then the
-    video is processed.
+  Info we are interested in ':state' if this is greater than 4 , then the
+  video is processed.

-    ':original_stream { :audio_transcription { :text "" }}' Will contain the
-    transcription data for the video.
+  `:original_stream { :audio_transcription { :text '' }}` Will contain the
+  transcription data for the video.
   "
   [token cb]
   (http/get (str ziggeo-api-url "/videos/" token) (auth-options auth)


enable to display todo list

enable to display todo list

--- src/om_next_todolist/core.cljs
+++ src/om_next_todolist/core.cljs
@@ -5,4 +5,31 @@

 (enable-console-print!)

-(println "Hello world!")
+(def app-state
+  (atom {:todos [{:id 1 :title "豚肉を買ってくる"}
+                 {:id 2 :title "たまねぎを買ってくる"}
+                 {:id 3 :title "にんじんを買ってくる"}
+                 {:id 4 :title "じゃがいもを買ってくる"}
+                 {:id 5 :title "カレーを作る"}]}))
+
+(defui TodoItem
+  Object
+  (render [this]
+    (let [props (om/props this)
+          title (:title props)]
+      (dom/li nil title))))
+
+(def todo-item (om/factory TodoItem))
+
+(defui TodoList
+  Object
+  (render [this]
+    (let [props (om/props this)
+          todos (:todos props)]
+      (apply dom/ul nil
+        (map todo-item todos)))))
+
+(def reconciler
+  (om/reconciler {:state app-state}))
+
+(om/add-root! reconciler TodoList (gdom/getElement "app"))


tempory fix

tempory fix

--- src/neuseg/train.clj
+++ src/neuseg/train.clj
@@ -31,7 +31,7 @@

 (defn gen-case [text]
   (map format (zip (map ndot (NeighborSlider. 4 (zero-vector 16) (iter-seq (NGram/unigram text))))
-                   (map ndot (NeighborSlider. 4 (zero-vector 32) (iter-seq (NGram/bigram text))))
-                   (map ndot (NeighborSlider. 4 (zero-vector 48) (iter-seq (NGram/trigram text))))
-                   (map ndot (NeighborSlider. 4 (zero-vector 48) (iter-seq (NGram/quadgram text))))
+                   (map ndot (NeighborSlider. 4 (zero-vector 16) (iter-seq (NGram/bigram text))))
+                   (map ndot (NeighborSlider. 4 (zero-vector 16) (iter-seq (NGram/trigram text))))
+                   (map ndot (NeighborSlider. 4 (zero-vector 16) (iter-seq (NGram/quadgram text))))
                    (partition 2 (tagging text)))))


use clojure.java.io

use clojure.java.io

--- src/neuseg/train.clj
+++ src/neuseg/train.clj
@@ -1,5 +1,6 @@
 (ns neuseg.train
   (:use [clj-tuple]
+        [clojure.java.io]
         [clojure.core.matrix :only [dot zero-vector]]
         [neuseg.db]
         [com.guokr.nlp.seg])


Predefine compression opts

Predefine compression opts

--- src/onyx/compression/nippy.clj
+++ src/onyx/compression/nippy.clj
@@ -14,11 +14,17 @@
 (defn window-log-compress [x]
   (nippy/freeze x {}))

+(def window-log-decompress-opts {:v1-compatibility? false})
+
 (defn window-log-decompress [x]
-  (nippy/thaw x {:v1-compatibility? false}))
+  (nippy/thaw x window-log-decompress-opts))
+
+(def localdb-compress-opts {:skip-header? true :compressor nil :encryptor nil :password nil})

 (defn localdb-compress [x]
-  (nippy/freeze x {:skip-header? true :compressor nil :encryptor nil :password nil}))
+  (nippy/freeze x localdb-compress-opts))
+
+(def local-db-decompress-opts {:v1-compatibility? false :compressor nil :encryptor nil})

 (defn localdb-decompress [x]
-  (nippy/thaw x {:v1-compatibility? false :compressor nil :encryptor nil}))
+  (nippy/thaw x local-db-decompress-opts))


Implement max pending.

Implement max pending.

--- src/onyx/plugin/core_async.clj
+++ src/onyx/plugin/core_async.clj
@@ -12,9 +12,12 @@
 (defmethod p-ext/read-batch [:input :core.async]
   [{:keys [onyx.core/task-map core.async/chan core.async/retry-ch
            core.async/pending-messages] :as event}]
-  (let [batch-size (:onyx/batch-size task-map)
+  (let [pending (count (keys @pending-messages))
+        max-pending (or (:onyx/max-pending task-map) 10000)
+        batch-size (:onyx/batch-size task-map)
+        max-segments (min (- max-pending pending) batch-size)
         ms (or (:onyx/batch-timeout task-map) 50)
-        batch (->> (range batch-size)
+        batch (->> (range max-segments)
                    (map (fn [_] {:id (java.util.UUID/randomUUID)
                                 :input :core.async
                                 :message (first (alts!! [retry-ch chan (timeout ms)] :priority true))}))


searching vertexes

searching vertexes

--- src/ophion/query.clj
+++ src/ophion/query.clj
@@ -470,7 +470,7 @@
         search? (search-origins now)]
     (if search?
       (let [vertex? (search-vertex-origins now)
-            results (search-index search (if vertex? "Gene" "edge") (get begin now))]
+            results (search-index search (if vertex? "vertex" "edge") (get begin now))]
         (if (empty? results)
           []
           (iterator-seq


RS + CW | #74 | api returns 404 when user is not found while updating profile

--- test/objective8/integration/api/users.clj
+++ test/objective8/integration/api/users.clj
@@ -115,4 +115,14 @@
                                                                                :user-uri (str "/users/" user-id)}))]
                       (:status response) => 200
                       (:headers response) => (helpers/location-contains (str "/api/v1/users/" user-id))
-                      (:body response) => (helpers/json-contains {:profile {:name "name" :biog "biography"}})))))
+                      (:body response) => (helpers/json-contains {:profile {:name "name" :biog "biography"}})))
+
+              (fact "returns a 404 if the user does not exist"
+                    (let [invalid-user-id 2323
+                          {response :response} (p/request app "/api/v1/users/writer-profiles"
+                                                          :request-method :post
+                                                          :content-type "application/json"
+                                                          :body (json/generate-string {:name "name"
+                                                                                :biog "biography"
+                                                                                :user-uri (str "/users/" invalid-user-id)}))]
+                      (:status response) => 404))))


First test.

First test.

--- test/onyx/coordinator/simulation_test.clj
+++ test/onyx/coordinator/simulation_test.clj
@@ -7,11 +7,23 @@
             [onyx.util :as u]
             [datomic.api :as d]))

-(let [peer (extensions/create :zookeeper :peer)
-      offer-ch-interceptor (chan 1)]
-  (tap async/offer-mult offer-ch-interceptor)
-  (>!! async/born-peer-ch-head peer)
-  (let [result (<!! offer-ch-interceptor)]
-    (d/q '[:find ?e :where [?e :peer/place]] (d/db @datomic/datomic-conn))
-    (close! offer-ch-interceptor)))
+(defn sandbox-db []
+  (datomic/start-datomic!
+   (str "datomic:mem://" (java.util.UUID/randomUUID))
+   (datomic/log-schema)))

+(deftest new-peer
+  (with-redefs [datomic/datomic-conn (delay (sandbox-db))]
+    (let [peer (extensions/create :zookeeper :peer)
+          offer-ch-interceptor (chan 1)]
+      (tap async/offer-mult offer-ch-interceptor)
+      (>!! async/born-peer-ch-head peer)
+      (let [_ (<!! offer-ch-interceptor)
+            query '[:find ?p :where [?e :peer/place ?p]]
+            result (d/q query (d/db @datomic/datomic-conn))]
+        (is (= (count result) 1))
+        (is (= (ffirst result) peer))
+        (close! offer-ch-interceptor)))))
+
+(run-tests)
+


another talkative logging

another talkative logging

--- src/ontrail/auth.clj
+++ src/ontrail/auth.clj
@@ -33,6 +33,6 @@
   (try
       (:username (user-from-token (:value (cookies "authToken"))))
       (catch Exception exception
-        (.error logger (str "Could not get user from cookie " exception))
+        (.error trace (str "Could not get user from cookie " exception))
         "nobody")))


tuned parameters

tuned parameters

--- src/ontrail/keen.clj
+++ src/ontrail/keen.clj
@@ -14,7 +14,7 @@
         [compojure.core :only (defroutes ANY POST GET PUT DELETE)]))

 (def conman
-  (make-reusable-conn-manager {:timeout 10 :threads 10 :default-per-route 10}))
+  (make-reusable-conn-manager {:timeout 10 :threads 3 :default-per-route 3}))

 (def connection
   (merge {:accept :json}
@@ -51,7 +51,7 @@
       walk/keywordize-keys))

 (def memo-count-by-id
-  (memo/ttl count-by-id :ttl/threshold (* 10 60 1000)))
+  (memo/ttl count-by-id :ttl/threshold (* 60 60 1000)))

 (defn try-get-one [id]
   (try
@@ -78,7 +78,7 @@
          (filter #(not= "admin" (:user %)))
          (map-indexed (fn [i o] (assoc o :index (inc i)))))))

-(def memo-most-read (memo/ttl most-read :ttl/threshold (* 6 60 60 1000)))
+(def memo-most-read (memo/ttl most-read :ttl/threshold (* 12 60 60 1000)))

 (defroutes
   keen-routes


Fix Replica Version's use in schema

Fix Replica Version's use in schema

--- src/onyx/schema.cljc
+++ src/onyx/schema.cljc
@@ -598,6 +598,9 @@
 (s/defschema SlotId
   s/Int)

+(s/defschema ReplicaVersion
+  s/Int)
+
 (s/defschema Replica
   {:job-scheduler JobScheduler
    :messaging {:onyx.messaging/impl Messaging s/Keyword s/Any}
@@ -635,11 +638,11 @@
    :state-logs {JobId {TaskId {SlotId [s/Int]}}}
    :state-logs-marked #{s/Int}
    :task-slot-ids {JobId {TaskId {PeerId SlotId}}}
-   :exhausted-inputs {JobId #{TaskId}}
+   :exhausted-inputs {JobId {TaskId ReplicaVersion}}
    :required-tags {JobId {TaskId [s/Keyword]}}
    :peer-tags {PeerId [s/Keyword]}
-   :allocation-version {JobId s/Int}
-   :version s/Int})
+   :allocation-version {JobId ReplicaVersion}
+   :version ReplicaVersion})

 (s/defschema LogEntry
   {:fn s/Keyword


Comment.

Comment.

--- src/posthere/app.clj
+++ src/posthere/app.clj
@@ -20,7 +20,7 @@
   ; POST requests
   (POST "/:uuid" [uuid :as request] (capture-request uuid request)) ; Capture their POST request

-  ; Resource requests
+  ; Resource requests (in development)
   (route/resources "/assets/"))

 (def app


removed video-1 thumbnail on home page

removed video-1 thumbnail on home page

--- src/prais2/home.cljc
+++ src/prais2/home.cljc
@@ -78,7 +78,8 @@
      (what-why)
      (data)
      (everything-else)]]
-   (video-thumbnails)]
+    ;(video-thumbnails)
+   ]

   #_[:.container-fluid
      [:.row.home-thumbail


Allow report/get-report to still take just a report-key as an argument as that arity/1 version is used in a guard expression.

--- src/open_company/resources/report.clj
+++ src/open_company/resources/report.clj
@@ -1,5 +1,6 @@
 (ns open-company.resources.report
-  (:require [defun :refer (defun)]
+  (:require [clojure.string :as s]
+            [defun :refer (defun)]
             [rethinkdb.query :as r]
             [open-company.config :as c]
             [open-company.resources.common :as common]
@@ -53,10 +54,11 @@
 (defn get-report
   "Given the ticker symbol of the company and the year and period of the report,
   or the primary key, retrieve it from the database, or return nil if it doesn't exist."
-  ([ticker year period] (get-report ticker (key-for ticker year period)))
+  ([report-key] (get-report (first (s/split report-key #"-")) report-key))
   ([ticker report-key]
     (when (company/get-company ticker)
-      (common/read-resource table-name report-key))))
+      (common/read-resource table-name report-key)))
+  ([ticker year period] (get-report ticker (key-for ticker year period))))

 (defun create-report
   "Given the report property map, create the report returning the property map for the resource or `false`.


Pass the metronome for the first instance of the melody with a 0 for symmetry.

--- src/overtunes/songs/frere_jacques.clj
+++ src/overtunes/songs/frere_jacques.clj
@@ -20,7 +20,7 @@

 (defn frere-jacques []
   (let [metro (metronome 120)]
-    (play-melody melody foo metro)
+    (play-melody melody foo (metronome-from metro 0))
     (play-melody melody foo (metronome-from metro 8))
     (play-melody melody foo (metronome-from metro 16))
     (play-melody melody foo (metronome-from metro 24))))


edits to hiding feedback

edits to hiding feedback

--- src-cljs/frontend/components/pieces/page_header.cljs
+++ src-cljs/frontend/components/pieces/page_header.cljs
@@ -251,7 +251,7 @@
               (when (ld/feature-on? "top-bar-beta-button")
                 [:div.topbar-toggle
                  (when (and has-topbar?
-                            (not (= (:nav-point topbar-beta) :build)))
+                         (not= (:nav-point topbar-beta) :build))
                    [:span.feedback
                      (button/link {:fixed? true
                                    :kind :primary


(PDB-4701) Add report filters in query engine

--- src/puppetlabs/puppetdb/query_eng.clj
+++ src/puppetlabs/puppetdb/query_eng.clj
@@ -1,6 +1,4 @@
 (ns puppetlabs.puppetdb.query-eng
-  (:import [org.postgresql.util PGobject]
-           [org.joda.time Period])
   (:require [clojure.core.match :as cm]
             [clojure.java.jdbc :as sql]
             [clojure.tools.logging :as log]
@@ -19,11 +17,15 @@
             [puppetlabs.puppetdb.query.fact-contents :as fact-contents]
             [puppetlabs.puppetdb.query.resources :as resources]
             [puppetlabs.puppetdb.query.catalog-inputs :as inputs]
+            [puppetlabs.puppetdb.query-eng.default-reports :as dr]
             [puppetlabs.puppetdb.scf.storage-utils :as sutils]
             [puppetlabs.puppetdb.schema :as pls]
             [puppetlabs.puppetdb.utils :as utils]
             [puppetlabs.puppetdb.query-eng.engine :as eng]
-            [schema.core :as s]))
+            [schema.core :as s])
+  (:import (clojure.lang ExceptionInfo)
+           (org.postgresql.util PGobject)
+           (org.joda.time Period)))

 (def entity-fn-idx
   (atom
@@ -127,9 +129,25 @@

                       :else
                       (get-in @entity-fn-idx [entity :rec]))
-          columns (orderable-columns query-rec)]
+          columns (orderable-columns query-rec)
+          unknown-err-msg (trs "Unknown exception when processing ast to add report type filter(s).")
+          ast (try (dr/maybe-add-agent-report-filter-to-query query-rec query)
+                (catch ExceptionInfo e
+                  (let [data (ex-data e)
+                        msg (.getMessage e)]
+                    (when (not= ::dr/unrecognized-ast-syntax (:kind data))
+                      (log/error e unknown-err-msg)
+                      (throw e))
+                    (log/error e msg)
+                    ::failed))
+                (catch Exception e
+                  (log/error e unknown-err-msg)
+                  (throw e)))]
       (paging/validate-order-by! columns query-options)
-      (eng/compile-user-query->sql query-rec query query-options))))
+      (if (= ast ::failed)
+        ;; TODO; when AST parse fails, ensure the whole query fails
+        (eng/compile-user-query->sql query-rec query query-options)
+        (eng/compile-user-query->sql query-rec ast query-options)))))

 (defn get-munge-fn
   [entity version paging-options url-prefix]


meter and feet

meter and feet

--- src/xanny/poetry.clj
+++ src/xanny/poetry.clj
@@ -1,3 +1,5 @@
 (ns xanny.poetry)

 (def feet {:iamb ["-" "/"] :trochee ["/" "-"]})
+
+(def meter {:mono 1 :di 2 :tri 3 :tetra 4 :penta 5 :hexa 6 :hepta 7 :octa 8})


use `ajax/ajax` instead of `ajax/managed-ajax`

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -505,13 +505,12 @@
   (let [api-ch (:api comms)
         vcs-type (vcs-url/vcs-type vcs-url)
         owner (vcs-url/org-name vcs-url)
-        repo (vcs-url/repo-name vcs-url)
-        uuid frontend.async/*uuid*]
-    (go
-      (let [api-result (<! (ajax/managed-ajax :put (api-path/merge-pull-request vcs-type owner repo number)
-                                              :params {:sha sha}))]
-        (put! api-ch [:merge-pull-request (:status api-result) api-result])
-        (release-button! uuid (:status api-result))))))
+        repo (vcs-url/repo-name vcs-url)]
+    (ajax/ajax :put
+               (api-path/merge-pull-request vcs-type owner repo number)
+               :merge-pull-request
+               api-ch
+               :params {:sha sha})))

 (defmethod post-control-event! :ssh-build-clicked
   [target message {:keys [build-num build-id vcs-url] :as args} previous-state current-state comms]


Basic pass at drawing shapes

Basic pass at drawing shapes

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -3,6 +3,9 @@
             [cljs.reader :as reader]
             [frontend.async :refer [put!]]
             [frontend.components.forms :refer [release-button!]]
+            [datascript :as d]
+            [frontend.datascript :as ds]
+            [frontend.layers :as layers]
             [frontend.routes :as routes]
             [frontend.state :as state]
             [frontend.stripe :as stripe]
@@ -81,3 +84,40 @@
 (defmethod control-event :night-mode-toggled
   [target message {:keys [project-id]} state]
   (update-in state state/night-mode-path not))
+
+(defmethod control-event :mouse-depressed
+  [target message [x y] state]
+  (let [layer (layers/make-layer x y)]
+    (-> state
+        (assoc-in [:drawing :in-progress?] true)
+        (assoc-in [:drawing :layer] layer))))
+
+(defmethod control-event :mouse-moved
+  [target message [x y] state]
+  (if (get-in state [:drawing :in-progress?])
+    (-> state
+        (update-in [:drawing :layer] assoc
+                   :layer/current-x x
+                   :layer/current-y y))
+    state))
+
+(defmethod control-event :mouse-released
+  [target message [x y] state]
+  (-> state
+      (update-in [:drawing :layer] dissoc :layer/current-x :layer/current-y :in-progress?)
+      (update-in [:drawing :layer] assoc :layer/end-x x :layer/end-y y)))
+
+(defmethod post-control-event! :mouse-depressed
+  [target message [x y] previous-state current-state])
+
+(defmethod post-control-event! :mouse-moved
+  [target message [x y] previous-state current-state])
+
+(defmethod post-control-event! :mouse-released
+  [target message [x y] previous-state current-state]
+  (let [db (:db current-state)
+        was-drawing? (get-in previous-state [:drawing :in-progress?])
+        layer (get-in current-state [:drawing :layer])]
+    (when was-drawing?
+      (d/transact! db [layer])
+      (print "New db: " db))))


WIP: debugging travis

WIP: debugging travis

--- test/clj/puppetlabs/trapperkeeper/services/webserver/jetty9_config_test.clj
+++ test/clj/puppetlabs/trapperkeeper/services/webserver/jetty9_config_test.clj
@@ -4,7 +4,7 @@
             [puppetlabs.trapperkeeper.services.webserver.jetty9-config :refer :all]
             [puppetlabs.trapperkeeper.testutils.logging :refer [with-log-output logs-matching]]))

-(deftest jetty7-minimum-threads-test
+#_(deftest jetty7-minimum-threads-test
   (testing "should return the same number when higher than num-cpus"
     (is (= 500 (jetty7-minimum-threads 500 1))))
   (testing "should set the number to min threads when it is higher and return a warning"
@@ -53,11 +53,11 @@
           (is (not (contains? processed-config :ssl-cert)))
           (is (not (contains? processed-config :ssl-ca-cert)))))))

-  (testing "should set max-threads"
+  #_(testing "should set max-threads"
     (let [config (configure-web-server {})]
       (is (contains? config :max-threads))))

-  (testing "should merge configuration with initial-configs correctly"
+  #_(testing "should merge configuration with initial-configs correctly"
     (let [user-config {:truststore "foo"}
           config      (configure-web-server user-config)]
       (is (= config {:truststore "foo" :max-threads 50 :client-auth :need :port 8080})))


delaney.clj: added orientation-testing functions.

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -108,6 +108,21 @@
     (cond (nil? i) ori
           (or (nil? D) (ori D)) (recur ori xs)
           :else (recur (assoc ori D (if (= :root i) 1 (- (ori Di)))) xs))))
+
+(defn loopless? [ds]
+  (every? (fn [[i D]] (not= D (s ds i D)))
+          (for [i (indices ds), D (elements ds)] [i D])))
+
+(defn oriented? [ds]
+  (let [ori (partial-orientation ds)]
+    (every? (fn [[i D]] (not= (ori D) (ori (s ds i D))))
+            (for [i (indices ds), D (elements ds)] [i D]))))
+
+(defn weakly-oriented? [ds]
+  (let [ori (partial-orientation ds)]
+    (every? (fn [[i D]]
+              (let [Di (s ds i D)] (or (= D Di) (not= (ori D) (ori Di)))))
+            (for [i (indices ds), D (elements ds)] [i D]))))

 (defn- protocol [ds indices trav]
   (let [imap (zipmap indices (range (count indices)))


Clear the graph view when the Track button is pressed.

--- samples/twitterbuzz/src/twitterbuzz/showgraph.cljs
+++ samples/twitterbuzz/src/twitterbuzz/showgraph.cljs
@@ -80,5 +80,5 @@
 (def animation (atom nil))

 ;(events/listen (dom/getElement "network") events/EventType.CLICK start-anneal)
-;(buzz/register :track-clicked start-anneal)
+(buzz/register :track-clicked #(. g (clear)))
 ;(buzz/register :refresh-clicked start-anneal)


wip on fixing import normalization issues

--- src/tango/ui_db.cljc
+++ src/tango/ui_db.cljc
@@ -15,9 +15,44 @@
        el))
    nm))

+;http://stackoverflow.com/questions/11577601/clojure-nested-map-change-value#11578370
+;; round participants from number to real id
+;;  :round/results [{:result/participant-number 30 => :result/participant {:participant/id xx
+
+;; make index of participants?
+
+;; :result/judgings
+;; ({:judging/adjudicator is the actual adj id but must be in correct form {:adjudicator/id xx
+
+(defn participant-index [cmp]
+  "Return map of index number -> id"
+  (reduce
+   (fn [index participant]
+     (assoc index (:participant/number participant) (:participant/id participant)))
+   {}
+   (mapcat :class/starting (:competition/classes cmp))))
+
 (defn sanitize [cmp]
   (-> cmp
       (remove-nils)))
+
+(let [res [1]]
+  (clojure.walk/postwalk
+   (fn [form]
+     (if (:round/name form) (assoc form :round/name "Y") form))
+   {:competition/class [{:class/rounds [{:round/name "X"}]}]}))
+
+(defn normalize-participant [index cmp]
+  (clojure.walk/postwalk
+   (fn [form]
+     (if (:result/participant-number form)
+       (dissoc
+        (assoc form :result/participant {:participant/id (get index (:result/participant-number form))})
+        :result/participant-number)
+       form))
+   cmp))
+
+

 ;; get all stuff
 ;; transform stuff with fn


these should not be marked private

these should not be marked private

--- src-cljs/cuttle/util.cljs
+++ src-cljs/cuttle/util.cljs
@@ -67,10 +67,10 @@
 ;; File Util
 ;;------------------------------------------------------------------------------

-(defn- file-exists? [filename]
+(defn file-exists? [filename]
   (.existsSync fs filename))

-(defn- write-file-async!
+(defn write-file-async!
   "Useful when we want to write a file asynchronously and do not care when it
    is finished."
   [filename contents]


switch from (merge) to (unify) to catch contradictions sooner

--- src/babel/encyclopedia.cljc
+++ src/babel/encyclopedia.cljc
@@ -6,7 +6,7 @@
    [babel.exception :refer [exception]]
    #?(:cljs [babel.logjs :as log])
    #?(:clj [clojure.tools.logging :as log])
-   [dag_unify.core :refer [strip-refs]]))
+   [dag_unify.core :refer [strip-refs unify]]))

 (def encyc
   {
@@ -101,10 +101,6 @@
    }
   )

-(def animal {:animate true
-             :artifact false
-             :living true})
-
 (defn null-sem-impl [input]
   "null sem-impl: simply return input."
   (log/trace (str "null-sem-impl:" (strip-refs input)))
@@ -114,7 +110,8 @@
   (get encyc {k (get-in input [k])} {}))

 (defn impl-list [input]
-  [(get-encyc input :activity)
+  [
+   (get-encyc input :activity)
    (get-encyc input :animate)
    (get-encyc input :artifact)
    (get-encyc input :buyable)
@@ -129,7 +126,8 @@
               :part-of-human-body)
    (get-encyc input :pet)
    (get-encyc input :place)
-   (get-encyc input :time)])
+   (get-encyc input :time)
+   ])

 (defn sem-impl [input & [original-input]]
   "expand input feature structures with semantic (really cultural) implicatures, e.g., if human, then not buyable or edible"
@@ -139,40 +137,21 @@
                              input))]
     (cond
       (= input :top) input
+      (= input :fail) :fail
       true
-      (let [activity   (get-encyc input :activity)
-            animate    (get-encyc input :animate)
-            artifact   (get-encyc input :artifact)
-            buyable    (get-encyc input :buyable)
-            city       (get-encyc input :city)
-            clothing   (get-encyc input :clothing)
-            consumable (get-encyc input :consumable)
-            drinkable  (get-encyc input :drinkable)
-            edible     (get-encyc input :edible)
-            furniture  (get-encyc input :furniture)
-            human      (get-encyc input :human)
-            part-of-human-body (get-encyc input
-                                          :part-of-human-body)
-            pet        (get-encyc input :pet)
-            place      (get-encyc input :place)
-            time       (get-encyc input :time)
-            ]
-        (let [merged
-              (cond (= input :fail) :fail
+      (let [merged
+            (unify input
+                   (reduce unify (impl-list input)))]
+        (log/debug (str "sem-impl so far: " merged))
+        (if (not (= merged input)) ;; TODO: make this check more efficient: count how many rules were hit
+          ;; rather than equality-check to see if merged has changed.
+          (sem-impl merged original-input) ;; we've added some new information: more implications possible from that.

-                    true
-                    (merge input
-                           (reduce merge [activity animate artifact buyable city clothing consumable drinkable
-                                          edible furniture human
-                                          pet place time])))]
-          (log/trace (str "sem-impl so far: " merged))
-          (if (not (= merged input)) ;; TODO: make this check more efficient: count how many rules were hit
-            ;; rather than equality-check to see if merged has changed.
-            (sem-impl merged original-input) ;; we've added some new information: more implications possible from that.
-
-            ;; else, no more implications: done.
-            (do
-              (log/debug (str "sem-impl:" (strip-refs original-input) " -> " (strip-refs merged)))
-              merged)))))))
+          ;; else, no more implications: done.
+          (do
+            (log/debug (str "sem-impl:" (strip-refs original-input) " -> " (strip-refs merged)))
+            merged))))))

+
+


add space

add space

--- src/midje/doc.clj
+++ src/midje/doc.clj
@@ -69,7 +69,7 @@
   (recheck-fact :print-nothing) ; Check silently (but produce true/false).
   (rcf)                         ; Synonym for above.

-  Note: facts with `:check-only-at-load-time`metadata do not get
+  Note: facts with `:check-only-at-load-time` metadata do not get
   stored for rechecking.

   ----- Forgetting facts


State.

State.

--- test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_020_atoms.clj
+++ test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_020_atoms.clj
@@ -12,11 +12,11 @@
 (fact (deref my-number-atom) => 0)
 (fact @my-number-atom => 0)

-(swap! my-number-atom inc) ; does this: (inc 0)
-(fact @my-number-atom => 1)
+(do (swap! my-number-atom inc) ; does this: (inc 0)
+    (fact @my-number-atom => 1))

-(swap! my-number-atom inc) ; does this: (inc 1)
-(fact @my-number-atom => 2)
+(do (swap! my-number-atom inc) ; does this: (inc 1)
+    (fact @my-number-atom => 2))

 (fact "`swap` returns the new value of the atom"
   (swap! my-number-atom inc) => 3
@@ -25,46 +25,46 @@
 ;;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 ;;;; Supplying args to the swap function:

-(swap! my-number-atom + 10) ; does this: (+ 2 10)
-(fact @my-number-atom => 12)
+(do (swap! my-number-atom + 10) ; does this: (+ 2 10)
+    (fact @my-number-atom => 12))

-(swap! my-number-atom + 10) ; does this: (+ 12 10)
-(fact @my-number-atom => 22)
+(do (swap! my-number-atom + 10) ; does this: (+ 12 10)
+    (fact @my-number-atom => 22))

-(swap! my-number-atom + 10 20 30) ; does this: (+ 22 10 20 30)
-(fact @my-number-atom => 82)
+(do (swap! my-number-atom + 10 20 30) ; does this: (+ 22 10 20 30)
+    (fact @my-number-atom => 82))

 ;;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-;;;; Maps in atoms
+;;;; Storing maps in atoms

 (def my-map-atom (atom {}))

-(swap! my-map-atom assoc :first-name "Alice")
-;; does this: (assoc {} :first-name "Alice"}
-(fact @my-map-atom => {:first-name "Alice"})
+(do (swap! my-map-atom assoc :first-name "Alice")
+    ;; does this: (assoc {} :first-name "Alice"}
+    (fact @my-map-atom => {:first-name "Alice"}))

-(swap! my-map-atom assoc :first-name "Bob")
-;; does this: (assoc {:first-name "Alice"} :first-name "Bob")
-(fact @my-map-atom => {:first-name "Bob"})
+(do (swap! my-map-atom assoc :first-name "Bob")
+    ;; does this: (assoc {:first-name "Alice"} :first-name "Bob")
+    (fact @my-map-atom => {:first-name "Bob"}))

-(swap! my-map-atom assoc-in [:address :line-1] "78 Green Lane")
-;; does this: (assoc-in {:first-name "Bob"} [:address :line-1] "78 Green Lane")
-(fact @my-map-atom => {:first-name "Bob"
-                       :address {:line-1 "78 Green Lane"}})
+(do (swap! my-map-atom assoc-in [:address :line-1] "78 Green Lane")
+    ;; does this: (assoc-in {:first-name "Bob"} [:address :line-1] "78 Green Lane")
+    (fact @my-map-atom => {:first-name "Bob"
+                           :address {:line-1 "78 Green Lane"}}))

-(swap! my-map-atom assoc-in [:address :line-1] "37 High Street")
-(fact @my-map-atom => {:first-name "Bob"
-                       :address {:line-1 "37 High Street"}})
+(do (swap! my-map-atom assoc-in [:address :line-1] "37 High Street")
+    (fact @my-map-atom => {:first-name "Bob"
+                           :address {:line-1 "37 High Street"}}))

 ;;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 ;;;; `compare-and-set!`

-(fact @my-number-atom => 82)
-(fact (compare-and-set! my-number-atom 99 42) => false)
-(fact @my-number-atom => 82)
+(do (fact @my-number-atom => 82)
+    (fact (compare-and-set! my-number-atom 99 42) => false)
+    (fact @my-number-atom => 82))

-(fact (compare-and-set! my-number-atom 82 42) => true)
-(fact @my-number-atom => 42)
+(do (fact (compare-and-set! my-number-atom 82 42) => true)
+    (fact @my-number-atom => 42))

 ;;;; ___________________________________________________________________________
 ;;;; Atoms: `reset!`


Modifications on Uwes Algorithm

Modifications on Uwes Algorithm

There was a bug in the computation of the mimimum covers which was due
to not properly checking a cover for being redundant (redundant with
respect to the given base set).

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

--- src/conexp/contrib/experimental/ryssel_algorithm.clj
+++ src/conexp/contrib/experimental/ryssel_algorithm.clj
@@ -15,7 +15,7 @@

 ;;; Searching for minimum covers

-(defn- covers? [base-set sets]
+(defn- covers? [sets base-set]
   (if (empty? base-set)
     true
     (loop [rest (transient base-set),
@@ -27,32 +27,48 @@
             true
             (recur new-rest (next sets))))))))

-(defn- redundant? [cover]
+(defn- redundant? [base-set cover count]
   (exists [set cover]
     (forall [x set]
-      (exists [other-set (disj cover set)]
-        (contains? other-set x)))))
+      (=> (contains? base-set x)
+          (<= 2 (get count x))))))

 (defn- minimum-covers [base-set sets]
-  (let [drop    (memoize drop),
-        sets    (vec (sort #(>= (count %1) (count %2)) sets)),
-        nr-sets (count sets),
-        result  (atom (transient [])),
-        search  (fn search [rest-base-set current-cover i]
+  (let [sets    (sort #(>= (count %1) (count %2)) sets),
+        result  (atom []),
+        search  (fn search [rest-base-set current-cover cover-count sets]
                   (cond
-                   (redundant? current-cover)  nil,
-                   (empty? rest-base-set)      (swap! result conj! current-cover),
-                   (>= i nr-sets)              nil,
+                   (redundant? base-set current-cover cover-count)
+                   nil,
+
+                   (empty? rest-base-set)
+                   (swap! result conj current-cover),
+
+                   (empty? sets)
+                   nil,
+
                    :else
-                   (when (covers? rest-base-set (drop i sets))
-                     (when (exists [x (sets i)]
+                   (when (covers? sets rest-base-set)
+                     (when (exists [x (first sets)]
                              (contains? rest-base-set x))
-                       (search (difference rest-base-set (sets i))
-                               (conj current-cover (sets i))
-                               (inc i)))
-                     (search rest-base-set current-cover (inc i)))))]
-    (search base-set #{} 0)
-    (persistent! @result)))
+                       (search (difference rest-base-set (first sets))
+                               (conj current-cover (first sets))
+                               (reduce! (fn [map x]
+                                          (if (contains? base-set x)
+                                            (assoc! map x (inc (get map x)))
+                                            map))
+                                        cover-count
+                                        (first sets))
+                               (rest sets)))
+                     (search rest-base-set
+                             current-cover
+                             cover-count
+                             (rest sets)))))]
+    (search base-set
+            #{}
+            (map-by-fn (constantly 0) base-set)
+            sets)
+    @result))

 ;;; Collapsing implications with equal premise
@@ -79,9 +95,9 @@
 (defn ryssel-base
   "Returns the set of implications computed by Ryssels Algorithm."
   [ctx]
-  (let [oprime (memoize #(object-derivation ctx %)),
+  (let [oprime (memoize #(oprime ctx %)),
         gens   (reduce! (fn [map x]     ;generating elements of attribute extents
-                          (let [extent (attribute-derivation ctx #{x})]
+                          (let [extent (aprime ctx #{x})]
                             (assoc! map extent
                                     (conj (get map extent #{}) x))))
                         {}


fixed redis loading of dbpedia page links

--- corpusmaker.clj
+++ corpusmaker.clj
@@ -18,28 +18,44 @@
   (:use
      [clojure.contrib.duck-streams :only (read-lines)]))

+;
+; Utilities to parse DBPedia N-TRIPLES dump to load them in a redis DB to
+; perform fast look up of wikilink => entity type
+;
+
 ; RE to parse a line of a N-TRIPLES RDF stream to find a type relationship
 ; http://www.w3.org/TR/rdf-testcases/#ntriples
-(def *type-pattern* #"<([^<]+?)> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <([^<]+?)> \.")
-(def *page-pattern* #"<([^<]+?)> <http://xmlns.com/foaf/0.1/page> <([^<]+?)> \.")
+(def *type-pattern*
+  #"<([^<]+?)> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <([^<]+?)> \.")
+(def *page-pattern*
+  #"<([^<]+?)> <http://xmlns.com/foaf/0.1/page> <([^<]+?)> \.")

 (defn collect-page
   "Parse a N-TRIPLES statement and store the [instance page] pair if match"
   [store-func statement]
   (let [[_ inst page] (re-find *page-pattern* statement)]
-    (when inst (store-func page inst)))
+    (when inst (store-func page inst))))

 (defn process-file [filename line-func]
   ; TODO: add start line and end line (max)
   ; TODO: add version to pass an acc explicitly and reduce instead?
   ; http://lethain.com/entry/2009/nov/15/reading-file-in-clojure/
-  (doall (map line-func (read-lines filename))))
+  (count (map line-func (read-lines filename))))

 (defn collect-pages-redis
   [filename]
   (redis/with-server
     {:host "127.0.0.1" :port 6379 :db 0}
-    (process-file filename #(collect-page redis/set %))))
+    (let [store-func #(redis/set %1 %2)
+          process-line #(collect-page store-func %)]
+      (process-file filename process-line))))
+
+;
+; Utilities to parse a complete Wikimedia XML dump to extract sentence that
+; contain token annotated with a wiki link that point to a page that matches a
+; named entity with a type among the classes of the DBPedia ontology:
+; Person, Organisation, Place, ...
+;

 ; TODO: rewrite this using http://github.com/marktriggs/xml-picker-seq since
 ; using a zipper keeps all the parsed elements in memory which is not suitable


fixed license

fixed license

--- main/src/dda/pallet/dda_managed_vm/infra/tightvnc.clj
+++ main/src/dda/pallet/dda_managed_vm/infra/tightvnc.clj
@@ -1,6 +1,18 @@
-; Copyright (c) meissa GmbH. All rights reserved.
-; You must not remove this notice, or any other, from this software.
-
+; Licensed to the Apache Software Foundation (ASF) under one
+; or more contributor license agreements. See the NOTICE file
+; distributed with this work for additional information
+; regarding copyright ownership. The ASF licenses this file
+; to you under the Apache License, Version 2.0 (the
+; "License"); you may not use this file except in compliance
+; with the License. You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
 (ns dda.pallet.dda-managed-vm.infra.tightvnc
   (:require
     [pallet.actions :as actions]


copying binaries

copying binaries

--- src/leiningen/new/closp.clj
+++ src/leiningen/new/closp.clj
@@ -14,71 +14,69 @@

 (def render (renderer "closp"))

+(def proj-dir (io/file (System/getProperty "leiningen.original.pwd")))
+(defn unpack
+  [name-proj name-in name-out]
+  (let [p (string/join "/" ["leiningen" "new" "closp" name-in])
+        i (io/resource p)
+        o (io/file proj-dir name-proj name-out)
+        _ (io/make-parents o)
+        is (io/input-stream i)
+        os (io/output-stream o)]
+    (io/copy is os)
+    (.flush os)))

 (defn generate-project [name feature-params data]
-  ;(io/copy (io/reader (io/resource "leiningen/new/closp/img/loading.gif")) (io/file "./loading.gif"))
   (binding [*name* name
             *render* #((renderer "closp") % data)]
     (reset! features (-> feature-params))
-    ;(reset! features (-> feature-params dailycred-params site-params db-required-features))

     (println "Generating new CLOSP project named" (str name "..."))
-    (println (.getPath (File. ".")))

-      (apply (partial ->files data)
-            (concat
-              [[".gitignore" (*render* "gitignore")]
-               ["project.clj" (*render* "project.clj")]
-               [(str "src/clj/{{san-path}}/dev.clj") (*render* "clj/dev.clj")]
-               [(str "src/clj/{{san-path}}/handler.clj") (*render* "clj/handler.clj")]
-               [(str "src/clj/{{san-path}}/core.clj") (*render* "clj/core.clj")]
-               [(str "src/clj/{{san-path}}/layout.clj") (*render* "clj/layout.clj")]
-               [(str "src/clj/{{san-path}}/middleware.clj") (*render* "clj/middleware.clj")]
-               [(str "src/clj/{{san-path}}/repl.clj") (*render* "clj/repl.clj")]
-               [(str "src/clj/{{san-path}}/session.clj") (*render* "clj/session.clj")]
-               [(str "src/clj/{{san-path}}/util.clj") (*render* "clj/util.clj")]
-
-               [(str "src/clj/{{san-path}}/routes/home.clj") (*render* "clj/routes/home.clj")]
-               [(str "src/clj/{{san-path}}/routes/user.clj") (*render* "clj/routes/user.clj")]
+    (apply (partial ->files data)
+           (concat
+             [[".gitignore" (*render* "gitignore")]
+              ["project.clj" (*render* "project.clj")]
+              [(str "src/clj/{{san-path}}/dev.clj") (*render* "clj/dev.clj")]
+              [(str "src/clj/{{san-path}}/handler.clj") (*render* "clj/handler.clj")]
+              [(str "src/clj/{{san-path}}/core.clj") (*render* "clj/core.clj")]
+              [(str "src/clj/{{san-path}}/layout.clj") (*render* "clj/layout.clj")]
+              [(str "src/clj/{{san-path}}/middleware.clj") (*render* "clj/middleware.clj")]
+              [(str "src/clj/{{san-path}}/repl.clj") (*render* "clj/repl.clj")]
+              [(str "src/clj/{{san-path}}/session.clj") (*render* "clj/session.clj")]
+              [(str "src/clj/{{san-path}}/util.clj") (*render* "clj/util.clj")]

-               [(str "src/clj/{{san-path}}/service/auth.clj") (*render* "clj/service/auth.clj")]
-
-               [(str "src/cljs/{{san-path}}/core.cljs") (*render* "cljs/core.cljs")]
-               [(str "src/cljs/{{san-path}}/helper.cljs") (*render* "cljs/helper.cljs")]
-               [(str "env/dev/cljs/{{sanitized}}/dev.cljs") (*render* "env/dev/cljs/dev.cljs")]
-               [(str "env/prod/cljs/{{sanitized}}/prod.cljs") (*render* "env/prod/cljs/prod.cljs")]
+              [(str "src/clj/{{san-path}}/routes/home.clj") (*render* "clj/routes/home.clj")]
+              [(str "src/clj/{{san-path}}/routes/user.clj") (*render* "clj/routes/user.clj")]

-               [(str "src/cljx/{{san-path}}/clj-core.cljx") (*render* "cljx/clj-core.cljx")]
-
+              [(str "src/clj/{{san-path}}/service/auth.clj") (*render* "clj/service/auth.clj")]

-               [(str "resources/templates/base.html") (*render* "resources/templates/base.html")]
-               [(str "resources/templates/menu.html") (*render* "resources/templates/menu.html")]
-               [(str "resources/templates/profile.html") (*render* "resources/templates/profile.html")]
-               [(str "resources/templates/registration.html") (*render* "resources/templates/registration.html")]
-               [(str "resources/templates/home/agb.html") (*render* "resources/templates/home/agb.html")]
-               [(str "resources/templates/home/contact.html") (*render* "resources/templates/home/contact.html")]
-               [(str "resources/templates/home/cookies.html") (*render* "resources/templates/home/cookies.html")]
-               [(str "resources/templates/home/index.html") (*render* "resources/templates/home/index.html")]
-               [(str "resources/templates/home/tos.html") (*render* "resources/templates/home/tos.html")]
-               [(str "resources/templates/user/admin.html") (*render* "resources/templates/user/admin.html")]
-               [(str "resources/templates/user/login.html") (*render* "resources/templates/user/login.html")]
+              [(str "src/cljs/{{san-path}}/core.cljs") (*render* "cljs/core.cljs")]
+              [(str "src/cljs/{{san-path}}/helper.cljs") (*render* "cljs/helper.cljs")]
+              [(str "env/dev/cljs/{{sanitized}}/dev.cljs") (*render* "env/dev/cljs/dev.cljs")]
+              [(str "env/prod/cljs/{{sanitized}}/prod.cljs") (*render* "env/prod/cljs/prod.cljs")]

-               [(str "resources/public/css/screen.css") (*render* "resources/public/css/screen.css")]
-               [(str "resources/public/css/home.css") (*render* "resources/public/css/home.css")]
+              [(str "src/cljx/{{san-path}}/clj-core.cljx") (*render* "cljx/clj-core.cljx")]

-               ["resources/public/img/loading.gif" (render "resources/public/img/loading.gif")]

-               ;"resources/public/img/browser_carousel_small.jpg"
-               ;"resources/public/img/"
-               ;"resources/public/img/"
-               ;"resources/public/img/"
+              [(str "resources/templates/base.html") (*render* "resources/templates/base.html")]
+              [(str "resources/templates/menu.html") (*render* "resources/templates/menu.html")]
+              [(str "resources/templates/profile.html") (*render* "resources/templates/profile.html")]
+              [(str "resources/templates/registration.html") (*render* "resources/templates/registration.html")]
+              [(str "resources/templates/home/agb.html") (*render* "resources/templates/home/agb.html")]
+              [(str "resources/templates/home/contact.html") (*render* "resources/templates/home/contact.html")]
+              [(str "resources/templates/home/cookies.html") (*render* "resources/templates/home/cookies.html")]
+              [(str "resources/templates/home/index.html") (*render* "resources/templates/home/index.html")]
+              [(str "resources/templates/home/tos.html") (*render* "resources/templates/home/tos.html")]
+              [(str "resources/templates/user/admin.html") (*render* "resources/templates/user/admin.html")]
+              [(str "resources/templates/user/login.html") (*render* "resources/templates/user/login.html")]

-               ;[(str "resources/public/img/channel_carousel_small.jpg") (*render* "resources/public/img/channel_carousel_small.jpg")]
-               ;[(str "resources/public/img/loading.jpg") (*render* "resources/public/img/loading.jpg")]
-               ;[(str "resources/public/img/template_carousel_small.jpg") (*render* "resources/public/img/template_carousel_small.jpg")]
-               ]
-              )))
-    )
+              [(str "resources/public/css/screen.css") (*render* "resources/public/css/screen.css")]
+              [(str "resources/public/css/home.css") (*render* "resources/public/css/home.css")]]))
+
+
+    (mapv #(apply unpack (:sanitized data) %)
+          [["loading.gif" "resources/public/img/loading.gif"]])))

 (defn closp
   "Create a new CLOSP project"
@@ -88,8 +86,8 @@
         san-path (string/replace ns #"\." "/")
         data {:name      name
               :sanitized (sanitize name)
-              :san-path    san-path
-              :ns     ns
+              :san-path  san-path
+              :ns        ns
               :year      (year)}]
     ;; Handle help and error conditions
     (cond
@@ -104,9 +102,9 @@

       (:help options) (opt-helper/exit 0 (opt-helper/usage summary))
       ;(not= (count arguments) 1) (exit 1 (usage summary))
-
+
       errors (opt-helper/exit 1 (opt-helper/error-msg errors))
-
+
       :else (generate-project name args data))
     )
   )