A bit better with memory footprint for select cubes

--- src/plugins/Scripts/Funimage/Annotation/Select_Cubes_2D.clj
+++ src/plugins/Scripts/Funimage/Annotation/Select_Cubes_2D.clj
@@ -112,7 +112,7 @@
                   "c2=" (get-title (second imps))
                   " "
                   "c3=" (get-title (last imps))
-                  " keep"))
+                  #_" keep"))
   #_(ij.plugin.RGBStackMerge/mergeHyperstacks (into-array ij.ImagePlus (take 3 imps)) false)
   #_(let [argmap (apply hash-map args)]
      (.mergeHyperstacks (ij.plugin.RGBStackMerge.) (into-array ij.ImagePlus (take 3 imps)) (or (:keep-source argmap) false))))
@@ -132,7 +132,7 @@
     (show-imp foreground-imp)
     (show-imp background-imp)
     (show-imp (set-title (imps-to-rgb3 (map (comp convert-to-8bit autocontrast)
-                                            [foreground-imp imp background-imp]))
+                                            [foreground-imp (show-imp (copy-imp imp)) background-imp]))
                         "Mask Visualization"))))

 ;; Dialog construction


Report when we detect a pod as deleted (#1279)

* Report when we detect a pod as deleted

* Review feedback

* Update scheduler/src/cook/kubernetes/controller.clj

Co-Authored-By: Daniel Posada <d0b0a3e4ff9ddf9df0a9e6f1184e5e15381eae45@gmail.com>

--- scheduler/src/cook/kubernetes/controller.clj
+++ scheduler/src/cook/kubernetes/controller.clj
@@ -199,8 +199,9 @@

 (defn pod-deleted
   "Indicate that kubernetes does not have the pod. Invoked by callbacks from kubernetes."
-  [{:keys [existing-state-map] :as kcc} ^V1Pod pod-deleted]
+  [{:keys [existing-state-map name] :as kcc} ^V1Pod pod-deleted]
   (let [pod-name (api/V1Pod->name pod-deleted)]
+    (log/info "In compute cluster" name ", detected pod" pod-name "deleted")
     (locking (calculate-lock pod-name)
       (swap! existing-state-map dissoc pod-name)
       (process kcc pod-name))))


Fix case of not finding :deploy-to when no options are provided.

--- src/leiningen/deploy.clj
+++ src/leiningen/deploy.clj
@@ -55,6 +55,6 @@
        (.execute)))
   ([project]
      (if-let [target (:deploy-to project)]
-       (deploy target)
+       (apply deploy project target)
        (do (println "Either set :deploy-to in project.clj or"
                     "provide deploy target options.") 1))))


Fix #2 by adding code to print compiler options when :debug is true in project.clj

--- src/leiningen/fregec.clj
+++ src/leiningen/fregec.clj
@@ -52,6 +52,13 @@
                       (into-array String ~srcs)
                       ~flags ~out
                       (into-array String ~cp) "")
+           pr-opts#  (when ~(:debug project)
+                       (println "")
+                       (->> opts#
+                            frege.compiler.Main/printopts
+                            frege.prelude.PreludeBase$TST/performUnsafe
+                            .call)
+                       (println ""))
            compiler# (frege.compiler.Main/runfregec
                       (into-array String ~files)
                       opts# (java.io.PrintWriter. *err*))
@@ -84,7 +91,6 @@
                                  (into [] srcs) out
                                  (into [] cp) flags
                                  (into [] files))]
-      ;; (print-opts options) ;; debugging
       (binding [eval/*pump-in* false]
         (eval/eval-in (project/merge-profiles project [subprocess-profile])
                       form)))))


Fix merging bugs, add preservation option

--- src-cljs/cljs_workspace/om_branch_merge.cljs
+++ src-cljs/cljs_workspace/om_branch_merge.cljs
@@ -6,7 +6,7 @@
 (def merge-candidate (atom nil))
 (def staged-for-merge (atom {:from nil :into nil}))

-(defn merge-state [remote-state local-state]
+(defn merge-state [local-state remote-state]
     (let [merged (merge local-state remote-state)]
       ; recover the old values, that ar on the exclude list and return
       (reduce
@@ -48,37 +48,42 @@
     res
     [root-branch [] []])) ; find the path to branch from root

-(defn extract-branch [start-fp path]
-  (into [] (reduce (fn [[flattened fork] next-attr]
-                        (let [data @(get-in fork :next-attr :data)]
-                            [(concat flattened data) (last data)]))
-                    [[] start-fp]
-                    path)))
+(defn extract-branch [start-fp path]
+    (if (empty? path)
+      (if (contains? start-fp :cont)
+        (extract-branch start-fp [:cont])
+        [])
+      (let [next-attr (first path)
+            data @(get-in start-fp [next-attr :data])]
+          (into [] (concat (butlast data) (extract-branch (last data) (rest path)))))))
+
+(defn merge-streams [s1 s2]
+  (map merge-state (concat s1 (repeat (last s1))) s2))

 (defn merge-from-flattened [branch flat-data]
-  (let [local-data @(branch :data)]
-    (if (< (count local-data) (count flat-data))
-        ; we need to either continue merging after a branching point
-        ; or append new merged entries to our local-branch
-        (if-let [last-entry (last local-data)]
-            (if (contains? last-entry :cont)
-                ; we have to now continue merging into BOTH forking branches, as we are NOT stroing diffs
-                (let [merged-part (map merge-state (butlast local-data) flat-data)
-                      cont (merge-from-flattened (last-entry :cont) (take (count local-data) flat-data))
-                      fork (merge-from-flattened (last-entry :fork) (take (count local-data) flat-data))]
-                    (conj merged-part {:cont {root: (last-entry :root) :data (atom cont)}
-                                       :fork {root: (last-entry :root) :data (atom fork)}}))
-                ; we reached the end of the branch and just append additional states to the branch
-                ; that are all merges with the last state in the branch
-                (map merge-state (concat local-data (repeat last-entry)) (flat-data)))
-            ; this is a weird case and the branch part we have to merge into
-            ; is actually a stub and contains no entries. In that case we just
-            ; append merged versions with the previous last entry to until the flattened
-            ; data is used up. But this is so weird, we can just aswell return the flat-data
-            (map merge-state (repeat {}) flat-data))
-        ; if not we have fewer entries to be merged into, we continue
-        ; merging the last state into all other proceeding local states
-        (conj (map merge-state (butlast local-data) (concat flat-data (repeat (last flat-data)))) (last local-data)))))
+  (let [local-data @(branch :data)
+        flat-data (if (> (count local-data) (count flat-data))
+                      (into [] (concat flat-data (repeat (- (count local-data) (count flat-data)) (last flat-data))))
+                      flat-data)
+        result
+            (if-let [last-entry (last local-data)]
+                (if (contains? last-entry :cont)
+                    ; we have to now continue merging into BOTH forking branches, as we are NOT stroing diffs
+                    (let [merged-part (into [] (map merge-state (butlast local-data) flat-data))
+                          cont (merge-from-flattened (last-entry :cont) (drop (count local-data) flat-data))
+                          fork (merge-from-flattened (last-entry :fork) (drop (count local-data) flat-data))]
+                        (conj merged-part {:cont {:root (get-in last-entry [:cont :root]) :data (atom cont)}
+                                           :fork {:id (get-in last-entry [:fork :id]) :data (atom fork)}}))
+                    ; we reached the end of the branch and just append additional states to the branch
+                    ; that are all merges with the last state in the branch
+                    (merge-streams local-data flat-data))
+                ; this is a weird case and the branch part we have to merge into
+                ; is actually a stub and contains no entries. In that case we just
+                ; append merged versions with the previous last entry to until the flattened
+                ; data is used up. But this is so weird, we can just aswell return the flat-data
+                (map merge-state (repeat {}) flat-data))
+          ]
+      (into [] result)))

 (defn merge-branches [remote-branch local-branch root-branch]
   (prn "Merging Branch " (remote-branch :id) " into " (local-branch :id))
@@ -86,28 +91,26 @@
          ; we first flatten the remote branch such that it appears to be one continuous
          ; vector of states, which makes it easier to perform the merge into our local branch
          remote (extract-branch fp remote-path)
-         merged-branch (merge-from-flattened local-branch remote)]
-      (prn "merged branch of len " (count local) " and " (count remote) " into size " (len merged-branch))
-      (reset! (into-branch :data) merged-branch) ; maybe clean up the remote branch that got included?
+         local (fp (first local-path)) ; we have to merge into all the subbranches anyway so we dont care for the rest path
+         merged-branch (merge-from-flattened local remote)]
+      (reset! (local :data) merged-branch) ; maybe clean up the remote branch that got included?
       ))

 (defn select-for-merge [branch cbk]
   ; if we select the same twice, we deselect
-  (prn "select for marge: " cbk)
+  (prn "select for merge: " cbk)
   (if (= @merge-candidate branch)
       (reset! merge-candidate nil)
       (if @merge-candidate
-          (if cbk
-            (do
-              (reset! staged-for-merge {:from @merge-candidate :into branch})
-              (cbk @merge-candidate branch)
-              (reset! merge-candidate nil))
-            (merge-branch @merge-candidate branch)) ; perform merge immediately if not callback defined
-          (reset! merge-candidate branch))))
+        (do
+          (reset! staged-for-merge {:from @merge-candidate :into branch})
+          (cbk @merge-candidate branch)
+          (reset! merge-candidate nil))
+        (reset! merge-candidate branch))))

 (defn merge-staged-branches [root-branch]
-  (let [[a b] @staged-for-merge]
-    (merge-branches a b root-branch)))
+  (let [{:keys [from into]} @staged-for-merge]
+    (merge-branches from into root-branch)))

 (defn toggle-preserve [morph-path]
   (if (contains? @preserve-list morph-path)


When running, show elapsed time in XX:XX format

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -1363,8 +1363,7 @@
    [:span.start-time
     {:title (datetime/full-datetime start-time)}
     (om/build common/updating-duration
-              {:start start-time}
-              {:opts {:formatter datetime/time-ago-abbreviated}})
+              {:start start-time})
     " ago"]])

 (defn build-finished-status [{stop-time :stop_time


Moved 'canceled by' block

Moved 'canceled by' block

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -944,15 +944,16 @@
               [:span.summary-label "Triggered by: "]
               [:span (trigger-html build)]]

+             (when-let  [canceler  (and  (=  status "canceled")
+                                         canceler)]
+
+               [:div.summary-item
+                [:span.summary-label "Canceled by: "]
+                [:span (build-canceler canceler)]])
+
              (when (build-model/has-pull-requests? build)
                (pull-requests {:urls (map :url pull_requests)} owner))]]

-           (when-let  [canceler  (and  (=  status "canceled")
-                                       canceler)]
-             [:div.summary-header
-              [:div.summary-items
-               [:div.summary-item
-                (build-canceler canceler)]]])
            [:div.card
             [:div.small-emphasis
              (let [n (count all_commit_details)]


Identity API rename is_user -> user?

Identity API rename is_user -> user?

--- src-cljs/frontend/components/pages/team.cljs
+++ src-cljs/frontend/components/pages/team.cljs
@@ -93,7 +93,7 @@
           users (when show-modal?
                   (->> vcs-users-by-handle
                        vals
-                       (remove :is_user)
+                       (remove :user?)
                        (sort-by :handle)))
           count-users (count users)]
       (reify
@@ -110,9 +110,9 @@
               (om/set-state! owner
                              :org-members-by-handle
                              (into {}
-                                   (for [[handle {:keys [is_user email]
+                                   (for [[handle {:keys [user? email]
                                                   :as user}] new-vcs-users
-                                         :when (not is_user)
+                                         :when (not user?)
                                          :let [trimmed-email (some-> email gstr/trim)]]
                                      [handle {:entered-email trimmed-email
                                               :selected? (valid-email? trimmed-email)}]))))))


Only transact if the tweets are non-empty.

--- src/twitter_collector/core.clj
+++ src/twitter_collector/core.clj
@@ -30,8 +30,9 @@
 (defn store-tweets [stage pending]
   (go-try
    (let [st (.getTime (java.util.Date.))
-         tweet-txs [['add-tweets (vec (first (swap! pending (fn [[prev cur]] [cur '()]))))]]]
-     (when-not (empty? tweet-txs)
+         tweets (vec (first (swap! pending (fn [[prev cur]] [cur '()]))))
+         tweet-txs [['add-tweets tweets]]]
+     (when-not (empty? tweets)
        (<? (cs/transact! stage [user cdvcs-id] tweet-txs)))
      (when (< (rand) 0.01)
        (println "Date: " (java.util.Date.))
@@ -72,14 +73,21 @@

   (count (second @pending))

+  (require '[replikativ.p2p.fetch :refer [fetch]])
+
   (def client-store (<?? (new-fs-store "/media/void/1e843516-40ec-4b2b-83d2-c796ee312a59/twitter/")))

-  (def client (<?? (client-peer client-store)))
+  (def client (<?? (client-peer client-store :middleware fetch)))

   (def client-stage (<?? (create-stage! user client)))
   (<?? (cs/create-cdvcs! client-stage :id cdvcs-id))

+  (<?? (cs/merge! client-stage [user cdvcs-id]
+                  (seq (get-in @client-stage [user cdvcs-id :state :heads]))))
+
   (<?? (connect! client-stage "ws://127.0.0.1:9095"))
+
+  (<?? (connect! client-stage "ws://topiq.es:9095"))

   (keys @(:state (get-in @peer [:volatile])))

@@ -89,6 +97,8 @@

   (count (get-in @client-stage [user cdvcs-id :state :commit-graph]))

+  (get-in @client-stage [user cdvcs-id :state :heads])
+
   (count (get-in @stage [user cdvcs-id :state :commit-graph]))

   (require '[replikativ.crdt.cdvcs.realize :as r])
@@ -96,18 +106,31 @@
   (def hist
     (r/commit-history (get-in @client-stage [user cdvcs-id :state :commit-graph])
                       (first (get-in @client-stage [user cdvcs-id :state :heads]))))
-
+
   (require '[clojure.core.async :as async]
            '[konserve.core :as k])

   (def commits
-    (->> hist
-         (map (fn [id] (k/get-in mem-store [id])))
+    (->> (take 10 hist)
+         (map #(k/get-in client-store [%]))
          async/merge
          (async/into [])
-         <??))
+         <??
+         ))

-  (take 10 commits)
+  (filter nil? commits)
+
+  (map (comp keys second) commits)
+  (map (fn [{[[_ v]] :transactions :as elem}] (if-not v elem)) commits)
+
+  (->> commits
+       (map (fn [{[[_ v]] :transactions :as elem}] v))
+       (filter identity)
+       (map #(go-try [% (<? (k/get-in client-store [%]))]))
+       async/merge
+       (async/into [])
+       <??
+       (map first))

   (<?? (k/get-in mem-store [(first hist)]))


Capital

Capital

--- src/lt/objs/plugins.cljs
+++ src/lt/objs/plugins.cljs
@@ -417,7 +417,7 @@
                         (object/raise manager :search-plugins! term)))})

 (cmd/command {:command :plugin-manager.refresh
-              :desc "Plugins: refresh plugin list"
+              :desc "Plugins: Refresh plugin list"
               :exec (fn []
                       (object/raise manager :refresh!)
                       (object/raise manager :fetch-plugins))})


Revert "use condp instead of lookup in a map" I swear this passed the tests locally :S

This reverts commit 3f9010f3e504c5cc2e284b3ebc27d189f7503509.

--- src/midje/semi_sweet.clj
+++ src/midje/semi_sweet.clj
@@ -31,11 +31,10 @@
 ;; FURTHERMORE, I wanted to use set operations to check for fake and not-called,
 ;; but those fail for reasons I don't understand. Bah.
 (defn- ^{:testable true } check-for-arrow [arrow]
-  (condp = (name arrow)
-    => :check-match
-    =expands-to=> :check-match
-    =not=> :check-negated-match
-    =deny=> :check-negated-match))
+  (get {=> :check-match
+        =expands-to=> :check-match
+        =not=> :check-negated-match
+        =deny=> :check-negated-match} (name arrow)))

 (defmacro unprocessed-check
   "Creates a map that contains a function-ized version of the form being
@@ -55,15 +54,17 @@
      :arrow '~arrow }
      (hash-map-duplicates-ok ~@overrides)))

-(defmulti ^{:private true} expect-expansion (fn [_call-form_ arrow & _]
-                                               (condp = (name arrow)
-                                                  => :expect*
-                                                  =not=> :expect*
-                                                  =deny=> :expect*
-                                                  =expands-to=> :expect-macro*
-                                                  =future=> :report-future-fact )))
+(letfn [(how-to-handle-check [_call-form_ arrow & _]
+          (get {=> :expect*
+                =not=> :expect*
+                =deny=> :expect*
+                =expands-to=> :expect-macro*
+                =future=> :report-future-fact} (name arrow)))]

-(defmethod expect-expansion :expect* [call-form arrow expected-result fakes overrides]
+  (defmulti ^{:private true} expect-expansion how-to-handle-check))
+
+(defmethod expect-expansion :expect*
+  [call-form arrow expected-result fakes overrides]
   `(let [check# (unprocessed-check ~call-form ~arrow ~expected-result ~overrides)]
      (midje.semi-sweet/*expect-checking-fn* check# ~fakes)))


Add some space above the note of invite to join.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -351,6 +351,7 @@
       (h1 invite-message)
       (spacer 40)
       (paragraph (format invite-instructions from org-name))
+      (spacer 20)
       (when show-note? (note-author from-avatar from true))
       (when show-note? (spacer 16))
       (when show-note? (paragraph note))


Improve validate-enough-peers! error message to provide better help

--- src/onyx/test_helper.clj
+++ src/onyx/test_helper.clj
@@ -30,15 +30,12 @@
                       {:catalog catalog :task-name task-name})))
     (first matches)))

-(defn n-peers
-  "Takes a workflow and catalog, returns the minimum number of peers
-   needed to execute this job."
-  [{:keys[catalog workflow] :as job}]
+(defn job->min-peers-per-task
+  [{:keys [catalog workflow] :as job}]
   (let [task-set (into #{} (apply concat workflow))]
-    (reduce
-     (fn [sum t]
-       (+ sum (or (:onyx/min-peers (find-task catalog t)) 1)))
-     0 task-set)))
+    (mapv (fn [t]
+           {:task t :min-peers (or (:onyx/min-peers (find-task catalog t)) 1)})
+         task-set)))

 (defn validate-enough-peers!
   "Checks that the test environment will start enough peers to start the job.  Do
@@ -46,15 +43,20 @@
   number of peers running over a cluster, and the number of peers that has joined
   is subject to change as nodes come online and go offline."
   [test-env job]
-  (let [required-peers (n-peers job)]
+  (let [peers-per-task (job->min-peers-per-task job)
+        _ (println "peers " peers-per-task)
+        required-peers (reduce + (map :min-peers peers-per-task))]
     (when (< (:n-peers test-env) required-peers)
       (throw (ex-info (format "test-env requires at least %s peers to start the job.
                                validate-enough-peers! checks your job to see whether you've started enough peers before submitting a job to the test cluster that might hang.
-                               Tasks each require at least one peer to be started, and may require more if :onyx/n-peers or :onyx/min-peers is set."
-                              required-peers)
-                      {:job job
-                       :n-peers (:n-peers test-env)
-                       :required-n-peers required-peers})))))
+                               Tasks each require at least one peer to be started, and may require more if :onyx/n-peers or :onyx/min-peers is set.
+                               Minimum peers for each task: %s."
+                              required-peers
+                              peers-per-task)
+                      {:required-n-peers required-peers
+                       :peers-peer-task peers-per-task
+                       :job job
+                       :n-peers (:n-peers test-env)})))))

 (defn playback-log [log replica ch timeout-ms]
   (loop [replica replica]


fix cyclic-load dependency

fix cyclic-load dependency

--- src/pc/http/datomic2.clj
+++ src/pc/http/datomic2.clj
@@ -2,7 +2,6 @@
 (ns pc.http.datomic2
   (:require [clojure.core.async :as async]
             [clojure.tools.logging :as log]
-            [pc.http.sente :as sente]
             [pc.datomic :as pcd]
             [datomic.api :refer [db q] :as d]))


comment out synths in design file

comment out synths in design file

--- etc/synthdefs/synth-designs.clj
+++ etc/synthdefs/synth-designs.clj
@@ -275,23 +275,23 @@
       (out out-bus (pan2 (* env snd) pan amp))))

-  (save-to-pi dull_bell)
-  (save-to-pi pretty_bell)
-  (save-to-pi beep)
-  (save-to-pi saw_beep)
-  (save-to-pi dsaw)
-  (save-to-pi fm)
-
-  (save-to-pi mod_saw)
-  (save-to-pi mod_saw_s)
-  (save-to-pi mod_dsaw)
-  (save-to-pi mod_dsaw_s)
-  (save-to-pi mod_sine)
-  (save-to-pi mod_sine_s)
-  (save-to-pi mod_tri)
-  (save-to-pi mod_tri_s)
-  (save-to-pi mod_pulse)
-  (save-to-pi mod_pulse_s)
+  ;; (save-to-pi dull_bell)
+  ;; (save-to-pi pretty_bell)
+  ;; (save-to-pi beep)
+  ;; (save-to-pi saw_beep)
+  ;; (save-to-pi dsaw)
+  ;; (save-to-pi fm)
+
+  ;; (save-to-pi mod_saw)
+  ;; (save-to-pi mod_saw_s)
+  ;; (save-to-pi mod_dsaw)
+  ;; (save-to-pi mod_dsaw_s)
+  ;; (save-to-pi mod_sine)
+  ;; (save-to-pi mod_sine_s)
+  ;; (save-to-pi mod_tri)
+  ;; (save-to-pi mod_tri_s)
+  ;; (save-to-pi mod_pulse)
+  ;; (save-to-pi mod_pulse_s)
   )


adding availability wait and volume deletion

--- src/aws/provider.clj
+++ src/aws/provider.clj
@@ -99,11 +99,20 @@
   (let [zone (instance-desc endpoint instance-id :placement :availability-zone)]
     (doseq [{:keys [device size]} volumes]
       (let [{:keys [volumeId]} (with-ctx ebs/create-volume size zone)]
+        (wait-for {:timeout [10 :minute]} #(= "available" (with-ctx ebs/state volumeId))
+           {:type ::aws:ebs-volume-availability :message "Failed to wait for ebs volume to become available"})
         (with-ctx ebs/attach-volume volumeId instance-id device)
-        (wait-for [10 :minute]
-            #(= "attached" (with-ctx ebs/attachment-status volumeId))
-            {:type ::aws:ebs-volume-attach-failed :message "Failed to wait for ebs volume device attach"})
-        ))))
+        (wait-for {:timeout [10 :minute]} #(= "attached" (with-ctx ebs/attachment-status volumeId))
+           {:type ::aws:ebs-volume-attach-failed :message "Failed to wait for ebs volume device attach"})))))
+
+(defn delete-volumes
+   "Clear instance volumes"
+   [endpoint instance-id]
+   (doseq [{:keys [ebs]} (-> (instance-desc endpoint instance-id) :block-device-mappings rest)]
+     (with-ctx ebs/detach-volume (ebs :volume-id))
+     (wait-for {:timeout [10 :minute]} #(= "available" (with-ctx ebs/state  (ebs :volume-id)))
+        {:type ::aws:ebs-volume-availability :message "Failed to wait for ebs volume to become available"})
+     (with-ctx ebs/delete-volume (ebs :volume-id))))

 (defconstrainedrecord Instance [endpoint spec user]
   "An Ec2 instance"
@@ -132,7 +141,8 @@
   (delete [this]
     (with-instance-id
       (debug "deleting" instance-id)
-      (with-ctx ec2/terminate-instances instance-id )
+      (delete-volumes endpoint instance-id)
+      (with-ctx ec2/terminate-instances instance-id)
       (wait-for-status this "terminated" [5 :minute])))

   (stop [this]
@@ -167,13 +177,10 @@
   (:endpoint m )
   (.status m)
   (.start m)
-  (celestial.model/set-env :dev
-   (ebs/create-volume (assoc (celestial.model/hypervisor :aws) :endpoint "ec2.ap-southeast-2.amazonaws.com") 10 "ap-southeast-2b"))
-  (celestial.model/set-env :dev
-   (ebs/delete-volume (assoc (celestial.model/hypervisor :aws) :endpoint "ec2.ap-southeast-2.amazonaws.com") "vol-b0286582"))
-  (celestial.model/set-env :dev
-   (ebs/attach-volume (assoc (celestial.model/hypervisor :aws) :endpoint "ec2.ap-southeast-2.amazonaws.com") "vol-a9317c9b" "i-c7b66cfb" "/dev/sdn"))
-  (celestial.model/set-env :dev (instance-desc "ec2.ap-southeast-2.amazonaws.com" "i-c7b66cfb" :placement :availability-zone))
+  (clojure.pprint/pprint (celestial.model/set-env :dev
+      (-> (instance-desc "ec2.eu-west-1.amazonaws.com" "i-395e1d76") :block-device-mappings rest)))
+
+

   )


fix bug: remove :dag_unify.core/serialized from spec before looking up in database

--- src/babel/reader.clj
+++ src/babel/reader.clj
@@ -257,8 +257,9 @@
            results))))

 (defn read-all [spec language]
-  (let [spec (unify spec
-                    {:synsem {:subcat '()}})
+  (let [spec (dissoc (unify spec
+                            {:synsem {:subcat '()}})
+                     :dag_unify.core/serialized)

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


made the buffer of StringPushbackReader extensible

--- src/blind/reader.clj
+++ src/blind/reader.clj
@@ -17,32 +17,36 @@
   (list 'set! what (list f what)))

 (deftype StringPushbackReader
-    [^:unsynchronized-mutable ^String s ^:unsynchronized-mutable buf
-     ^:unsynchronized-mutable len ^:unsynchronized-mutable buf?]
+    [^:unsynchronized-mutable ^String s ^:unsynchronized-mutable len
+     ^"[Ljava.lang.Object;" buf ^:unsynchronized-mutable pos]
   PushbackReader
   (read-char [reader]
-    (if buf?
-      (do (set! buf? false)
-          buf)
+    (if (< pos (alength buf))
+      (let [r (aget buf pos)]
+        (update! pos inc)
+        r)
       (when (pos? len)
         (let [r (.charAt s 0)]
           (update! len dec)
           (set! s (.substring s 1))
           r))))
   (peek-char [reader]
-    (if buf?
-      buf
+    (if (< pos (alength buf))
+      (aget buf pos)
       (when (pos? len)
           (.charAt s 0))))
   (unread [reader ch]
     (when ch
-      (if buf? (throw (RuntimeException. "Pushback buffer is full")))
-      (set! buf ch)
-      (set! buf? true))))
-
-(defn string-push-back-reader [^String s]
+      (if (zero? pos) (throw (RuntimeException. "Pushback buffer is full")))
+      (update! pos dec)
+      (aset buf pos ch))))
+
+(defn string-push-back-reader
   "Creates a StringPushbackReader from a given string"
-  (StringPushbackReader. s nil (.length s) false))
+  ([s]
+     (string-push-back-reader s 1))
+  ([^String s buf-len]
+     (StringPushbackReader. s (.length s) (object-array buf-len) buf-len)))

 (defprotocol IndexingReader
   (get-line-number [reader])


Add more scaling optiosn

Add more scaling optiosn

--- src/clj/clojurewerkz/statistiker/scaling.clj
+++ src/clj/clojurewerkz/statistiker/scaling.clj
@@ -1,17 +1,74 @@
 (ns clojurewerkz.statistiker.scaling
-  (:require [clojurewerkz.statistiker.statistics :refer [mean sd]]))
+  (:require [clojurewerkz.statistiker.statistics :refer [mean sd]]
+            [clojurewerkz.statistiker.fast-math :refer [sqr]]))
+
+(defn make-rescale-range-fn
+  [x xmin xmax]
+  (let [orig-min  (apply min x)
+        orig-max  (apply max x)
+        orig-diff (- orig-max orig-min)
+        diff      (- xmax xmin)]
+    (fn [x]
+      (double (+ (/ (* (- x orig-min)
+                       diff)
+                    orig-diff)
+                 xmin
+                 )))))
+
+(defn make-rescale-fn
+  [x]
+  (let [xmin (apply min x)
+        xmax (apply max x)
+        diff (- xmax xmin) ]
+    (fn [x] (double (/ (- x xmin) diff)))))

 (defn rescale
-  "Linear transformation"
   [x]
-  (let [xmin        (apply min x)
-        xmax        (apply max x)
-        scale-fn (fn [x] (double (/ (- x xmin) (- xmax xmin))))]
-    (mapv scale-fn x)))
+  (mapv (make-rescale-fn x) x))
+
+(defn rescale-range
+  [x xmin xmax]
+  (mapv (make-rescale-range-fn x xmin xmax) x))
+
+(defn make-standartise-fn
+  [x]
+  (let [xmean    (mean x)
+        xsd      (sd x)]
+    (fn [x] (double (/ (- x xmean) xsd)))))

 (defn standartise
   [x]
-  (let [xmean    (mean x)
-        xsd      (sd x)
-        scale-fn (fn [x] (double (/ (- x xmean) xsd)))]
-    (map scale-fn x)))
+  (mapv (make-standartise-fn x) x))
+
+(defn make-l1-normalize-fn
+  [x]
+  (let [sum (->> x
+                 (map #(Math/abs %))
+                 (reduce +))]
+    #(/ % sum)))
+
+(defn l1-normalize
+  "L1-normalize (divide each element by sum of absolute values)."
+  [x]
+  (mapv (make-l1-normalize-fn x) x))
+
+(defn make-l2-normalize-fn
+  [x]
+  (let [sum (->> x
+                 (map #(sqr %))
+                 (reduce +))]
+    #(/ % sum)))
+
+(defn l2-normalize
+  "L2-normalize (divide each element by sum of squares)"
+  [x]
+  (mapv (make-l2-normalize-fn x) x))
+
+(defn scale-feature
+  [maps key scale-fn-factory]
+  (let [extracted (map #(get % key) maps)
+        scale-f   (scale-fn-factory extracted)
+        scaled    (map scale-f extracted)
+        ]
+    (map (fn [v scaled]
+           (assoc v key scaled)) maps scaled)))


fixed typo

fixed typo

--- src/cljs/reagent_phonecat_tutorial/core.cljs
+++ src/cljs/reagent_phonecat_tutorial/core.cljs
@@ -48,7 +48,7 @@
             :order-prop :name

             :navigation {:page :phones ;; can be any one of #{:phones :phone}
-                         :param {}}
+                         :params {}}
             }))

 (def navigational-state (rg/cursor state [:navigation]))


CMR-812: Updated CMR extension and format support.

--- src/cmr/metadata_db/data/oracle/concepts.clj
+++ src/cmr/metadata_db/data/oracle/concepts.clj
@@ -40,9 +40,7 @@
   here match what Catalog REST stores and must continue to match that. Adding new ones is allowed
   but do not modify these existing values."
   {"application/echo10+xml" "ECHO10"
-   "application/iso+xml" "ISO_MENDS"
-   "application/iso-smap+xml" "ISO_SMAP"
-   "application/iso-mends+xml" "ISO_MENDS"
+   "application/iso:smap+xml" "ISO_SMAP"
    "application/iso19115+xml" "ISO19115"
    "application/dif+xml" "DIF"})


I don't think this is the correct way to test this

--- test/albatross/core_test.clj
+++ test/albatross/core_test.clj
@@ -32,16 +32,6 @@
 (use-fixtures :each wrap-tests)

 (deftest start-and-stop
-  (testing "start multiple times"
-    ;; FIXME
-    (;; let [system (component/start (albatross-system test-config))]
-     ;;  (is (= system (component/start system)))
-     ;;  (component/stop system)
-      ))
-  (testing "stop and start"
-    (let [system (component/start (albatross-system test-config))]
-      (component/stop system)
-      (is true)))
-  (testing "stop multiple times"
-    (let [system (component/stop (component/start (albatross-system test-config)))]
-      (is (= system (component/stop system))))))
+  (testing "start multiple times")
+  (testing "stop and start")
+  (testing "stop multiple times"))


Added (stage-all-changes) helper function

--- src/clj_git/core.clj
+++ src/clj_git/core.clj
@@ -43,3 +43,8 @@
       (let [new-commit-hash (write-commit text)]
         (move-branch (head-name) new-commit-hash)
         new-commit-hash))))
+
+(defn stage-all-changes []
+  (doseq [filename (list-modified-files)]
+    (stage-file filename))
+  (print-status))


fixing test

fixing test

--- test/celestial/test/jobs.clj
+++ test/celestial/test/jobs.clj
@@ -16,7 +16,7 @@
    (provided
      (server-conn) => {}
      (acquire-lock {} "red1" 1800000 300000) => nil :times 1
-     (jobs/save-status anything :success)  => {:status :success}  :times 1
+     (jobs/save-status "red1" anything :success)  => {:status :success}  :times 1
      ))


[test/spiral-test] Patch for cljs.

[test/spiral-test] Patch for cljs.

--- test/cortex/spiral_test.cljc
+++ test/cortex/spiral_test.cljc
@@ -1,19 +1,16 @@
 (ns cortex.spiral-test
   (:require
-    [clojure.test :refer [deftest is are]]
+    [clojure.core.matrix :as m]
     [cortex.optimise :as opt]
-    [clojure.core.matrix :as m]
-    [clojure.core.matrix.random :as randm]
     [cortex.util :as util]
     [cortex.network :as net]
     [cortex.core :as core]
     [cortex.layers :as layers]))

-
-
 (def num-points 200)
 (def num-classes 3)
-(m/set-current-implementation :vectorz)
+
+(m/set-current-implementation #?(:clj :vectorz :cljs :thing-ndarray))

 (defn create-spiral
   [start-theta end-theta start-radius end-radius num-items]
@@ -64,7 +61,6 @@
         score (net/evaluate-softmax network all-data all-labels)]
     [score network]))

-
 (defonce score-network (atom nil))

 (defn get-score-network


Fix missing :require of clojure.set

Fix missing :require of clojure.set

Reported by Martin Blais

--- src/main/clojure/clojure/tools/namespace.clj
+++ src/main/clojure/clojure/tools/namespace.clj
@@ -16,7 +16,8 @@
   ^{:author "Stuart Sierra",
      :doc "Search for ns declarations in dirs, JARs, or CLASSPATH"}
   clojure.tools.namespace
-  (:require [clojure.java.classpath :as classpath])
+  (:require [clojure.java.classpath :as classpath]
+            [clojure.set :as set])
   (import (java.io File FileReader BufferedReader PushbackReader
                    InputStreamReader)
           (java.util.jar JarFile)))
@@ -139,7 +140,7 @@
 ;;; Parsing dependencies

 (defn- deps-from-libspec [prefix form]
-  (cond (list? form) (apply union (map (fn [f] (deps-from-libspec
+  (cond (list? form) (apply set/union (map (fn [f] (deps-from-libspec
 						(symbol (str (when prefix (str prefix "."))
 							     (first form)))
 						f))
@@ -153,11 +154,11 @@
 (defn- deps-from-ns-form [form]
   (when (and (list? form)
 	     (contains? #{:use :require} (first form)))
-    (apply union (map #(deps-from-libspec nil %) (rest form)))))
+    (apply set/union (map #(deps-from-libspec nil %) (rest form)))))

 (defn deps-from-ns-decl
   "Given a (quoted) ns declaration, returns a set of symbols naming
   the dependencies of that namespace.  Handles :use and :require
   clauses but not :load."
   [decl]
-  (apply union (map deps-from-ns-form decl)))
+  (apply set/union (map deps-from-ns-form decl)))


simplifying down towards zero

simplifying down towards zero

--- src/cooljure/csv.clj
+++ src/cooljure/csv.clj
@@ -18,7 +18,7 @@

 ; AWTAWT TODO: add ":delimiter \x" support

-(defn parse-csv->maps
+(defn parse-csv->maps-v0
   "Reads string data from the specified CSV file. The first row is assumed to be column
   header strings, which are (safely) converted into keywords. Each row is converted to a
   map using the column-hdr-keywords map and the corresponding string data from that row.
@@ -40,6 +40,23 @@
                                             (fn [cum-map [parse-kw parse-fn]]
                                               (update-in cum-map [parse-kw] parse-fn) )
                                             raw-map parse-fns-map )
-                        ] data-map ))
+                          ] data-map ))
     ] data-maps )))

+(defn parse-csv->maps
+  "Reads string data from the specified CSV file. The first row is assumed to be column
+  header strings, which are (safely) converted into keywords. Each row is converted to a
+  map using the column-hdr-keywords map and the corresponding string data from that row.
+  If supplied, each entry of parse-fns-map associates a col-hdr-keyword & a parsing
+  function, which is applied to the corresponding data entry for each row. Data for
+  col-hdr-keywords not present in parse-fns-map is returned as a string.  Return value is
+  a sequence of row maps.  "
+  [csv-file]
+  { :pre  [ (string? csv-file) ]
+    :post [ (map? (first %)) ] }
+  (let [data-lines    (csv/parse-csv (slurp csv-file))
+        hdrs-all      (mapv cool-misc/str->kw (first data-lines))
+        data-maps     (for [row (rest data-lines)]
+                        (zipmap hdrs-all row) )
+  ] data-maps ))
+


structure driven crawler its own fn now

structure driven crawler its own fn now

--- src/crawler/main.clj
+++ src/crawler/main.clj
@@ -5,10 +5,19 @@
             [crawler.utils :as utils]
             [crawler.structure-driven :as structure-driven]))

-(defn crawler-options
+(def crawler-options
   [[nil "--structure-driven" "Use the structure driven crawler"]
    [nil "--start" "Entry point for the structure driven crawler"]
    [nil "--example" "Example leaf page url for the structure driven crawler"]])
+
+(defn structure-driven-crawler
+  [start-url example-body]
+  (let [structure-driven-leaf? (fn [x]
+                                 (structure-driven/leaf?
+                                  x example-body))]
+    (crawl/sample-sitemap-lookahead start-url
+                                    structure-driven-leaf?
+                                    structure-driven/extractor)))

 (defn -main
   [& args]
@@ -16,17 +25,10 @@
                     (cli/parse-opts crawler-options)
                     :options)]
     (cond (:structure-driven options)
-          (let [start-url    (-> options :start)
-                example-body (-> options
-                                 :example
-                                 download-with-cookie)
-
-                structure-driven-leaf?     (fn [x]
-                                             (structure-driven/leaf?
-                                              x example-body))]
-            (crawl/sample-sitemap-lookahead start-url
-                                            structure-driven-leaf?
-                                            structure-driven/extractor))
+          (structure-driven-crawler (-> options :start)
+                                    (-> options
+                                        :example
+                                        utils/download-with-cookie))

           :else
           (println "Pick one bruh"))))


Add tests for pattern/top-level?

Add tests for pattern/top-level?

--- test/oxcart/pattern_test.clj
+++ test/oxcart/pattern_test.clj
@@ -37,6 +37,16 @@
   (is (var? (p/def->var foo)))
   (is (var? (p/def->var bar)))
   (is-not (var? (p/def->var fail))))
+
+
+(deftest top-level?-tests
+  (is (p/top-level? foo))
+  (is (p/top-level? bar))
+  (is (p/top-level? fail))
+  (is-not (p/top-level?
+           (-> (ast (let [x 1] (+ x 2)))
+               :body
+               :ret))))

 (def private-defn


Plot learning curve.

Plot learning curve.

--- src/restaurants/core.clj
+++ src/restaurants/core.clj
@@ -57,21 +57,43 @@
                       (map #(remove % dataset)))
         cv          (fn [t v]
                       (let [trained (train model t)
-                            predicted (map (partial predict trained) v)]
-                        (rmse v predicted)))
-        result      (map cv training validation)]
-    (utils/avg result)))
+                            v-predicted (map (partial predict trained) v)
+                            t-predicted (map (partial predict trained) v)]
+                        [(rmse v v-predicted)
+                         (rmse t t-predicted)]))
+        result      (map cv training validation)
+        v-rmse      (utils/avg (map first result))
+        t-rmse      (utils/avg (map second result))]
+    [v-rmse
+     t-rmse
+     (/ t-rmse v-rmse)]))
+
+(defn learning-curve [records model & [point-cnt]]
+  (let [n    (count records)
+        k    5
+        max-point-cnt (int (/ n k))
+        step (int (/ n (min (or point-cnt max-point-cnt) max-point-cnt)))
+        data (map (fn [i]
+                    (conj (cross-validation k (take i records) model) i))
+               (range step (+ n step) step))
+        ds   (incanter.core/dataset ["validation" "training" "%" "n"] data)]
+    (doto
+      (charts/xy-plot :n :validation :data ds)
+      (charts/add-lines (map #(get % 3) data) (map #(get % 1) data))
+      view)))

 (try
   (let [records (load-csv "train.csv")
+        ;;records (shuffle records)
+        ;;records (take 50 records)
         ;;hist    (reduce (partial histogram records) {} (keys (first records)))
         models  {;;:average (avg/->Average nil)
                  ;;:average-by-city-group (avg/->AverageBy :city-group nil)
                  ;;:average-by-city (avg/->AverageBy :city nil)
-                 :average-best (avg/->AverageBest nil)
+                 ;;:average-best (avg/->AverageBest nil)
                  ;;:bagging-avg-best (bag/->Bagging (avg/->AverageBest nil) 10 137)
-                 ;;:regression-tree (dt/->RegressionTree nil)
-                 :bagging-regression-tree (bag/->Bagging (dt/->RegressionTree nil) 5 137)
+                 :regression-tree (dt/->RegressionTree nil)
+                 ;;:bagging-regression-tree (bag/->Bagging (dt/->RegressionTree nil) 5 137)
                  }
         ;;dataset (incanter.core/to-dataset records)
         ]
@@ -80,9 +102,13 @@
         (doto
           (charts/scatter-plot k :revenue :data dataset :group-by :city-group)
           (i/save (str (name k) ".png")))))
-    (doseq [[k model] models]
+    #_(doseq [[k model] models]
       (prn k
         (cross-validation 10 records model)))
+
+    (doseq [[k model] models]
+      (learning-curve records model))
+
     ;;(solution "test.csv" "output.csv" (:regression-tree trained))
     )
   (catch Exception ex


Refine spec macro parsing

Refine spec macro parsing

--- src/spectrace/trace.cljc
+++ src/spectrace/trace.cljc
@@ -29,19 +29,27 @@
                   " must have its own method implementation for spectrace.trace/step*")
              {:spec spec})))

-(defn- resolve-spec [spec]
-  (cond-> spec
-    (keyword? spec) s/form))
+(defn- parse-spec [spec]
+  (let [result (s/conform ::specs/spec (s/form spec))]
+    (if (= result ::s/invalid)
+      ::s/invalid
+      (let [[kind spec] result]
+        spec))))
+
+(defn- conformed-spec [spec]
+  (let [spec' (if (keyword? spec)
+                (parse-spec spec)
+                spec)]
+    (assert (not= spec' ::s/invalid)
+            (str "spec macro " spec " must have its own spec definition"))
+    spec'))

 (defn step [{:keys [spec] :as state} succ fail]
-  (let [spec (resolve-spec spec)]
-    (if (symbol? spec)
-      (succ (assoc state :spec spec) fail)
-      (let [spec' (s/conform ::specs/spec-form spec)]
-        (assert (not= spec' ::s/invalid)
-                (str "spec macro " spec
-                     " must have its own spec definition"))
-        (step* (assoc state :spec spec') succ fail)))))
+  (let [spec (conformed-spec spec)
+        state (assoc state :spec spec)]
+    (if (or (set? spec) (symbol? spec) (keyword? spec))
+      (succ state fail)
+      (step* state succ fail))))

 (defn- with-cont [succ fail ret]
   (if ret
@@ -104,7 +112,7 @@
   (step (assoc state :spec (get-in spec [:args :pred-form])) succ fail))

 (defn- normalize [{:keys [spec path val in]}]
-  (let [spec' (resolve-spec spec)
+  (let [spec' (conformed-spec spec)
         state {:spec spec'
                :path (vec path)
                :val val
@@ -119,7 +127,9 @@
               ret
               (step state
                     (fn [state' fail]
-                      (let [state' (normalize state')]
+                      (let [state' (-> state'
+                                       (update :spec second)
+                                       normalize)]
                         #(rec state' fail (conj ret state'))))
                     (fn [] fail))))]
     (let [state (normalize {:spec spec :path path :val value :in in})]


Mark `return` as alpha

Mark `return` as alpha

--- src/taoensso/carmine.clj
+++ src/taoensso/carmine.clj
@@ -113,8 +113,10 @@
   [& body] `(with-parser (with-meta identity {:raw? true}) ~@body))

 (defn return
-  "Special command that takes any value and returns it unchanged as part of
-  an enclosing `with-conn` pipeline response."
+  "Alpha - subject to change.
+  Special command that takes any value and returns it unchanged as part of
+  an enclosing `with-conn` pipeline response. Ignores any parser in enclosing
+  context."
   [value]
   (swap! (:parser-queue protocol/*context*) conj
          (with-meta (constantly value) {:dummy-reply? true})))


Housekeeping, add support for Double values

--- src/taoensso/faraday.clj
+++ src/taoensso/faraday.clj
@@ -60,10 +60,10 @@
 ;; * Docs.
 ;; * Bench.

-;;;; Database connection/client
+;;;; DynamoDB API objects

 (defn- db-client*
-  "Returns an AmazonDynamoDBClient instance for the supplied IAM credentials."
+  "Returns a new AmazonDynamoDBClient instance for the supplied IAM credentials."
   [{:keys [access-key secret-key endpoint proxy-host proxy-port] :as creds}]
   (let [aws-creds     (BasicAWSCredentials. access-key secret-key)
         client-config (ClientConfiguration.)]
@@ -75,17 +75,13 @@

 (def db-client (memoize db-client*))

-;;;; Coercions ; TODO ?
-
-(defprotocol AsMap (as-map [x]))
-
-(defn- to-long [x] (Long. x))
+(defn- coerce-num [x] (if (.contains x ".") (Double. x) (Long. x)))

 (defn- get-value "Returns the value of an AttributeValue object."
-  [attr-value] ; TODO ?
+  [attr-value]
   (or (.getS attr-value)
-      (some->> (.getN attr-value)  to-long)
-      (some->> (.getNS attr-value) (map to-long) (into #{}))
+      (some->> (.getN attr-value)  coerce-num)
+      (some->> (.getNS attr-value) (map coerce-num) (into #{}))
       (some->> (.getSS attr-value) (into #{}))))

 (defn- key-schema-element "Returns a new KeySchemaElement object."
@@ -126,7 +122,7 @@

   The throughput is a map with two keys:
     :read  - the provisioned number of reads per second
-    :write - the provisioned number of writes per second" ; TODO
+    :write - the provisioned number of writes per second"
   [creds {:keys [name hash-key range-key throughput]}]
   (.createTable
    (db-client creds)
@@ -139,13 +135,15 @@
   "Update a table in DynamoDB with the given name. Only the throughput may be
   updated. The throughput values can be increased by no more than a factor of
   two over the current values (e.g. if your read throughput was 20, you could
-  only set it from 1 to 40). See create-table." ; TODO
+  only set it from 1 to 40). See create-table."
   [creds {:keys [name throughput]}]
   (.updateTable
    (db-client creds)
    (doto (UpdateTableRequest.)
      (.setTableName (str name))
      (.setProvisionedThroughput (provisioned-throughput throughput)))))
+
+(defprotocol AsMap (as-map [x]))

 (extend-protocol AsMap
   KeySchemaElement
@@ -348,7 +346,7 @@
   "Retrieve a batch of items in a single request. DynamoDB limits
    apply - 100 items and 1MB total size limit. Requested items
    which were elided by Amazon are available in the returned map
-   key :unprocessed-keys.
+   key :unprocessed-keys.

    Examples:
    (batch-get-item creds
@@ -367,7 +365,7 @@
   (doto (DeleteRequest.)
     (.setKey (item-key item))))

-(defn- put-request [item]
+(defn- put-request [item]
   (doto (PutRequest.)
     (.setItem
       (into {}
@@ -385,7 +383,7 @@
   "Execute a batch of Puts and/or Deletes in a single request.
    DynamoDB limits apply - 25 items max. No transaction
    guarantees are provided, nor conditional puts.
-
+
    Example:
    (batch-write-item creds
      [:put :users {:user-id 1 :username \"sally\"}]


add google sign in to about menu

add google sign in to about menu

--- src-cljs/frontend/components/overlay.cljs
+++ src-cljs/frontend/components/overlay.cljs
@@ -351,12 +351,10 @@
             (when-not (:cust app)
               (list
                 [:p.make
-                 "Sign up and we'll even keep track of all your docs.
-                 Never lose a great idea again!"]
-                [:a.menu-cta.make
-                 {:href (auth/auth-url :source "username-overlay")
-                  :role "button"}
-                 "Sign Up"]))
+                 "Everyone's ideas made with Precursor save automatically.
+                 And if you sign in with Google we'll even keep track of which ones are yours."]
+                [:div.calls-to-action.make
+                 (om/build common/google-login {:source "Username Menu"})]))
             [:a.vein.make
              {:href "/home"
               :role "button"}


add missing shortcuts

add missing shortcuts

--- src-cljs/frontend/components/overlay.cljs
+++ src-cljs/frontend/components/overlay.cljs
@@ -12,6 +12,7 @@
             [frontend.overlay :refer [current-overlay overlay-visible? overlay-count]]
             [frontend.state :as state]
             [frontend.utils :as utils :include-macros true]
+            [goog.labs.userAgent.browser :as ua]
             [om.core :as om :include-macros true]
             [om.dom :as dom :include-macros true])
   (:require-macros [frontend.utils :refer [html]])
@@ -204,39 +205,56 @@

 (defn shortcuts [app owner]
   (reify
+    om/IInitState (init-state [_] {:copy-paste-works? (ua/isChrome)})
     om/IRender
     (render [_]
       (let [cast! (om/get-shared owner :cast!)]
         (html
-          [:div.menu-view
-           [:div.menu-view-frame
-            [:article
-             [:h2 "Move fast, make things."]
-             [:div.shortcuts-item
-              [:div.shortcuts-key "S"]
-              [:div.shortcuts-result "Select"]]
-             [:div.shortcuts-item
-              [:div.shortcuts-key "R"]
-              [:div.shortcuts-result "Rectangle"]]
-             [:div.shortcuts-item
-              [:div.shortcuts-key "C"]
-              [:div.shortcuts-result "Circle"]]
-             [:div.shortcuts-item
-              [:div.shortcuts-key "L"]
-              [:div.shortcuts-result "Line"]]
-             [:div.shortcuts-item
-              [:div.shortcuts-key "P"]
-              [:div.shortcuts-result "Pen"]]
-             [:div.shortcuts-item
-              [:div.shortcuts-key "T"]
-              [:div.shortcuts-result "Text"]]
-             [:div.shortcuts-item
-              [:div.shortcuts-key "1"]
-              [:div.shortcuts-result "Snap to origin"]]
-             [:div.shortcuts-item
-              [:div.shortcuts-key (common/icon :command)]
-              [:div.shortcuts-key "Z"]
-             [:div.shortcuts-result "Undo"]]]]])))))
+         [:div.menu-view
+          [:div.menu-view-frame
+           [:article
+            [:h2 "Move fast, make things."]
+            [:div.shortcuts-item
+             [:div.shortcuts-key "S"]
+             [:div.shortcuts-result "Select"]]
+            [:div.shortcuts-item
+             [:div.shortcuts-key "R"]
+             [:div.shortcuts-result "Rectangle"]]
+            [:div.shortcuts-item
+             [:div.shortcuts-key "C"]
+             [:div.shortcuts-result "Circle"]]
+            [:div.shortcuts-item
+             [:div.shortcuts-key "L"]
+             [:div.shortcuts-result "Line"]]
+            [:div.shortcuts-item
+             [:div.shortcuts-key "P"]
+             [:div.shortcuts-result "Pen"]]
+            [:div.shortcuts-item
+             [:div.shortcuts-key "T"]
+             [:div.shortcuts-result "Text"]]
+            [:div.shortcuts-item
+             [:div.shortcuts-key "1"]
+             [:div.shortcuts-result "Snap to origin"]]
+            [:div.shortcuts-item
+             [:div.shortcuts-key "?"]
+             [:div.shortcuts-result "Reopen this menu"]]
+            [:div.shortcuts-item
+             [:div.shortcuts-key "Delete"]
+             [:div.shortcuts-result "Delete selected"]]
+            [:div.shortcuts-item
+             [:div.shortcuts-key (common/icon :command)]
+             [:div.shortcuts-key "Z"]
+             [:div.shortcuts-result "Undo"]]
+            (when (om/get-state owner [:copy-paste-works?])
+              (list
+               [:div.shortcuts-item
+                [:div.shortcuts-key (common/icon :command)]
+                [:div.shortcuts-key "C"]
+                [:div.shortcuts-result "Copy"]]
+               [:div.shortcuts-item
+                [:div.shortcuts-key (common/icon :command)]
+                [:div.shortcuts-key "V"]
+                [:div.shortcuts-result "Paste"]]))]]])))))

 (defn username [app owner]
   (reify


extracted next-comp and next-prime

extracted next-comp and next-prime

--- src/euler/helper.clj
+++ src/euler/helper.clj
@@ -129,6 +129,25 @@
                           :while (every? #(< -1 % size) yx)]
                       (reduce nth grid yx))))))

+(defn- next-comp
+  "Update the sieve with the given composite number."
+  [x step sieve]
+  (if (sieve x)
+    ;; the composite number has already been found previously
+    (recur (+ x step) step sieve)
+    ;; brand new composite number
+    (assoc sieve x step)))
+
+(defn- next-prime
+  "Retrieve the next prime number using the given sieve."
+  [x sieve]
+  (let [step (sieve x)]
+    (if (sieve x)
+      ;; found a composite
+      (recur (+ x 2) (next-comp (+ x step) step (dissoc sieve x)))
+      ;; found a prime
+      (cons x (lazy-seq (next-prime (+ x 2) (assoc sieve (* x x) (* x 2))))))))
+
 (def primes
   "**primes :: [Int]**
   Lazy stream of prime numbers, generated by the
@@ -136,22 +155,7 @@
   composite number corresponding to the prime number.
   Taken from http://voidmainargs.blogspot.de/2010/12/
   lazy-sieve-eratosthenes-in-scala-and.html"
-  (letfn [(next-comp [x step sieve]
-            (if (sieve x)
-            ;; the composite number has already been found previously
-              (recur (+ x step) step sieve)
-            ;; brand new composite number
-              (assoc sieve x step)))
-          (next-prime [x sieve]
-            (let [step (sieve x)]
-              (if (sieve x)
-            ;; found a composite
-                (recur (+ x 2) (next-comp (+ x step) step (dissoc sieve x)))
-            ;; found a prime
-                (cons x
-                      (lazy-seq
-                       (next-prime (+ x 2) (assoc sieve (* x x) (* x 2))))))))]
-    (cons 2 (lazy-seq (next-prime 3 {})))))
+  (cons 2 (lazy-seq (next-prime 3 {}))))

 (defn prime?
   "**prime? :: Int -> Bool**


added hsts header everywhere

added hsts header everywhere

--- src/org/zalando/stups/friboo/system/http.clj
+++ src/org/zalando/stups/friboo/system/http.clj
@@ -57,6 +57,13 @@
     (let [response (handler request)]
       (r/header response "Access-Control-Allow-Headers" "Origin, X-Requested-With, Content-Type, Accept, Authorization"))))

+(defn- add-hsts-header
+  "Adds Strict-Transport-Security for https only."
+  [handler]
+  (fn [request]
+    (let [response (handler request)]
+      (r/header response "Strict-Transport-Security" "max-age=10886400"))))
+
 (def default-error
   (json/write-str
     {:message "Internal Server Error"}))
@@ -111,6 +118,7 @@
             get-oauth2-config (fn [] {:tokeninfo-url (require-config configuration :tokeninfo-url)})
             handler (-> (s1st/swagger-context ::s1st/yaml-cp definition)
                         (s1st/swagger-ring add-ip-log-context)
+                        (s1st/swagger-ring add-hsts-header)
                         (s1st/swagger-ring exceptions-to-json)
                         (s1st/swagger-ring health-endpoint)
                         (s1st/swagger-ring wrap-params)


avoid NPE

avoid NPE

--- src/org/zalando/stups/friboo/system/http.clj
+++ src/org/zalando/stups/friboo/system/http.clj
@@ -85,14 +85,15 @@
 (defn map-authorization-header
   "Map 'Token' and 'Basic' Authorization values to standard Bearer OAuth2 auth"
   [authorization]
-  (condp #(.startsWith %2 %1) authorization
-    "Token " (.replaceFirst authorization "Token " "Bearer ")
-    "Basic " (let [basic-auth (parse-basic-auth authorization)]
-               (if (= (:username basic-auth) "oauth2")
-                 (str "Bearer " (:password basic-auth))
-                 ; do not touch Basic auth headers if username is not "oauth2"
-                 authorization))
-  authorization))
+  (when authorization
+    (condp #(.startsWith %2 %1) authorization
+      "Token " (.replaceFirst authorization "Token " "Bearer ")
+      "Basic " (let [basic-auth (parse-basic-auth authorization)]
+                 (if (= (:username basic-auth) "oauth2")
+                   (str "Bearer " (:password basic-auth))
+                   ; do not touch Basic auth headers if username is not "oauth2"
+                   authorization))
+      authorization)))

 (defn map-alternate-auth-header
   "Map alternate Authorization headers to standard OAuth2 'Bearer' auth"


First call to Guess.makeGuess() working

First call to Guess.makeGuess() working

--- src/hangman/core.clj
+++ src/hangman/core.clj
@@ -224,17 +224,19 @@
                                (map str/trim) )
           strategy        (get-strategy)
           hangmanGame     (HangmanGame. "test" 20)
+          _ (println ".nextGuess - call")
+          guess           (.nextGuess strategy hangmanGame)
+          _ (println ".nextGuess - ret")
     ]
       (println "tst-words" tst-words)
-      (println ".nextGuess - call")
-      (.nextGuess strategy hangmanGame)
-      (println ".nextGuess - ret")
+      (println ".makeGuess - call")
+      (.makeGuess guess hangmanGame)
+      (println ".makeGuess - ret")
     )
     (println "driver - exit")
   ))

 (comment
-git@github.com:catalan42/hangman.git
 )

 (def baseline-scores {


apply config twice to check creation and update

--- test/shuppet/integration.clj
+++ test/shuppet/integration.clj
@@ -45,4 +45,5 @@
    (fact "Test config is applied without errors"
          (client/get (url+ "/env/dev/app/test/clean"))
          (client/get (url+ "/env/dev/app/test/apply")) => (contains {:status 200})
+         (client/get (url+ "/env/dev/app/test/apply")) => (contains {:status 200})
          (client/get (url+ "/env/dev/app/test/clean"))))


Update rss.clj

Update rss.clj

--- src/io/perun/rss.clj
+++ src/io/perun/rss.clj
@@ -23,7 +23,7 @@
     rss-str))

 (defn generate-rss [tgt-path files options]
-  (let [rss-filepath (str (:target options) "/" (:filename options))
+  (let [rss-filepath (str (:out-dir options) "/" (:filename options))
         rss-string   (generate-rss-str files options)]
     (perun/create-file tgt-path rss-filepath rss-string)
     (perun/report-info "rss" "generated RSS feed and saved to %s" rss-filepath)))


leiningen.core -> leiningen.core.main in lein 2.x

--- src/appengine_magic/leiningen_helpers.clj
+++ src/appengine_magic/leiningen_helpers.clj
@@ -1,6 +1,6 @@
 (ns appengine-magic.leiningen-helpers
   (:use appengine-magic.utils)
-  (:require [leiningen.core :as lein])
+  (:require [leiningen.core.main :as lein])
   (:import java.io.File
            com.google.appengine.tools.admin.AppCfg
            [org.apache.commons.exec CommandLine DefaultExecutor]))


Fixed blockly editor

Fixed blockly editor

Would not show after showing the text editor

--- idecode/myappshare/mainapp.cljs
+++ idecode/myappshare/mainapp.cljs
@@ -288,10 +288,10 @@
     (div {:style {
                    :display (if (or (= (get-in @app-state [:ui :editor :mode]) "blockly")
                                     (= (get-in @app-state [:ui :editor :mode]) nil))
-                              "display-inline"
+                              "inline-block"
                               "none")

-                   :background "white" :width "100%"  :height "800px" :align "top" :top "100px"  }}
+                   :background2 "white" :width "100%"  :height "800px" :align "top" :top "100px"  }}

@@ -330,12 +330,20 @@
                                         :width          "500px"
                                         :display        "inline-block"}} "")

-         (pre {:id "blocklyCode" :style {:verticalAlign "text-top"
+         (div nil
+               (button {
+                         :onClick (fn[e] (swap! app-state assoc-in [:ui :editor :show-generated-code] true))
+                         :className    (if (small-screen) "btn btn-default" "btn-lg btn-default")} "Show generated code")
+
+         (pre {:id "blocklyCode" :style {:display (if (get-in @app-state [:ui :editor :show-generated-code])
+                                                    ""
+                                                    "none")
+                                         :verticalAlign "text-top"
                                          :background     "white"
                                          :color          "black"
                                          :height         "800px"
                                          :width          "500px"}} ""))))
-
+)

@@ -390,7 +398,7 @@
                         (or (= (get-in @app-state [:ui :editor :mode]) "blockly") (= (get-in @app-state [:ui :editor :mode]) nil))
                         (span {:onClick #(go  (swap! app-state assoc-in [:ui :editor :mode] "text")
                                               (js/setTimeout js/refreshCodeMirror 500)
-                                              (touch [])
+                                              (js/setTimeout (fn [ee] (touch [:ui :editor])) 500)
                                               )} "Blockly | ")
                         )


tweaks

tweaks

--- src/jsx_fun/core.clj
+++ src/jsx_fun/core.clj
@@ -202,6 +202,7 @@

   (try
     (let [cx     (Context/enter)
+          _      (.setLanguageVersion cx 200)
           _      (.setOptimizationLevel cx -1)
           scope  (.initStandardObjects cx)
           source (slurp (io/resource "babel-core/browser.js"))]
@@ -215,6 +216,7 @@
   ;; returns [object Object] in Rhino
   ;; FIXED in my Rhino fork
   (let [cx     (Context/enter)
+        _      (.setLanguageVersion cx 200)
         _      (.setOptimizationLevel cx -1)
         scope  (.initStandardObjects cx)
         source (slurp (io/resource "babel-core/browser.js"))]
@@ -224,6 +226,7 @@

   ;; FIXED in my Rhino fork
   (let [cx     (Context/enter)
+        _      (.setLanguageVersion cx 200)
         _      (.setOptimizationLevel cx -1)
         scope  (.initStandardObjects cx)
         source (slurp (io/resource "babel-core/browser.js"))]
@@ -231,6 +234,7 @@
       "Object.prototype.toString.call(undefined)"
       "<cmd>" 1 nil))

+  ;; undefined
   (let [cx     (Context/enter)
         _      (.setOptimizationLevel cx -1)
         scope  (.initStandardObjects cx)
@@ -244,6 +248,13 @@
         scope  (.initStandardObjects cx)
         source (slurp (io/resource "babel-core/browser.js"))]
     (.evaluateString cx scope
+      "Symbol" "<cmd>" 1 nil))
+
+  (let [cx     (Context/enter)
+        _      (.setOptimizationLevel cx -1)
+        scope  (.initStandardObjects cx)
+        source (slurp (io/resource "babel-core/browser.js"))]
+    (.evaluateString cx scope
       "Object.getOwnPropertyNames"
       "<cmd>" 1 nil))


Remove api_utils.cljs.

Remove api_utils.cljs.

--- src/cljs/cljs_browser_repl/api_utils.cljs
+++ src/cljs/cljs_browser_repl/api_utils.cljs
@@ -1,57 +0,0 @@
-(ns cljs-browser-repl.api-utils)
-
-(defrecord Section [title additional-info topics])
-(defrecord Topic [title symbols])
-
-;;; A map of sections and topics we want to display in our API panel.
-;;; We can easily add or remove sections/topics and they will be automatically
-;;; displayed in the API panel.
-(def custom-api-map
-  {:sections [(Section. "Datatypes" ""
-                        [(Topic. "maps " '({:key1 val1 :key2 val2}))
-                         (Topic. "vectors" '([1 2 3] [:a :b :c]))
-                         (Topic. "sets" '(#{:a :b :c 1 2 3}))
-                         (Topic. "scalars" '(a-symbol :a-keyword "a-string"))
-                         (Topic. "arrays" '((array 1 2 3)))])
-              (Section. "Functions" ""
-                        [(Topic. "calling"
-                                 '("(<FUNCTION> <ARGS*>)"))
-                         (Topic. "defining named functions"
-                                 '("(defn <NAME> [<ARGS*>] |CONSTRAINTS| <ACTIONS*>)"))
-                         (Topic. "anonymous function"
-                                 '("(fn |NAME| [<ARGS*>] |CONSTRAINTS| <ACTIONS*>)"))
-                         (Topic. "anonymous inline funcion"
-                                 '("#(<ACTION> |% %2 %3 OR %&|)"))])
-              (Section. "Useful Macros" ""
-                        [(Topic. "conditionals"
-                                 '(if if-let cond condp and or when when-let))
-                         (Topic. "nesting, chaining, and interop"
-                                 '(-> ->> doto .. .))
-                         (Topic. "defining things"
-                                 '(def defn fn let binding defmulti defmethod
-                                   deftype defrecord reify this-as))])
-              (Section. "Useful Functions" ""
-                        [(Topic. "math"
-                                 '(+ - * / quot rem mod inc dec max min))
-                         (Topic. "comparison"
-                                 '(= == not= < > <= >=))
-                         (Topic. "predicates"
-                                 '(nil? identical? zero? pos? neg? even? odd? true? false?))
-                         (Topic. "data processing"
-                                 '(map reduce filter partition split-at split-with))
-                         (Topic. "data create"
-                                 '(vector vec hash-map set for list list*))
-                         (Topic. "data inspection"
-                                 '(first rest get get-in keys vals count get nth contains? find))
-                         (Topic. "data manipulation"
-                                 '(seq into conj cons assoc assoc-in dissoc zipmap
-                                   merge merge-with select-keys update-in))
-                         (Topic. "arrays"
-                                 '(first rest get get-in keys vals count get nth contains? find))])
-              (Section. "JavaScript Interop" ""
-                        [(Topic. "method call" '("(.the-method target-object args...)"))
-                         (Topic. "property access" '("(.-property target-object -property)"))
-                         (Topic. "property setting" '("(set! (.-title js/document) \"Hi!\")"))
-                         (Topic. "direct javascript" '("(js/alert \"Hello scalac!\")"))
-                         (Topic. "external library use" '("(.text (js/jQuery \"#title\") \"ClojureScript Rocks!\")"))])]
-})


Hide modal dialogs after update happened. This way it can be used as indicator that update happened.

--- src/cljs/hatnik/web/client/z_actions.cljs
+++ src/cljs/hatnik/web/client/z_actions.cljs
@@ -36,14 +36,14 @@

 (defn common-update-callback [msg data response]
   (when (= "ok" (get response "result"))
+    (state/update-all-view)
     (.modal ($ :#iModalAddAction) "hide")
-    (.modal ($ :#iModalProjectMenu) "hide")
-    (state/update-all-view)))
+    (.modal ($ :#iModalProjectMenu) "hide")))

 (defn create-new-project-callback [name response]
   (when (= "ok" (get response "result"))
-    (.modal ($ :#iModalProjectMenu) "hide")
-    (state/update-all-view)))
+    (state/update-all-view)
+    (.modal ($ :#iModalProjectMenu) "hide")))

 (defn send-new-project-request [name]
   (if (s/check schm/Project {:name name})
@@ -52,8 +52,8 @@

 (defn create-new-action-callback [data response]
   (when (= "ok" (get response "result"))
-    (.modal ($ :#iModalAddAction) "hide")
-    (state/update-all-view)))
+    (state/update-all-view)
+    (.modal ($ :#iModalAddAction) "hide")))

 (defn build-email-action [data-pack]
   {:project-id (:project-id data-pack)
@@ -136,14 +136,12 @@
              #(common-update-callback action-update-error-message data %))))))

 (defn delete-action [action-id]
-  (.modal ($ :#iModalAddAction) "hide")
   (ajax
    (str "/api/actions/" action-id) "DELETE"
    {} (wrap-error-alert
        #(common-update-callback "Couldn't delete the action. Please file a bug if the issue persists." {} %))))

 (defn ^:export delete-project [project-id]
-  (.modal ($ :#iModalProjectMenu) "hide")
   (ajax
    (str "/api/projects/" project-id) "DELETE"
    {} (wrap-error-alert


check if component still exists when returning from data fetch (#1022)

--- src/cljs/main/broadfcui/common/table.cljs
+++ src/cljs/main/broadfcui/common/table.cljs
@@ -76,12 +76,15 @@
                      :tab (some-> (:tabs props) :items (get (:selected-tab-index @state)))
                      :query-params query-params
                      :on-done (fn [{:keys [total-count tab-count filtered-rows results]}]
-                                ((@refs "blocker") :hide)
-                                (swap! state merge
-                                       {:data-test-state "ready"
-                                        :rows results
-                                        :tab-count (or tab-count total-count)}
-                                       (utils/restructure total-count filtered-rows query-params)))})))
+                                (when-let [blocker (@refs "blocker")]
+                                  ;; blocker disappearing means that the Table was unmounted while
+                                  ;; this function was running, so just ignore the result.
+                                  (blocker :hide)
+                                  (swap! state merge
+                                         {:data-test-state "ready"
+                                          :rows results
+                                          :tab-count (or tab-count total-count)}
+                                         (utils/restructure total-count filtered-rows query-params))))})))
    :get-default-props
    (fn []
      {:load-on-mount true})
@@ -229,4 +232,4 @@
         (when-let [tabs (:tabs props)]
           {:selected-tab-index (or (some-> (:initial-selection tabs) (utils/first-matching-index (:items tabs)))
                                    0)})
-        (when-let [v (:v props)] {:v v}))))})+        (when-let [v (:v props)] {:v v}))))})


Use reify instead defrecord for token and signed token backend.

--- src/clojure/buddy/auth/backends/token.clj
+++ src/clojure/buddy/auth/backends/token.clj
@@ -30,46 +30,42 @@
               matches     (re-find pattern auth-header)]
     (get matches 1)))

-(defrecord SignedTokenBackend [pkey unauthorized-handler max-age]
-  proto/Authentication
-  (parse [_ request]
-    (parse-authorization-header request))
-  (authenticate [_ request data]
-    (assoc request :identity (loads data pkey {:max-age max-age})))
-
-  proto/Authorization
-  (handle-unauthorized [_ request metadata]
-    (if unauthorized-handler
-      (unauthorized-handler request metadata)
-      (if (authenticated? request)
-        (-> (response "Permission denied")
-            (status 403))
-        (-> (response "Unauthorized")
-            (status 401))))))
-
-(defrecord TokenBackend [authfn unauthorized-handler]
-  proto/Authentication
-  (parse [_ request]
-    (parse-authorization-header request))
-  (authenticate [_ request token]
-    (let [rsq (when authfn (authfn request token))]
-      (if (response? rsq) rsq
-        (assoc request :identity rsq))))
-
-  proto/Authorization
-  (handle-unauthorized [_ request metadata]
-    (if unauthorized-handler
-      (unauthorized-handler request metadata)
-      (if (authenticated? request)
-        (-> (response "Permission denied")
-            (status 403))
-        (-> (response "Unauthorized")
-            (status 401))))))
-
 (defn signed-token-backend
   [& [{:keys [privkey unauthorized-handler max-age]}]]
-  (->SignedTokenBackend privkey unauthorized-handler max-age))
+  (reify
+    proto/Authentication
+    (parse [_ request]
+      (parse-authorization-header request))
+    (authenticate [_ request data]
+      (assoc request :identity (loads data pkey {:max-age max-age})))
+
+    proto/Authorization
+    (handle-unauthorized [_ request metadata]
+      (if unauthorized-handler
+        (unauthorized-handler request metadata)
+        (if (authenticated? request)
+          (-> (response "Permission denied")
+              (status 403))
+          (-> (response "Unauthorized")
+              (status 401)))))))

 (defn token-backend
   [& [{:keys [authfn unauthorized-handler]}]]
-  (->TokenBackend authfn unauthorized-handler))
+  (reify
+    proto/Authentication
+    (parse [_ request]
+      (parse-authorization-header request))
+    (authenticate [_ request token]
+      (let [rsq (when authfn (authfn request token))]
+        (if (response? rsq) rsq
+            (assoc request :identity rsq))))
+
+    proto/Authorization
+    (handle-unauthorized [_ request metadata]
+      (if unauthorized-handler
+        (unauthorized-handler request metadata)
+        (if (authenticated? request)
+          (-> (response "Permission denied")
+              (status 403))
+          (-> (response "Unauthorized")
+              (status 401)))))))


Update for new lifecycles.

Update for new lifecycles.

--- test/onyx/helper_env.clj
+++ test/onyx/helper_env.clj
@@ -1,6 +1,5 @@
 (ns onyx.helper-env
   (:require [clojure.core.async :refer [chan >!! <!! close! sliding-buffer go-loop]]
-            [onyx.peer.task-lifecycle-extensions :as l-ext]
             [taoensso.timbre :refer [fatal] :as timbre]
             [onyx.extensions :as extensions]
             [com.stuartsierra.component :as component]
@@ -36,7 +35,7 @@
       (doseq [v-peer v-peers]
         (remove-peer component v-peer))))

-  (run-job [component {:keys [workflow catalog task-scheduler] :as job}]
+  (run-job [component {:keys [workflow catalog lifecycles task-scheduler] :as job}]
     (let [n-peers-required (count (distinct (flatten workflow)))
           n-peers (count @(:v-peers component))]
       (when (< n-peers n-peers-required)
@@ -46,6 +45,7 @@
     (onyx.api/submit-job (:peer-config component)
                          {:workflow workflow
                           :catalog catalog
+                          :lifecycles lifecycles
                           :task-scheduler task-scheduler}))

   component/Lifecycle


something is working

something is working

--- src/llvm/library.clj
+++ src/llvm/library.clj
@@ -1,12 +1,9 @@
 (ns llvm.library
-  (:require [clojure.java.shell :refer [sh]]
-            [clojure.string     :refer [trim]])
   (:import jnr.ffi.LibraryLoader llvm.LLVMWrapper))

 (def llvm-library
-  (let [libdir (-> (sh "llvm-config" "--libdir") :out trim)]
-    (delay
-      (-> llvm.LLVMWrapper
-        LibraryLoader/create
-        (.search libdir)
-        (.load "LLVM-3.2")))))
+  (delay
+    (-> llvm.LLVMWrapper
+      LibraryLoader/create
+      (.search "llvm")
+      (.load "LLVM-3.2"))))


interpose docstring

interpose docstring

--- src/main/clojure/rx/lang/clojure/core.clj
+++ src/main/clojure/rx/lang/clojure/core.clj
@@ -532,6 +532,11 @@
        (concat*)))

 (defn interpose
+  "Returns an Observable of the elements of xs separated by sep
+
+  See:
+    clojure.core/interpose
+  "
   [sep xs]
   (let [op (operator* (fn [o]
                         (let [first? (atom true)]


Default to on for now for green tests.

Default to on for now for green tests.

--- src/midje/config.clj
+++ src/midje/config.clj
@@ -34,7 +34,7 @@
   *config* {:print-level :print-normally
             :visible-deprecation true
             :visible-future true
-            :visible-failure-namespaces false
+            :visible-failure-namespace true
             :partial-prerequisites false
             :check-after-creation true
             :emitter 'midje.emission.plugins.default


have interactive

have interactive

--- src/nonaga/draw.cljs
+++ src/nonaga/draw.cljs
@@ -36,6 +36,9 @@
 (defn draw [shape coords]
   (map (comp shape hex->svg) coords))

+(defn draw-marbles [color coords click]
+  (map #(marble color (click color %1) %2) coords (map hex->svg coords)))
+
 (def light-colors
   {"red" "pink"
    "blue" "lightblue"})
@@ -47,19 +50,24 @@
         (draw (partial marble (light-colors (name color)))
               (b/valid-destinations state selected))))))

+(defn start-marble-move [component color coord]
+  (fn []
+    (let [state (assoc (.-wrapper (.-state component)) :event [:marble-move color coord])]
+      (.setState component #js {:wrapper state}))))
+
 (def board
   (create-class
     "getInitialState"
-    (fn [] (assoc n/initial-game :event [:marble-move :red [1 4]]))
+    (fn [] #js {:wrapper n/initial-game})
     "render"
     (fn []
       (this-as this
-         (let [state (aget this "state")]
+         (let [state (.-wrapper (.-state this))]
            (svg {}
-             (draw ring (:rings state))
-             (draw (partial marble "red") (:whites state))
-             (draw (partial marble "blue") (:blacks state))
-             (draw-valid-marble-moves state)))))))
+                (draw ring (:rings state))
+                (draw-marbles "red"  (:whites state) (partial start-marble-move this))
+                (draw-marbles "blue" (:blacks state) (partial start-marble-move this))
+                (draw-valid-marble-moves state)))))))

 (defn start []
   (render-component (board) (sel1 :#content)))


allow submit of child with pregnancy result

--- src/ohds/handler.clj
+++ src/ohds/handler.clj
@@ -124,12 +124,17 @@
    :collectionDateTime s/Str
    :collectedByUuid s/Str})

+(s/defschema ChildRequest
+  {:firstName s/Str
+   :extId s/Str
+   :gender s/Str})
+
 (s/defschema PregnancyResultRequest
   {:type s/Str
    :pregnancyOutcome s/Str
-   :child s/Str ;;; TOOD: is this optional?
-   :collectionDateTime s/Str
-   :collectedByUuid s/Str})
+   :collectionDateTime s/Str
+   :collectedByUuid s/Str
+   (s/optional-key :child) ChildRequest})

 (s/defschema LocationHierarchyRequest
   {:level s/Str
@@ -338,8 +343,22 @@
           :summary "Create new pregnancy result event"
           :return (s/maybe s/Str)
           :body [request PregnancyResultRequest]
-          (ok-or-400 (census/create
-                      (census/map->PregnancyResult request)))))
+          (if (:child request)
+            (let [child (merge (:child request)
+                               (select-keys request [:collectionDateTime
+                                                     :collectedByUuid]))
+                  child-id  (census/create
+                             (census/map->Individual child))
+                  child-request (assoc request :child child-id)]
+              (println "***" child)
+              (println "***" child-id)
+              (println "***" child-request)
+              (if child-id
+                (ok-or-400 (census/create
+                            (census/map->PregnancyResult child-request)))
+                (bad-request)))
+            (ok-or-400 (census/create
+                        (census/map->PregnancyResult request))))))

       (context "/visit" []
         (POST "/" []


change initial state of atom

change initial state of atom

--- src/background_on/web.clj
+++ src/background_on/web.clj
@@ -7,7 +7,7 @@
             [background-on.nyt :as nyt])
   (:gen-class))

-(def snapshot-json-atom (atom {}))
+(def snapshot-json-atom (atom ""))

 (defroutes app-routes
   (GET "/snapshot" [] @snapshot-json-atom)


Ste - Refactors anoymous function to seperate function

--- src/cctray_clj/parser.clj
+++ src/cctray_clj/parser.clj
@@ -9,9 +9,12 @@
   (let [split-name (split name #"\s::\s")]
     {:name (first split-name) :pipeline (second split-name) :stage (last split-name)}))

+(defn extract-attributes [data]
+  (if (= (:tag data) :Project)
+    (merge (:attrs data) (extract-name (get-in data [:attrs :name])))))
+
 (defn get-projects [url]
   (let [content (:content (to-map url))]
     (remove nil? (map
-                   #(if (= (:tag %) :Project)
-                     (merge (:attrs %) (extract-name (get-in % [:attrs :name]))))
+                   #(extract-attributes %)
                    content))))


Work around null memorysize_mb on Amazon Linux

--- src/clj/runbld/system.clj
+++ src/clj/runbld/system.clj
@@ -3,6 +3,7 @@
             [schema.core :as s])
   (:require [clj-yaml.core :as yaml]
             [clojure.java.shell :as sh]
+            [clojure.java.io :as io]
             [environ.core :as environ]
             [runbld.opts :as opts]
             [schema.core :as s]
@@ -23,13 +24,42 @@
       (throw+ {:warning ::no-facter
                :msg "facter cannot be found in PATH"}))))

+(defn find-ram-mb
+  "Hack until we can fix our facter versions, or get it to always
+  return memory info"
+  [facts]
+  (if (:memorysize_mb facts)
+    (Float/parseFloat
+     (:memorysize_mb facts))
+    (let [meminfo "/proc/meminfo"]
+      (if (and (= (:kernel facts) "Linux")
+               (.exists (io/file meminfo)))
+        (let [memtotal-raw (:out
+                            (sh/sh "fgrep" "MemTotal" meminfo))
+              [_ kb] (or (re-find #"^MemTotal: +(\d+) kB" memtotal-raw)
+                         (throw+ {:type ::error
+                                  :msg (format
+                                        "can't get memtotal from meminfo:\n%s"
+                                        (with-out-str
+                                          (println memtotal-raw)
+                                          (clojure.pprint/pprint facts)))}))]
+          (float (/ (Integer/parseInt kb) 1024)))
+        (throw+ {:type ::error
+                 :msg (format "can't get memory info from:\n%s"
+                              (with-out-str
+                                (clojure.pprint/pprint facts)))})))))
+
+(defn memory-details [facts]
+  (let [ram-mb (find-ram-mb facts)
+        ram-gb (.setScale
+                (bigdec (/ ram-mb 1024)) 2
+                java.math.BigDecimal/ROUND_HALF_UP)]
+    {:ram-mb ram-mb
+     :ram-gb ram-gb}))
+
 (s/defn inspect-system :- BuildSystem
   ([facter-fn :- clojure.lang.IFn]
    (let [facts (facter-fn)
-         ram-mb (Float/parseFloat (:memorysize_mb facts))
-         ram-gb (.setScale
-                 (bigdec (/ ram-mb 1024)) 2
-                 java.math.BigDecimal/ROUND_HALF_UP)
          ipv6 (:ipaddress6 facts)]
      (merge
       {:arch           (:architecture            facts)
@@ -43,13 +73,12 @@
        :model          (:hardwaremodel           facts)
        :os             (:operatingsystem         facts)
        :os-version     (:operatingsystemrelease  facts)
-       :ram-mb         ram-mb
-       :ram-gb         ram-gb
        :timezone       (:timezone                facts)
        :uptime-days    (:uptime_days             facts)
        :uptime-secs    (:uptime_seconds          facts)
        :uptime         (:uptime                  facts)
        :virtual        (:is_virtual              facts)}
+      (memory-details facts)
       (when ipv6
         {:ipv6 ipv6})))))


print version

print version

--- src/clj_opengrok/core.clj
+++ src/clj_opengrok/core.clj
@@ -18,7 +18,8 @@
    ["-q" "--quiet" "search, does not show page."]
    ["-i" "--ignore file-ext" "index, *.o:*.class:*.zip:.svn:target"]
    ["-s" "--src-root path" "index, source root path"]
-   ["-e" "--project" "index, enable projects"]])
+   ["-e" "--project" "index, enable projects"]
+   ["-v" "--version"]])

 (defn usage [options-summary]
   (string/join
@@ -45,11 +46,14 @@
   (println msg)
   (System/exit status))

+(defn version []
+  (str "clj-opengrok v" (System/getProperty "clj-opengrok.version")))
+
 (defn -main [& args]
   (let [{:keys [options arguments errors summary]}
         (parse-opts args cli-options)]
     (cond
-      (:help options) (exit 0 (usage summary))
+      (:version options) (exit 0 (version))
       (not= (count arguments) 1) (exit 1 (usage summary))
       errors (exit 1 (error-msg errors)))
     (case (first arguments)


String and Number literals are now objects

This includes adding host methods to get the regular Clojure values
back for use.

--- src/clojure_ruby/core.clj
+++ src/clojure_ruby/core.clj
@@ -23,17 +23,41 @@

 (def variables (atom {}))

+(defn host-send [obj method-sym & args]
+  (if-let [meth (get-in obj [:host-methods method-sym])]
+    (apply meth obj args)
+    (throw (RuntimeException. (str "object " obj " does not have host method " method-sym)))))
+
+(defn rb-send [obj method-name args]
+  (if-let [meth (get-in obj [:methods method-name])]
+    (apply meth obj args)
+    (throw (RuntimeException. (str "Object " obj " does not have method " method-name)))))
+
+(defn create-number [n]
+  {:data n
+   :methods {"<" (fn number-lt [this other]
+                   (let [other (host-send other :number)]
+                     (< (:data this) other)))}
+   :host-methods {:number (fn number-host-number [this] (:data this))}})
+
 (defn create-string [s]
   {:data s
-   :methods {"size" (fn string-size [this] (count (:data this)))}})
+   :methods {"size" (fn string-size [this]
+                      (create-number (count (:data this))))}
+   :host-methods {:string (fn string-host-string [this] (:data this))}})

 (def Array
-  {:methods {"new" (fn Array-new [this cnt val] (atom (vec (repeat cnt val))))}})
+  {:methods {"new" (fn Array-new [this cnt val]
+                     (let [cnt (host-send cnt :number)
+                           val (host-send val :number)]
+                       (atom (vec (repeat cnt val)))))}})

 (swap! variables assoc "Array" Array)

 (def File
-  {:methods {"read" (fn File-read [this name] (create-string (slurp name)))}})
+  {:methods {"read" (fn File-read [this name]
+                      (let [name (host-send name :string)]
+                        (create-string (slurp name))))}})

 (swap! variables assoc "File" File)

@@ -43,11 +67,6 @@
   (let [[_ name val] stmt
         val (evaluate val)]
     (swap! variables assoc name val)))
-
-(defn rb-send [obj method-name args]
-  (if-let [meth (get-in obj [:methods method-name])]
-    (apply meth obj args)
-    (throw (RuntimeException. (str "Object " obj " does not have method " method-name)))))

 (defmethod evaluate :var_ref [stmt]
   (let [[_ name] stmt]
@@ -63,11 +82,11 @@

 (defmethod evaluate :number [stmt]
   (let [[_ val] stmt]
-    (Long. val)))
+    (create-number (Long. val))))

 (defmethod evaluate :string [stmt]
   (let [[_ val] stmt]
-    val))
+    (create-string val)))

 (defmethod evaluate :while [stmt]
   (let [[_ predicate & body] stmt


Implement hash-attrs via group-by

Implement hash-attrs via group-by

--- src/datascript/query.cljc
+++ src/datascript/query.cljc
@@ -281,14 +281,17 @@
         (list* #?(:cljs (.map getters #(% tuple))
                   :clj  (to-array (map #(% tuple) getters))))))))

+(defn -group-by
+  [f init coll]
+  (persistent!
+   (reduce
+    (fn [ret x]
+      (let [k (f x)]
+        (assoc! ret k (conj (get ret k init) x))))
+    (transient {}) coll)))
+
 (defn hash-attrs [key-fn tuples]
-  (loop [tuples     tuples
-         hash-table (transient {})]
-    (if-some [tuple (first tuples)]
-      (let [key (key-fn tuple)]
-        (recur (next tuples)
-               (assoc! hash-table key (conj (get hash-table key '()) tuple))))
-      (persistent! hash-table))))
+  (-group-by key-fn '() tuples))

 (defn hash-join [rel1 rel2]
   (let [tuples1       (:tuples rel1)


Do docstrings a little better

Do docstrings a little better

--- src/detritus/variants.clj
+++ src/detritus/variants.clj
@@ -111,11 +111,15 @@
                                  :tag/members  kw-members
                                  :tag/tag      kw-tag)]
     `(do (def ~vname
+           ~?docstring
            (quote ~(merge ?attr-map ?pre-map)))
-         (defn ~(symbol (str "->" (name vname))) ~?docstring ~?attr-map ~members
+         (defn ~(symbol (str "->" (name vname)))
+           ~(str "Generated constructor for the " ~vname " type.")
+           ~?attr-map ~members
            ~?pre-map
            (->ATaggedVal ~kw-tag (hash-map ~@(interleave kw-members members))))
          (defn ~(symbol (str (name vname) "?"))
+           ~(str "Generated predicate for the " ~vname " type.")
            ([x#]
             (and (tagged? x#)
                  (= ~kw-tag (tag x#))


:bug: Fix text shape edition mode.

:bug: Fix text shape edition mode.

--- frontend/src/uxbox/main/ui/shapes/text.cljs
+++ frontend/src/uxbox/main/ui/shapes/text.cljs
@@ -39,30 +39,25 @@
 (declare text-shape-wrapper)
 (declare text-shape-edit)

-(mf/def text-component
-  :mixins [mf/memo mf/reactive]
-  :render
-  (fn [own {:keys [shape] :as props}]
-    (let [{:keys [id x1 y1 content group]} shape
-          modifiers (mf/react (refs/selected-modifiers id))
-          selected (mf/react refs/selected-shapes)
-          edition? (= (mf/react refs/selected-edition) id)
-          selected? (and (contains? selected id)
-                         (= (count selected) 1))
-          shape (assoc shape :modifiers modifiers)]
-      (letfn [(on-mouse-down [event]
-                (handle-mouse-down event shape selected))
-              (on-double-click [event]
-                ;; TODO: handle grouping event propagation
-                ;; TODO: handle actions locking properly
-                (dom/stop-propagation event)
-                (st/emit! (udw/start-edition-mode id)))]
-        [:g.shape {:class (when selected? "selected")
-                   :on-double-click on-double-click
-                   :on-mouse-down on-mouse-down}
-         (if edition?
-           [:& text-shape-edit {:shape shape}]
-           [:& text-shape-wrapper {:shape shape}])]))))
+(mf/defc text-component
+  [{:keys [shape] :as props}]
+  (let [{:keys [id x1 y1 content group]} shape
+        selected (mf/deref refs/selected-shapes)
+        edition (mf/deref refs/selected-edition)
+        edition? (= edition id)
+        selected? (and (contains? selected id)
+                       (= (count selected) 1))]
+    (letfn [(on-mouse-down [event]
+              (handle-mouse-down event shape selected))
+            (on-double-click [event]
+              (dom/stop-propagation event)
+              (st/emit! (udw/start-edition-mode id)))]
+      [:g.shape {:class (when selected? "selected")
+                 :on-double-click on-double-click
+                 :on-mouse-down on-mouse-down}
+       (if edition?
+         [:& text-shape-edit {:shape shape}]
+         [:& text-shape-wrapper {:shape shape}])])))

 ;; --- Text Styles Helpers


println already concatenates strings for you putting a space among then

--- src/engine_server/web.clj
+++ src/engine_server/web.clj
@@ -29,7 +29,7 @@
       (on-close channel (fn [status]
         (let [game (find-or-create-game id)
           player (:player (@clients channel))]
-          (println (str "Closing channel! :( Player " player " gave up"))
+          (println "Closing channel! :( Player" player "gave up")
           (swap! games assoc id (remove-player-from-game game player))
           (swap! clients dissoc channel) )))
       (future (loop []


ensure dev mode load info is properly set when using shadow.loader

its set by the "index" files which the loader doesn't actually
load since it loads the parts directly.

fixes #452

--- src/main/shadow/build/targets/browser.clj
+++ src/main/shadow/build/targets/browser.clj
@@ -15,6 +15,7 @@
             [shadow.build.config :as config]
             [shadow.build.output :as output]
             [shadow.build.closure :as closure]
+            [shadow.build.modules :as modules]
             [shadow.build.data :as data]
             [shadow.build.log :as log]
             [shadow.core-ext :as core-ext]
@@ -249,7 +250,7 @@
       modules)))

 (defn configure-modules
-  [{:keys [worker-info] :as state} mode {:keys [modules module-loader] :as config}]
+  [state mode config]
   (let [modules (rewrite-modules state mode config)]
     (build-api/configure-modules state modules)))

@@ -300,7 +301,7 @@
         )))

 (defn flush-manifest
-  [{:keys [build-options] :as state} include-foreign?]
+  [{:keys [build-options] :as state}]
   (let [data
         (->> (or (::closure/modules state)
                  (:build-modules state))
@@ -390,6 +391,23 @@
       (->> optimized
            (map #(hash-optimized-module % state module-hash-names))
            (into [])))))
+
+;; in case the module is loaded by shadow.loader and not via its generated index file
+(defn append-module-sources-set-loaded-calls [{:keys [build-modules] :as state}]
+  (reduce
+    (fn [state {:keys [module-id sources] :as mod}]
+      (let [set-loaded-info
+            (->> sources
+                 (map #(get-in state [:sources %]))
+                 (map #(str "SHADOW_ENV.setLoaded(" (pr-str (:output-name %)) ");"))
+                 (str/join "\n"))
+
+            append-id
+            [::modules/append module-id]]
+
+        (update-in state [:sources append-id :source] str ";\n" set-loaded-info)))
+    state
+    build-modules))

 (defn inject-loader-setup-dev
   [state config]
@@ -649,7 +667,7 @@
           (-> (inject-loader-setup-dev config)
               (flush-module-data)))
         (flush-unoptimized)
-        (flush-manifest false))
+        (flush-manifest))
     :release
     (-> state
         ;; must hash before adding loader since it needs to know the final uris of the modules
@@ -670,7 +688,7 @@
         (cond->
           module-loader
           (flush-module-data))
-        (flush-manifest true))))
+        (flush-manifest))))

@@ -780,6 +798,8 @@
     (-> state
         ;; (maybe-inject-cljs-loader-constants mode config)
         (cond->
+          (and (= :dev mode) (> (count (:modules config)) 1))
+          (append-module-sources-set-loaded-calls)
           ;; only set this if any :shadow-js is used otherwise closure will complain
           (get-in state [:sym->id 'shadow.js])
           (assoc-in [:compiler-options :closure-defines 'shadow.js.process.browser] true)


Pass correct params to teardown

Pass correct params to teardown

--- src/matchmaker_sparql/evaluation/core.clj
+++ src/matchmaker_sparql/evaluation/core.clj
@@ -16,4 +16,4 @@
            (->> limits-and-offsets
                 (map (partial fold/run-fold evaluation-params))
                 (metrics/aggregate-evaluation-metrics evaluation-params)))
-         (finally (teardown/teardown-evaluation params)))))
+         (finally (teardown/teardown-evaluation evaluation-params)))))


.lein/profiles add old PC stuff

.lein/profiles add old PC stuff

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -5,6 +5,9 @@
                        [spyscope "0.1.4"] ;; reader macro to print forms before execution: #spy/p, d
                        [difform "1.1.2"] ;; diff of clj data structures
                        [clj-ns-browser "1.3.1"]
+                       [nrepl-inspect "0.4.1"]    ; for wrap-inspect, Emacs
+                       [ritz/ritz-nrepl-middleware "0.7.0"]
+                       [night-vision "0.1.0-SNAPSHOT"] ;; print input/output of each call in a ns; see (night-vision.goggles/introspect-ns! '<your ns>)
                        ]
         ;; "Copy" the given function to clojure.core (and thus all namespaces), prefixed with > => (>doc ..)
         :injections [(require 'vinyasa.inject) ;; TODO check also vinyasa/pull, lein, reimport
@@ -17,7 +20,27 @@
                          [alex-and-georges.debug-repl debug-repl]
                          [com.georgejahad.difform difform]
                          [clj-ns-browser.sdoc sdoc]])
-                     (require 'spyscope.core)]
+                     (require 'spyscope.core)
+                     (require 'night-vision.goggles)]
         :plugins [
+                  [lein-catnip "0.5.1"]
+                  ;;[codox "0.6.1"]                     ; document. generation from src
+                  [lein-ring "0.8.10"]
+                  ;;[lein-noir "1.2.1"]                 	; deprecated, use compojure + noir lib
+                  [lein-droid "0.2.2"]       	; for Android; !! req. JDK 6 as of 5/2013 !!!
+                  [lein-ritz "0.7.0"]   		; for nrepl-inspect
+                  [lein-marginalia "0.7.1"]
                   [lein-ancient "0.5.4"]
-                  [lein-try "0.4.1"]]}}+                  [lein-try "0.4.1"]
+                  [lein-alembic "0.1.0"]     ; make alembic available -> reload prj deps w/o restarting repl: (alembic.still/load-project)
+                  [lein-clojuredocs "1.0.2"] ; Create clojuredocs-style doc
+                  [quickie "0.2.6"] ; autotest for clojure.test
+                  [lein-light "0.0.44"] ; LightTable: `lein light` in a prj
+                  ]}
+       :repl-options {:nrepl-middleware
+                       [
+                        ;inspector.middleware/wrap-inspect
+                        ritz.nrepl.middleware.javadoc/wrap-javadoc
+                        ritz.nrepl.middleware.apropos/wrap-apropos
+                        ritz.nrepl.middleware.simple-complete/wrap-simple-complete]}
+ }


Update lein plugins versions

Update lein plugins versions

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -1,18 +1,18 @@
 {
  :user {
   :plugins [
-    [cider/cider-nrepl "0.13.0"]
-    [lein-cljfmt "0.5.6"]
+    [cider/cider-nrepl "0.15.1"]
+    [lein-cljfmt "0.5.7"]
     [lein-pprint "1.1.2"]
     [lein-assoc "0.1.0"]
     [lein-cloverage "1.0.9"]
-    [venantius/ultra "0.5.0"]
-    [jonase/eastwood "0.2.3" :exclusions [org.clojure/clojure]]
+    [venantius/ultra "0.5.1"]
+    [jonase/eastwood "0.2.5" :exclusions [org.clojure/clojure]]
     [lein-expectations "0.0.8"]
     [lein-autoexpect "1.9.0"]
     [com.jakemccrary/lein-test-refresh "0.14.0"]
-    [lein-ancient "0.6.10"]
-    [lein-nvd "0.2.3"]]
+    [lein-ancient "0.6.14"]
+    [lein-nvd "0.4.0"]]
   :repl-options {
     :timeout 300000}
   :aliases {