Fix backspace deleting the wrong item in Selectable

--- src/main/om_mantras/selectable.cljs
+++ src/main/om_mantras/selectable.cljs
@@ -95,7 +95,6 @@

   (update-selected [this items]
     (om/update-state! this assoc :selected items)
-    (.update-caret this (:caret (om/get-state this)))
     (some-> this om/props :change-fn (apply [items])))

   (select-match [this match]
@@ -106,37 +105,49 @@
         (->> (concat before [match] after)
              (into [])
              (.update-selected this)))
-      (.update-caret this (-> this om/get-state :caret inc))
+      (.update-caret this inc)
       (.update-text this "")))

   (show-matches [this show?]
     (om/update-state! this assoc :show-matches show?))

   (focus [this e]
-    (-> this (om/react-ref :input/box) (om/react-ref :input/input) dom/node .focus)
+    (-> this
+        (om/react-ref :input/box)
+        (om/react-ref :input/input)
+        dom/node
+        .focus)
     (.show-matches this true))

   (set-active-match [this child]
     (om/update-state! this assoc :active-match (-> child om/props :item)))

-  (update-caret [this position]
+  (update-caret [this f]
     (let [selected (:selected (om/get-state this))]
-      (->> (max 0 (min (count selected) position))
-           (om/update-state! this assoc :caret))))
+      (om/update-state! this update :caret
+                        (fn [caret]
+                          (-> (f caret)
+                              (max 0)
+                              (min (count selected)))))))

   (key-backspace [this e]
     (when (empty? (:text (om/get-state this)))
-      (let [selected (->> this om/get-state :selected butlast (into []))]
-        (.update-selected this selected))
-      (.update-text this "")))
+      (let [selected (:selected (om/get-state this))
+            caret (:caret (om/get-state this))]
+        (let [[before after] (split-at caret selected)]
+          (->> (concat (butlast before) after)
+               (into [])
+               (.update-selected this)))
+        (.update-caret this dec)
+        (.update-text this ""))))

   (key-left [this e]
     (when (empty? (:text (om/get-state this)))
-      (.update-caret this (-> this om/get-state :caret dec))))
+      (.update-caret this dec)))

   (key-right [this e]
     (when (empty? (:text (om/get-state this)))
-      (.update-caret this (-> this om/get-state :caret inc))))
+      (.update-caret this inc)))

   (key-escape [this e]
     (.show-matches this false))
@@ -174,7 +185,7 @@
   (componentWillMount [this]
     (.update-text this "")
     (.update-selected this [])
-    (.update-caret this 0)
+    (.update-caret this (constantly 0))
     (.show-matches this false))

   (componentWillReceiveProps [this props]


fix saw wave out of sine wave examples

fix saw wave out of sine wave examples

--- src/overtone_workshop/session-1.clj
+++ src/overtone_workshop/session-1.clj
@@ -14,10 +14,11 @@
 ;; make a sawtooth wave out of 100 sine waves via list comprehension,
 ;; like your precious python 🐍
 (demo
- (let [* overtone.sc.ugen.collide/*]
+ (let [* overtone.sc.ugen-collide/*]
    (sum (for [i (range 1 100)]
           (* (/ 1 i) (sin-osc (* i 220)))))))

+(demo (lf-saw 220))
 ;; additive synthesis
 ;; http://quod.lib.umich.edu/cgi/p/pod/dod-idx/synthesizing-a-javanese-gong-ageng.pdf
 (definst bell [frequency 440 duration 1.0 volume 1.0 position 0 wet 0.5 room 0.5
@@ -34,7 +35,6 @@
         whole (* 10 (mix partials))]
     whole))

-
 ;; ex. 3 -- SHOWING THE FREQUENCY - PITCH CORRELATION
 ;; good chance to show off doseq. functions that start with 'do' in
 ;; clojure are often used cordone off the outside world (I/O thingers)
@@ -48,7 +48,7 @@
 ;; lowpass
 (do
   (demo 1 (lf-saw))
-  (Thread/sleep 1000)
+  (Thread/sleep 1500)
   (demo 1 (lpf (lf-saw) 500)))

 ;; hipass
@@ -64,7 +64,9 @@
   (demo 1 (bpf (lf-saw) 1000 0.1)))

 ;; way more fun when you move the cutoff frequency around
-(demo 5 (lpf (lf-saw) (mouse-x 20 6000 EXP)))
+(demo 10 (lpf (lf-saw) (mouse-x 20 6000 EXP)))
+
+

 ;; ex. 5 -- ENVELOPES --

@@ -96,7 +98,10 @@

 ;; classic lfo business
 ;; frequency
-(demo 5 (sin-osc (mul-add (sin-osc 0.8) 20 200)))
+
+
+(demo 5 (sin-osc (+ 2000 (* (sin-osc 2) 1000))))
+
 ;; amplitude
 (demo 5 (* (+ 1 (sin-osc 0.5)) (sin-osc)))
 ;; all together now


hide HW screens from navigation

hide HW screens from navigation

Signed-off-by: Dmitry Novotochinov <b5b1b877a7d2fe39ba1f1c39d1fd1abc6e284505@gmail.com>

--- src/status_im/ui/screens/views.cljs
+++ src/status_im/ui/screens/views.cljs
@@ -69,7 +69,8 @@
             [status-im.utils.random :as rand]
             [re-frame.core :as re-frame]
             [taoensso.timbre :as log]
-            [status-im.utils.platform :as platform]))
+            [status-im.utils.platform :as platform]
+            [status-im.utils.config :as config]))

 (defn wrap [view-id component]
   (fn []
@@ -129,18 +130,20 @@
     {:screen
      (nav-reagent/stack-navigator
       (stack-screens
-       (cond-> {:login                            login
-                :progress                         progress
-                :create-account                   create-account
-                :recover                          recover
-                :accounts                         accounts
-                :hardwallet-authentication-method hardwallet-authentication-method
-                :hardwallet-connect               hardwallet-connect
-                :hardwallet-setup                 hardwallet-setup
-                :hardwallet-pin                   hardwallet-pin
-                :hardwallet-success               hardwallet-success}
+       (cond-> {:login          login
+                :progress       progress
+                :create-account create-account
+                :recover        recover
+                :accounts       accounts}
          (= :intro view-id)
-         (assoc :intro intro)))
+         (assoc :intro intro)
+
+         config/hardwallet-enabled?
+         (assoc :hardwallet-authentication-method hardwallet-authentication-method
+                :hardwallet-connect hardwallet-connect
+                :hardwallet-setup hardwallet-setup
+                :hardwallet-pin hardwallet-pin
+                :hardwallet-success hardwallet-success)))
       (cond-> {:headerMode "none"}
         (#{:intro :login} view-id)
         (assoc :initialRouteName (name view-id))))}
@@ -259,34 +262,36 @@
        {:screen
         (nav-reagent/stack-navigator
          (stack-screens
-          {:my-profile                       (main-tabs/get-main-tab :my-profile)
-           :profile-photo-capture            profile-photo-capture
-           :about-app                        about-app/about-app
-           :bootnodes-settings               bootnodes-settings
-           :edit-bootnode                    edit-bootnode
-           :offline-messaging-settings       offline-messaging-settings
-           :edit-mailserver                  edit-mailserver
-           :help-center                      help-center
-           :extensions-settings              extensions-settings
-           :add-extension                    add-extension
-           :show-extension                   show-extension
-           :network-settings                 network-settings
-           :network-details                  network-details
-           :edit-network                     edit-network
-           :log-level-settings               log-level-settings
-           :fleet-settings                   fleet-settings
-           :currency-settings                currency-settings
-           :backup-seed                      backup-seed
-           :login                            login
-           :create-account                   create-account
-           :recover                          recover
-           :accounts                         accounts
-           :hardwallet-authentication-method hardwallet-authentication-method
-           :hardwallet-connect               hardwallet-connect
-           :hardwallet-pin                   hardwallet-pin
-           :hardwallet-setup                 hardwallet-setup
-           :hardwallet-success               hardwallet-success
-           :qr-scanner                       qr-scanner})
+          (cond-> {:my-profile                       (main-tabs/get-main-tab :my-profile)
+                   :profile-photo-capture            profile-photo-capture
+                   :about-app                        about-app/about-app
+                   :bootnodes-settings               bootnodes-settings
+                   :edit-bootnode                    edit-bootnode
+                   :offline-messaging-settings       offline-messaging-settings
+                   :edit-mailserver                  edit-mailserver
+                   :help-center                      help-center
+                   :extensions-settings              extensions-settings
+                   :add-extension                    add-extension
+                   :show-extension                   show-extension
+                   :network-settings                 network-settings
+                   :network-details                  network-details
+                   :edit-network                     edit-network
+                   :log-level-settings               log-level-settings
+                   :fleet-settings                   fleet-settings
+                   :currency-settings                currency-settings
+                   :backup-seed                      backup-seed
+                   :login                            login
+                   :create-account                   create-account
+                   :recover                          recover
+                   :accounts                         accounts
+                   :qr-scanner                       qr-scanner}
+
+            config/hardwallet-enabled?
+            (assoc :hardwallet-authentication-method hardwallet-authentication-method
+                   :hardwallet-connect hardwallet-connect
+                   :hardwallet-pin hardwallet-pin
+                   :hardwallet-setup hardwallet-setup
+                   :hardwallet-success hardwallet-success)))
          {:headerMode       "none"
           :initialRouteName "my-profile"})}
        :profile-qr-viewer


Questioning the use of Liberator

Questioning the use of Liberator

--- src/swanson/routes/transactions.clj
+++ src/swanson/routes/transactions.clj
@@ -46,21 +46,15 @@
                       (utils/json-response
                         {:error (str "Transaction not found for id " id)})))

-(defresource transactions []
-  :allowed-methods [:options :get]
-  :available-media-types ["application/json"]
-  :handle-ok (fn [ctx]
-              (let [default "25"
-                    l (get-in ctx [:request :params :limit] default)
-                    limit (utils/parse-number l)]
-                (utils/json-response (db/get-all-transactions limit)))))
+(defn transactions []
+  (let [default "25"
+        l (get-in ctx [:request :params :limit] default)
+        limit (utils/parse-number l)]
+    (utils/json-response (db/get-all-transactions limit))))

-(defresource category [category-id]
-  :allowed-methods [:options :get]
-  :available-media-types ["application/json"]
-  :handle-ok (fn [ctx]
-              (let [result (db/category-monthly (Integer/parseInt category-id))]
-                (utils/json-response result))))
+(defn category [category-id]
+  (let [result (db/category-monhly (Integer/parseInt category-id))]
+    (utils/json-response result)))

 (defn categories-ytd []
   (let [result (db/categories-ytd)]


Document the pattern fns

Document the pattern fns

--- src/oxcart/pattern.clj
+++ src/oxcart/pattern.clj
@@ -40,6 +40,12 @@

 (defn private?
+  "λ AST → bool
+
+  Indicates whether the AST node passed as an argument is flagged as
+  private. Definitions may be public or private, all other
+  values (constant expressions, function applications and soforth) are
+  defined to be private."
   [form]
   (let [status (-> form :meta :form :private)]
     (if (def? form)
@@ -48,16 +54,33 @@

 (defn public?
+  "λ AST → bool
+
+  Indicates whether the AST node passed as the first argument is
+  flagged as public. Definitions are public by default unless marked
+  private. All other values (constant expressions, function
+  applications and soforth) are defined to be private."
   [form]
   (-> form private? not))

 (defn dynamic?
+  "λ AST → bool
+
+  Indicates whether the AST node passed as the argument is flagged as
+  dynamic. Dynamic status is not currently conditional on being a
+  definition, however this behavior is subject to change."
   [form]
   (-> form :meta :form :dynamic true?))

 (defn const?
+  "λ AST → bool
+
+  Indicates whether the AST node passed as the argument is flagged as
+  const. If the node is both const and dynamic, it is not const. An
+  error may be issued if this is ever the case as it represents a
+  contradiction in terms."
   [form]
   (case (-> form :meta :form :const)
     (true nil) (not (dynamic? form))


set video error based on processing.

set video error based on processing.

--- src/oc/storage/resources/entry.clj
+++ src/oc/storage/resources/entry.clj
@@ -224,10 +224,14 @@
                           (> (:state video) 4))
         video-transcript-data (get-in video [:original_stream :audio_transcription :text])
         video-transcript (or video-transcript-data
-                             (:video-transcript entry))]
+                             (:video-transcript entry))
+        video-error (if video-processed
+                      false
+                      (:video-error entry))]
     (update-entry-no-user! conn
                            (:uuid entry)
                            (-> entry
+                               (assoc :video-error video-error)
                                (assoc :video-processed video-processed)
                                (assoc :video-transcript video-transcript)))))


Accumulate entry editors in sequence order.

--- src/oc/storage/resources/entry.clj
+++ src/oc/storage/resources/entry.clj
@@ -118,7 +118,7 @@
           topic-named-entry (assoc merged-entry :topic-name topic-name)
           slugged-entry (assoc topic-named-entry :topic-slug topic-slug)
           ts (db-common/current-timestamp)
-          updated-authors (conj authors (assoc (lib-schema/author-for-user user) :updated-at ts))
+          updated-authors (concat authors [(assoc (lib-schema/author-for-user user) :updated-at ts)])
           updated-author (assoc slugged-entry :author updated-authors)
           attachments (:attachments merged-entry)
           updated-entry (assoc updated-author :attachments (timestamp-attachments attachments ts))]


added danser

added danser

--- src/babel/francais/lexicon.cljc
+++ src/babel/francais/lexicon.cljc
@@ -166,6 +166,9 @@

    "croire" {:synsem {:cat :verb
                       :sem {:pred :believe}}}
+
+   "danser" {:synsem {:cat :verb
+                       :sem {:pred :dance}}}

    "decider" {:synsem {:cat :verb
                        :sem {:pred :decide}}}


added nascere

added nascere

--- src/babel/italiano/lexicon.cljc
+++ src/babel/italiano/lexicon.cljc
@@ -1564,6 +1564,11 @@

    ;; non-comparative
    ;; TODO: add comparative
+   "nascere" {:synsem {:cat :verb
+                      :essere true
+                      :sem {:pred :be-born}}
+             :italiano {:passato "nato"}}
+
    "nero"
    (unify adjective
           {:synsem {:cat :adjective


update

update

--- src/panpan/persona.clj
+++ src/panpan/persona.clj
@@ -51,7 +51,7 @@
       #".+"
       (fn [& _]
         (when-let [res (some-> api-key
-                               (dd/talk text {:t 30
+                               (dd/talk text {;:t 30
                                               :context (brain/get CONTEXT_KEY)}))]
           (brain/set CONTEXT_KEY (:context res))
           (:utt res))))))


whoops

whoops

--- src/voke/core.cljs
+++ src/voke/core.cljs
@@ -1,5 +1,5 @@
 (ns voke.core
-  (:require [voke.system.core :refer [handle-update-entity-events make-system-runner]]))
+  (:require [voke.system.core :refer [make-system-runner]]))

 ; TODO make-player function... somewhere.
 (def player {:id                      1


Stripping out redundant arguments. Could probably do more.

--- src/midje/util/checkers.clj
+++ src/midje/util/checkers.clj
@@ -316,11 +316,11 @@
 (defmulti compare-results
   (fn [actual expected looseness]
     (if (= ::map (midje-classification actual))
-      midje-classification
+      (midje-classification actual)
       [::not-map (or (some #{:in-any-order} looseness) :strict-order)])))

 ;; There are some incommensurable utility behaviors
-(defn compare-one-map-permutation [midje-classification actual expected keys]
+(defn compare-one-map-permutation [actual expected keys]
   ;;  (prn "map-comparison" actual expected)
   (reduce (fn [so-far key]
             (if (and (find actual key)
@@ -336,7 +336,7 @@
   "Compare actual elements to expected, which is one of perhaps many
    permutations of the original expected list. looseness is a subset of
    #{:gaps-ok :in-any-order}."
-  [midje-classification actual expected looseness]
+  [actual expected looseness]
   (let [starting-candidate (assoc (base-starting-candidate expected) :expected-skipped-over [])
         gaps-ok? (some #{:gaps-ok} looseness)]
     (loop [walking-actual   actual
@@ -400,8 +400,7 @@
   (order-free-compare-results expected
                               (feasible-permutations (keys expected))
                               (fn [permutation]
-                                (compare-one-map-permutation (midje-classification actual)
-                                                             actual
+                                (compare-one-map-permutation actual
                                                              expected
                                                              permutation))))

@@ -410,8 +409,7 @@
   (order-free-compare-results expected
                               (feasible-permutations expected)
                               (fn [permutation]
-                                (compare-one-seq-permutation (midje-classification actual)
-                                                             actual
+                                (compare-one-seq-permutation actual
                                                              permutation
                                                              looseness))))


use zipper for computing round info

use zipper for computing round info

--- src/bracketolojy/tournament.clj
+++ src/bracketolojy/tournament.clj
@@ -50,27 +50,36 @@
     treeify
     bracket))

-(defn- compute-round-dispatch [_ node]
-  (when (and (map? node) (contains? node :upper) (contains? node :lower))
-    (if (get-in node [:data :round])
-      :branch
-      :root)))
-
-(defmulti #^{:private true} compute-round
-          compute-round-dispatch)
-(defmethod compute-round :default [_ node]
-  node)
-(defmethod compute-round :branch [_ node]
-  (let [current-round (get-in node [:data :round])]
-    (-> (assoc-in node [:upper :data :round] (dec current-round))
-        (assoc-in [:lower :data :round] (dec current-round)))))
-(defmethod compute-round :root [max-rounds node]
-  (compute-round max-rounds (assoc-in node [:data :round] max-rounds)))
+(defn- branch? [node]
+  (and (map? node) (contains? node :upper) (contains? node :lower)))
+
+(defn children [node]
+  ((juxt :upper :lower) node))
+
+(defn make-node [existing [upper lower]]
+  (-> (assoc-in existing [:upper] upper)
+      (assoc-in [:lower] lower)))
+
+(defn- update-round [rnd node]
+  (assoc-in node [:data :round] rnd))
+
+(defn- compute-round [loc]
+  (if (zip/end? loc)
+    loc
+    (if-let [parent-round (some-> (zip/up loc)
+                                  zip/node
+                                  (get-in [:data :round]))]
+      (recur (zip/next (zip/edit loc (partial update-round (dec parent-round)))))
+      (recur (zip/next loc)))))

 (defn round-info [max-rounds tree]
-  (walk/prewalk
-    (partial compute-round max-rounds)
-    tree))
+  (->> (update-round max-rounds tree)
+       (zip/zipper
+         branch?
+         children
+         make-node)
+       compute-round
+       zip/root))

 (defn weighted-pairing-log5
   "Compute and update the chance that Team a and Team b will advance when playing against each other,
@@ -138,16 +147,14 @@
   "Update the expected value of each team in the field using parent-team-map.  The expected value for each team in the
   field is the team's average points plus the expected value of the team in the parent-team-map."
   [parent-team-map node]
-  (if (seq (get-in node [:data :teams]))
-    (update-in
-      node
-      [:data :teams]
-      (partial
-        map
-        #(update-in % [:expected-value] (fnil + 0 0)
-                    (get-in parent-team-map [(:name %) :expected-value])
-                    (:avg-pts %))))
-    node))
+  (update-in
+    node
+    [:data :teams]
+    (partial
+      map
+      #(update-in % [:expected-value] (fnil + 0 0)
+                  (get-in parent-team-map [(:name %) :expected-value])
+                  (:avg-pts %)))))

 (defn- update-expected-value
   "For each child in children, update the expected value of the teams in that child's field.  The expected value for each team
@@ -156,7 +163,7 @@
   (let [parent-team-map (->> (get-in node [:data :teams])
                              (map #((juxt :name identity) %))
                              (into {}))]
-    (if (and (get node :upper) (get node :lower))
+    (if (branch? node)
       (-> (update-in node [:upper] (partial update-child-expected-value parent-team-map))
           (update-in [:lower] (partial update-child-expected-value parent-team-map)))
       node)))
@@ -167,16 +174,6 @@
   (if (zip/end? loc)
     loc
     (recur (zip/next (zip/edit loc update-expected-value)))))
-
-(defn- branch? [node]
-  (and (map? node) (contains? node :upper) (contains? node :lower)))
-
-(defn children [node]
-  ((juxt :upper :lower) node))
-
-(defn make-node [existing [upper lower]]
-  (-> (assoc-in existing [:upper] upper)
-      (assoc-in [:lower] lower)))

 (defn compute-expected-value
   "Compute the expected value for each node in the tournament probabilites tree."


whitespace changes

whitespace changes

--- src/re_frame_async_flow_fx/core.cljs
+++ src/re_frame_async_flow_fx/core.cljs
@@ -84,38 +84,38 @@
     (fn async-flow-event-hander
       [{:keys [db]} event-v]

-        (condp = event-v
-              ;; Setup this flow coordinator:
-              ;;   1. Establish initial state - :seen-events and :started-tasks are made empty sets
-              ;;   2. dispatch the first event, to kick start flow
-              ;;   3. arrange for the events to be forwarded to this handler
-              :setup {:db (set-state db #{} #{})
-                      :dispatch first-dispatch
-                      :event-forwarder {:register    id
-                                        :events      (apply set/union (map :events rules))
-                                        :dispatch-to [id]}}
+      (condp = event-v
+        ;; Setup this flow coordinator:
+        ;;   1. Establish initial state - :seen-events and :started-tasks are made empty sets
+        ;;   2. dispatch the first event, to kick start flow
+        ;;   3. arrange for the events to be forwarded to this handler
+        :setup {:db (set-state db #{} #{})
+                :dispatch first-dispatch
+                :event-forwarder {:register    id
+                                  :events      (apply set/union (map :events rules))
+                                  :dispatch-to [id]}}

-              ;; Teardown this flow coordinator:
-              ;;   1. remove this event handler
-              ;;   2. remove any state stored in app-db
-              ;;   3. deregister the events forwarder
-              :halt-flow {:db (dissoc db db-path)
-                     :event-forwarder {:unregister id}
-                     :deregister-event-handler id}
+        ;; Teardown this flow coordinator:
+        ;;   1. remove this event handler
+        ;;   2. remove any state stored in app-db
+        ;;   3. deregister the events forwarder
+        :halt-flow {:db (dissoc db db-path)  ;; Aggh. I need dissoc-in to make this work.
+                    :event-forwarder {:unregister id}
+                    :deregister-event-handler id}

-              ;; Here we are managig the flow.
-              ;; A new event has been forwarded to this handler. What does it mean?
-              ;;  1. does this new event mean we need to dispatch another?
-              ;;  2. remember this event has happened
-              (let [[_ [forwarded-event-id & args]] event-v
-                    {:keys [seen-events started-tasks]} (get-state db)
-                    new-seen-events    (conj seen-events forwarded-event-id)
-                    ready-tasks        (newly-startable-tasks rules new-seen-events started-tasks)
-                    ready-task-ids     (->> ready-tasks (map :id) set)
-                    new-started-tasks  (set/union started-tasks ready-task-ids)]
-                (merge
-                    {:db       (set-state db new-seen-events new-started-tasks)}
-                    (when (seq ready-tasks) {:dispatch (mapcat :dispatch ready-tasks)})))))))
+        ;; Here we are managig the flow.
+        ;; A new event has been forwarded to this handler. What does it mean?
+        ;;  1. does this new event mean we need to dispatch another?
+        ;;  2. remember this event has happened
+        (let [[_ [forwarded-event-id & args]] event-v
+              {:keys [seen-events started-tasks]} (get-state db)
+              new-seen-events    (conj seen-events forwarded-event-id)
+              ready-tasks        (newly-startable-tasks rules new-seen-events started-tasks)
+              ready-task-ids     (->> ready-tasks (map :id) set)
+              new-started-tasks  (set/union started-tasks ready-task-ids)]
+          (merge
+            {:db       (set-state db new-seen-events new-started-tasks)}
+            (when (seq ready-tasks) {:dispatch (mapcat :dispatch ready-tasks)})))))))

 ;; -- Register effects handler with re-frame


Keep compiled data in Clojure format

Keep compiled data in Clojure format

--- src/org/knotation/editor/core.cljs
+++ src/org/knotation/editor/core.cljs
@@ -95,12 +95,12 @@

     (set! (.-knotation ed)
           (clj->js {:getCompiled
-                     (fn [] (clj->js (or (.-graph (.-knotation ed)) [])))
+                    (fn [] (or (.-graph (.-knotation ed)) []))

                     :getCompiledLine
                     (fn [ln-num]
                       (when-let [g (.-graph (.-knotation ed))]
-                        (clj->js (first (filter #(= (inc ln-num) (->> % ::st/input ::st/line-number)) g)))))}))
+                        (first (filter #(= (inc ln-num) (->> % ::st/input ::st/line-number)) g))))}))

     (set! (.-hooks ed) {:on-hover (atom []) :on-leave (atom [])})
     (set! (.-onmouseover (.getWrapperElement ed)) #(run-hooks! ed :on-hover %))


Replace call to chunkifier with direct use of thrift API

--- src/clj/forma/source/static.clj
+++ src/clj/forma/source/static.clj
@@ -109,20 +109,19 @@

   ?dataset ?m-res ?t-res !date ?mod-h ?mod-v ?sample ?line ?val"
   [val-gen m-res chunk-size nodata]
-  (let [chunkifier (p/chunkify chunk-size)
-        src (p/sparse-windower val-gen
+  (let [src (p/sparse-windower val-gen
                                ["?sample" "?line"]
                                (r/chunk-dims m-res chunk-size)
                                "?val"
                                nodata)]
     (<- [?tile-chunk]
-        (src ?dataset ?s-res ?t-res !date ?h ?v  _ ?id ?window)
+        (src ?dataset ?s-res ?t-res _ ?h ?v  _ ?id ?window)
         (p/flatten-window ?window :> ?data)
         (thrift/pack ?data :> ?val)
         (count ?data :> ?count)
         (= ?count chunk-size)
-        (chunkifier ?dataset !date ?s-res ?t-res ?h ?v ?id ?val :> ?tile-chunk)
-        )))
+        (thrift/ModisChunkLocation* ?s-res ?h ?v ?id chunk-size :> ?tile-loc)
+        (thrift/DataChunk* ?dataset ?tile-loc ?val ?t-res :> ?tile-chunk))))

 (defn static-chunks
   "TODO: DOCS!"


added conditional for deseasonalization

added conditional for deseasonalization

--- src/clj/forma/trends/filter.clj
+++ src/clj/forma/trends/filter.clj
@@ -27,13 +27,15 @@
   Example:
     (deseasonalize 23 (s/sample-uniform 200))"
   [freq ts]
-  (let [x (dummy-mat freq (i/nrow ts))
-        xt (i/trans x)
-        xtx (i/mmult xt x)
-        coefs (i/mmult (i/solve xtx) xt ts)
-        fitted (i/mmult x coefs)]
-    (i/plus (i/minus ts fitted)
-            (s/mean ts))))
+  (if (nil? ts)
+    nil
+    (let [x (dummy-mat freq (i/nrow ts))
+          xt (i/trans x)
+          xtx (i/mmult xt x)
+          coefs (i/mmult (i/solve xtx) xt ts)
+          fitted (i/mmult x coefs)]
+      (i/plus (i/minus ts fitted)
+              (s/mean ts)))))

 ;; Remove seasonal component by harmonic decomposition


implement Security Nexus

implement Security Nexus

--- src/clj/game/cards-hardware.clj
+++ src/clj/game/cards-hardware.clj
@@ -300,6 +300,16 @@
                                                      (:deck runner)) :hand)
                                          (shuffle! :deck))}}}}

+   "Security Nexus"
+   {:effect (effect (gain :link 1) (gain :memory 1))
+    :leave-play (effect (lose :link 1) (lose :memory 1))
+    :abilities [{:req (req (:run @state))
+                 :msg "force the Corp to initiate a trace"
+                 :label "Trace 5 - Give the Runner 1 tag and end the run"
+                 :trace {:once :per-turn :base 5 :msg "give the Runner 1 tag and end the run"
+                         :effect (effect (gain :runner :tag 1) (end-run))
+                         :unsuccessful {:msg "bypass the current ICE"}}}]}
+
    "Silencer"
    {:recurring 1}


don't card-init agendas swapped back to the Corp, but still hook up events and abilities

--- src/clj/game/cards-hardware.clj
+++ src/clj/game/cards-hardware.clj
@@ -453,7 +453,11 @@
                                                      (gain-agenda-point state :runner (- swpts stpts))
                                                      (gain-agenda-point state :corp (- stpts swpts))
                                                      (doseq [c (get-in @state [:corp :scored])]
-                                                       (card-init state :corp c false))
+                                                       (let [abilities (:abilities (card-def c))
+                                                             c (merge c {:abilities abilities})]
+                                                         (update! state :corp c)
+                                                         (when-let [events (:events (card-def c))]
+                                                           (register-events state side events c))))
                                                      (doseq [r (get-in @state [:runner :scored])]
                                                        (desactivate state :corp r))
                                                      (system-msg state side


Add story list items

Add story list items

--- src/cljs/hacker_agent/core.cljs
+++ src/cljs/hacker_agent/core.cljs
@@ -57,11 +57,20 @@
                 (for [[id sub-data] (vec kids)]
                   ^{:key id} [comment sub-data]))])])))))

+(defn story-list-item [id]
+  (let [data (base/id->atom id)]
+    (fn [id]
+      (let [{:keys [id by title score]} @data]
+        (when id
+          [:li
+           [:p [:a {:href (str "/#/items/" id)} title] " * " score]
+           [:p "By: " by]])))))
+
 (defn top-stories [state]
   (let [{top-stories :top-stories} state]
     [:ul
-     (for [id top-stories]
-       ^{:key id} [:li [:a {:href (str "/#/items/" id)} id]])]))
+     (for [id (vec top-stories)]
+       ^{:key id} [story-list-item id])]))

 ;; -------------------------
 ;; Views


Inline fn that didn't help to explain much.

--- src/cljs/leipzig_live/core.cljs
+++ src/cljs/leipzig_live/core.cljs
@@ -19,20 +19,15 @@
 ;; -------------------------
 ;; Evaluation

-(defn identify
-  "Hack to make literal values still evaluate."
-  [expr-str]
-  (str "(identity " expr-str ")"))
-
 (defonce compiler-state (cljs/empty-state))
 (defn evaluate
   [expr-str]
-    (cljs/eval-str
-      compiler-state
-      (identify expr-str)
-      nil
-      {:eval cljs/js-eval}
-      #(:value %)))
+  (cljs/eval-str
+    compiler-state
+    (str "(identity " expr-str ")")
+    nil
+    {:eval cljs/js-eval}
+    #(:value %)))

 ;; -------------------------
 ;; Behaviour


Either monad transformer

Either monad transformer

--- src/cljx/cats/monad/either.cljx
+++ src/cljx/cats/monad/either.cljx
@@ -1,6 +1,6 @@
 (ns cats.monad.either
   "The Either (Error) Monad."
-  (:require [cats.protocols :as p]))
+  (:require [cats.protocols :as proto]))

 (declare either-monad)

@@ -92,4 +92,30 @@
        (f (.-v s))
        s))))

-; TODO Either transformer
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Monad transformer definition
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn either-trans [inner-m]
+  (reify
+    proto/Monad
+    (mreturn [_ v]
+      (proto/mreturn inner-m (right v)))
+
+    (mbind [_ mv f]
+      (proto/mbind inner-m
+                   mv
+                   (fn [either-v]
+                     (if (left? either-v)
+                       (proto/mreturn inner-m either-v)
+                       (f (from-either either-v))))))
+
+    proto/MonadTrans
+    (inner [_]
+      inner-m)
+
+    (lift [m mv]
+      (proto/mbind inner-m
+                   mv
+                   (fn [v]
+                     (proto/mreturn inner-m (right v)))))))


Set CORS header on POSTs

Set CORS header on POSTs

--- src/cmr/graph/rest/response.clj
+++ src/cmr/graph/rest/response.clj
@@ -37,4 +37,5 @@
                  (response/header "Access-Control-Allow-Headers" "Content-Type")
                  (response/header "Access-Control-Max-Age" "2592000"))
     :get (response/header response "Access-Control-Allow-Origin" "*")
+    :post (response/header response "Access-Control-Allow-Origin" "*")
     response))


unused recommender engine detection module

--- src/crawler/rich_char_extractor.clj
+++ src/crawler/rich_char_extractor.clj
@@ -94,38 +94,6 @@
         :xpath-nav-info (reverse
                          (sort-by :score xpath-nav-info))})))

-(defn detect-recommender-engine-links
-  [src-text-mean src-text-stdev decision-space body]
-  (let [means (map
-               (fn [{xpaths :xpaths
-                    hrefs  :hrefs
-                    score  :score
-                    texts  :texts}]
-                 (let [text-sizes (map count texts)
-                       text-mean  (/
-                                   (apply + text-sizes)
-                                   (count text-sizes))]
-                   [{:xpaths xpaths
-                     :hrefs  hrefs
-                     :score  score
-                     :texts  texts}
-                    text-mean]))
-               decision-space)]
-    (map
-     (fn [[stuff a-mean]]
-       (let [res        (- a-mean src-text-mean)
-             candidate? (or (<= res src-text-stdev)
-                            (<= res (* (- 1.0)
-                                       src-text-stdev)))]
-         (when candidate?
-           (let [links (:hrefs stuff)]
-             (some
-              #(<= 0.8
-                   (similarity/tree-edit-distance-html
-                    body (utils/download-with-cookie %)))
-              (take 3 links))))))
-     means)))
-
 (defn filter-content
   "Helper routine you can use to filter
    content that the extractor mined.


Remove handling of samples in org PATCH request.

--- src/oc/storage/api/orgs.clj
+++ src/oc/storage/api/orgs.clj
@@ -113,6 +113,42 @@

     (do (timbre/error "Failed creating org.") false)))

+      ; (when (:samples ctx) ; are we PATCH'ing boards from NUX?
+      ;   ;; Sync the boards the org has w/ the boards PATCH'd from the NUX by creating and deleting boards
+      ;   (timbre/info "Syncing samples for:" org-uuid)
+      ;   (let [selected-board-names (vec (:boards ctx))
+      ;         existing-boards (board-res/list-boards-by-org conn org-uuid)
+      ;         existing-board-names (set (map :name existing-boards))
+      ;         existing-boards-by-name (zipmap (map :name existing-boards) existing-boards)
+      ;         desired-board-names (set (conj selected-board-names config/forced-board-name))
+      ;         delete-board-names (clojure.set/difference existing-board-names desired-board-names)
+      ;         create-board-names (clojure.set/difference desired-board-names existing-board-names)
+      ;         ;; including these doall/pmap in the let to prevent Eastwood from having a tizzy about the doall
+      ;         ;; Sync the orgs boards w/ the NUX selected boards by deleting and adding as needed
+      ;         _deleted-boards (doall (pmap (fn [delete-board-name]
+      ;           (timbre/info "NUX sync - Deleting board:" delete-board-name "for org:" org-uuid)
+      ;           (let [board (board-res/get-board conn (:uuid (get existing-boards-by-name delete-board-name)))
+      ;                 entries (entry-res/list-all-entries-by-board conn (:uuid board))]
+      ;             (board-res/delete-board! conn org-uuid (:slug board) entries)
+      ;             (notification/send-trigger! (notification/->trigger :delete update-result {:old board} (:user ctx)))))
+      ;           delete-board-names))
+      ;         _created-boards (doall (pmap (fn [create-board-name]
+      ;           (timbre/info "NUX sync - Creating board:" create-board-name "for org:" org-uuid)
+      ;           (create-board conn updated-org {:name create-board-name} author))
+      ;           create-board-names))
+      ;         ;; create a min of 3 / max of 4 sample entries, including at least 1 from the forced board
+      ;         selected-entries (take 3 (flatten (map default-entries-for
+      ;                                             (remove #(= % config/forced-board-name) selected-board-names))))
+      ;         forced-entries (default-entries-for config/forced-board-name)
+      ;         total-entries (take 4 (concat selected-entries forced-entries))
+      ;         create-entries (map #(update % :author (fn [val] (or val (lib-schema/author-for-user author))))
+      ;                         (take 4 (concat selected-entries forced-entries)))
+      ;         _created-entries (doall (pmap #(create-entry conn updated-org % author) create-entries))]
+      ;       (notification/send-trigger!
+      ;         (notification/->trigger :nux updated-org {:nux-boards (vec desired-board-names)} author))
+      ;       (timbre/info "Syncing samples for:" org-uuid "complete.")))
+
+
 (defn- update-org [conn ctx slug]
   (timbre/info "Updating org:" slug)
   (if-let* [author (:user ctx)
@@ -120,41 +156,6 @@
             update-result (org-res/update-org! conn slug updated-org)
             org-uuid (:uuid updated-org)]
     (do
-      (when (:samples ctx) ; are we PATCH'ing boards from NUX?
-        ;; Sync the boards the org has w/ the boards PATCH'd from the NUX by creating and deleting boards
-        (timbre/info "Syncing samples for:" org-uuid)
-        (let [selected-board-names (vec (:boards ctx))
-              existing-boards (board-res/list-boards-by-org conn org-uuid)
-              existing-board-names (set (map :name existing-boards))
-              existing-boards-by-name (zipmap (map :name existing-boards) existing-boards)
-              desired-board-names (set (conj selected-board-names config/forced-board-name))
-              delete-board-names (clojure.set/difference existing-board-names desired-board-names)
-              create-board-names (clojure.set/difference desired-board-names existing-board-names)
-              ;; including these doall/pmap in the let to prevent Eastwood from having a tizzy about the doall
-              ;; Sync the orgs boards w/ the NUX selected boards by deleting and adding as needed
-              _deleted-boards (doall (pmap (fn [delete-board-name]
-                (timbre/info "NUX sync - Deleting board:" delete-board-name "for org:" org-uuid)
-                (let [board (board-res/get-board conn (:uuid (get existing-boards-by-name delete-board-name)))
-                      entries (entry-res/list-all-entries-by-board conn (:uuid board))]
-                  (board-res/delete-board! conn org-uuid (:slug board) entries)
-                  (notification/send-trigger! (notification/->trigger :delete update-result {:old board} (:user ctx)))))
-                delete-board-names))
-              _created-boards (doall (pmap (fn [create-board-name]
-                (timbre/info "NUX sync - Creating board:" create-board-name "for org:" org-uuid)
-                (create-board conn updated-org {:name create-board-name} author))
-                create-board-names))
-              ;; create a min of 3 / max of 4 sample entries, including at least 1 from the forced board
-              selected-entries (take 3 (flatten (map default-entries-for
-                                                  (remove #(= % config/forced-board-name) selected-board-names))))
-              forced-entries (default-entries-for config/forced-board-name)
-              total-entries (take 4 (concat selected-entries forced-entries))
-              create-entries (map #(update % :author (fn [val] (or val (lib-schema/author-for-user author))))
-                              (take 4 (concat selected-entries forced-entries)))
-              _created-entries (doall (pmap #(create-entry conn updated-org % author) create-entries))]
-            (notification/send-trigger!
-              (notification/->trigger :nux updated-org {:nux-boards (vec desired-board-names)} author))
-            (timbre/info "Syncing samples for:" org-uuid "complete.")))
-
       (timbre/info "Updated org:" slug)
       (notification/send-trigger! (notification/->trigger :update {:old (:existing-org ctx) :new update-result}
                                                           author))
@@ -208,9 +209,7 @@

 (defn- valid-org-update? [conn slug org-props]
   (if-let [org (org-res/get-org conn slug)]
-    (let [samples? (:samples org-props)
-          updated-props (if samples? (dissoc org-props :samples :boards) org-props)
-          updated-org (merge org (org-res/ignore-props updated-props))
+    (let [updated-org (merge org (org-res/ignore-props org-props))
           updating-org-name? (contains? org-props :name)
           org-name (:name org-props)]
       (if (and (lib-schema/valid? common-res/Org updated-org)
@@ -219,7 +218,7 @@
                         (<= (count org-name) org-name-max-length)
                         (>= (count org-name) org-name-min-length))))
         {:existing-org (api-common/rep org) :updated-org (api-common/rep updated-org)
-         :samples (api-common/rep samples?) :boards (api-common/rep (:boards org-props))}
+         :boards (api-common/rep (:boards org-props))}
         [false, {:updated-org (api-common/rep updated-org)}])) ; invalid update
     true)) ; No org for this slug, so this will fail existence check later


SER-81 fix identify bin path

SER-81 fix identify bin path

--- src/vignette/util/thumb_verifier.clj
+++ src/vignette/util/thumb_verifier.clj
@@ -1,6 +1,7 @@
 (ns vignette.util.thumb-verifier
   (:require [wikia.common.logger :as log]
-            [clojure.java.shell :refer [sh]])
+            [clojure.java.shell :refer [sh]]
+            [clojure.string :refer [trim]])
   (:use [environ.core]))

 (declare
@@ -30,7 +31,8 @@
       :thumb-map thumb-map
       }))))

-(def identify-bin (str (env :imagemagick-base "/usr/local/bin") "/identify"))
+(def identify-bin
+  (trim (str (env :imagemagick-base "/usr/local") "/bin/identify")))

 (defn identify
   [file]


(set-handler for button now uses inherit-multimethod)

--- src/conexp/gui/editors/util.clj
+++ src/conexp/gui/editors/util.clj
@@ -20,6 +20,7 @@
     [javax.swing.table DefaultTableModel])
   (:use clojure.contrib.swing-utils
     conexp.gui.util
+    conexp.util
     [clojure.contrib.string :only (join split-lines split)]))

 ;;;
@@ -283,18 +284,11 @@
 (deftype button [widget])
 (derive ::button ::widget)

-(defmulti set-handler
-  "is a multi method dispatched by the first parameters type.
-
-  Sets the action handler for the button object.
+(inherit-multimethod set-handler ::button
+  "Sets the action handler for the button object.
   Parameters:
     obutton    _button object
-    handler    _0-ary function that will be called on button press"
-  (fn [x & rest]
-    (cond
-      (isa? (type x) ::button) ::button)))
-
-(defmethod set-handler nil [& args] (message-box "set-handler not implemented!"))
+    handler    _0-ary function that will be called on button press")

 (defmethod-swing-threads*
   set-handler ::button


Only use one swap and minimize gets and assocs

--- src/onyx/messaging/acking_daemon.clj
+++ src/onyx/messaging/acking_daemon.clj
@@ -21,6 +21,8 @@
 (defn acking-daemon [config]
   (map->AckingDaemon {:opts config}))

+(defrecord Ack [completions-id ack-val])
+
 ;; TODO, performance
 ;; Should ack multiple messages at a time so only a single swap!
 ;; is required
@@ -29,18 +31,16 @@
         (swap!
           (:ack-state daemon)
           (fn [state]
-            (update-in state
-                       [message-id]
-                       (fn [ack]
-                         (if-let [current-ack-val (:ack-val ack)]
-                           (assoc ack :ack-val (bit-xor current-ack-val ack-val))
-                           {:completions-id completion-id :ack-val ack-val})))))]
-
-    (when-let [x (get rets message-id)]
-      (when (zero? (:ack-val x))
-        (swap! (:ack-state daemon) dissoc message-id)
-        (>!! (:completions-ch daemon) {:id message-id
-                                       :peer-id completion-id})))))
+            (let [updated-ack-val (if-let [current-ack-val (get-in state [message-id :ack-val])]
+                                    (bit-xor current-ack-val ack-val))]
+              (cond (nil? updated-ack-val)
+                    (assoc state message-id (->Ack completion-id ack-val))
+                    (zero? updated-ack-val)
+                    (dissoc state message-id)
+                    :else
+                    (assoc-in state [message-id :ack-val] updated-ack-val)))))]
+    (when-not (get rets message-id)
+      (>!! (:completions-ch daemon) {:id message-id :peer-id completion-id}))))

 (defn gen-message-id
   "Generates a unique ID for a message - acts as the root id."


Update validation.clj, constrain offset

Update validation.clj, constrain offset

This commit sets the maximum offset to 10000.

--- src/qu/query/validation.clj
+++ src/qu/query/validation.clj
@@ -133,16 +133,35 @@
 (defn- validate-integer
   [query clause]
   (let [val (clause query)]
-    (if (integer? val)
-      query
-      (try
-        (let [_ (cond
-                 (integer? val) val
-                 (nil? val) 0
-                 :default (Integer/parseInt val))]
-          query)
-        (catch NumberFormatException e
-          (add-error query clause "Please use an integer."))))))
+     (if (integer? val)
+       query
+        (try
+          (let [_ (cond   ;begin first statement in try
+                   (integer? val) val
+                    (nil? val) 0
+                    :default (Integer/parseInt val))]
+            query)
+          (catch NumberFormatException e;
+           (add-error query clause "Please use an integer."))))))
+
+(defn- validate-intsize
+  [query clause]
+  (let [val (clause query)]
+    (try
+      (if (and (integer? (Integer/parseInt val)) (> 10000 (Integer/parseInt val)))
+        query
+        (if (and (integer? (Integer/parseInt val)) (< 10000 (Integer/parseInt val)))
+          (add-error query clause "Offset must be < 10000.")
+          (try
+          (let [_ (cond
+                   (integer? val) val
+                   (nil? val) 0
+                   :default (Integer/parseInt val))]
+           query)
+            (catch NumberFormatException e;
+              (add-error query clause "Please use an integer.")))))
+      (catch NumberFormatException e;
+        (add-error query clause "Please use an integer.")))))

 (defn- validate-max-limit
   [query max]
@@ -157,7 +176,7 @@

 (defn- validate-offset
   [query]
-  (validate-integer query :offset))
+  (validate-intsize query :offset))

 (defn validate
   "Check the query for any errors."


fix for error scenarion triggered by warm cache request

--- src/refactor_nrepl/util.clj
+++ src/refactor_nrepl/util.clj
@@ -31,7 +31,7 @@
        ffirst))

 (defn throw-unless-clj-file [file]
-  (when (and file (or (.endsWith file ".cljs") (.endsWith file ".cljx")))
+  (when (and file (not-empty file) (or (.endsWith file ".cljs") (.endsWith file ".cljx")))
     (throw (IllegalArgumentException.
             "Refactor nrepl doesn't work on cljs or cljx files!"))))


Better text from sample page

Better text from sample page

--- src/rente/client/views.cljs
+++ src/rente/client/views.cljs
@@ -4,14 +4,11 @@
 (defn main [data]
   [:div
    [:h1 (:title @data)]
-   [:span "Hello world! This is reagent!"]
+   [:div "Hello world! This is reagent speaking!"]
    [:br]
-   [:span "And sente seems to work too.."]
-   [:br]
-   [:span "And figwheel.. w00t!"]
+   [:div "Look in your browsers developer console to see the web socket communication when clicking below buttons."]
    [:br]
    [:button {:on-click socket/test-socket-callback} "Send Message Callback"]
    [:br]
-   [:button {:on-click socket/test-socket-event} "Send Message Event"]
-   ])
+   [:button {:on-click socket/test-socket-event} "Send Message Event"]])


cleanup

cleanup

--- src/leiningen/leinsync/commands.clj
+++ src/leiningen/leinsync/commands.clj
@@ -54,17 +54,17 @@
     (l/list-resources all-projects-desc ns/resource-def)))

 (defn update-projects! [_ target-projects source-project-desc]
-  (let [all-target-project-desc (pr/read-all-target-project-clj target-projects)
+  (let [target-projects-desc (pr/read-all-target-project-clj target-projects)
         namespaces (u/cartesian-product (get-in source-project-desc ns/namespace-def) target-projects)
         resources (u/cartesian-product (get-in source-project-desc ns/resource-def) target-projects)]
-    (if (not (empty? namespaces)) (ns/update-namespaces! namespaces source-project-desc all-target-project-desc))
-    (if (not (empty? resources)) (ns/update-resouces! resources source-project-desc all-target-project-desc))))
+    (if (not (empty? namespaces)) (ns/update-namespaces! namespaces source-project-desc target-projects-desc))
+    (if (not (empty? resources)) (ns/update-resouces! resources source-project-desc target-projects-desc))))

 (defn deps [_ target-projects {source-project :name}]
-  (let [all-projects-desc (-> target-projects
-                              (conj source-project)
-                              (pr/read-all-target-project-clj))]
-    (deps/check-deps all-projects-desc)))
+  (-> target-projects
+      (conj source-project)
+      (pr/read-all-target-project-clj)
+      (deps/check-deps)))

 (def SYNC-COMMANDS {:default {:update "" :test ""}
                     :deps    deps


Added sample jayq dependency

Added sample jayq dependency

--- src/leiningen/new/fwrum/project.clj
+++ src/leiningen/new/fwrum/project.clj
@@ -7,7 +7,8 @@
   :dependencies [[org.clojure/clojure "1.7.0"]
                  [org.clojure/clojurescript "0.0-3297"]
                  [org.clojure/core.async "0.1.346.0-17112a-alpha"]
-                 [rum "0.2.7"]]
+                 [rum "0.2.7"]
+                 [jayq "2.5.4"]]

   :plugins [[lein-cljsbuild "1.0.5"]
             [lein-figwheel "0.3.5"]]


fix refer warnings

fix refer warnings

--- src/main/clojure/dojo/solutions.clj
+++ src/main/clojure/dojo/solutions.clj
@@ -1,6 +1,7 @@
 (ns dojo.solutions
   (:use clojure.core.matrix)
-  (:use clojure.core.matrix.operators)
+  (:refer-clojure :exclude [+ - * / == ])
+  (:require [clojure.core.matrix.operators :refer [+ - * / ==]])
   (:use clojure.repl)
   (:use dojo.data))

@@ -16,7 +17,7 @@
 ;; matrix of away games for each team: 1 = home game, 0 = otherwise
 (def AWAY-GAMES (vec (for [team TEAMS] (mapv #(if (= team (mget % (COL-NUMS "AwayTeam"))) 1 0) (slices RESULTS)))))

-;; vectors of result types for each match
+;; vectors of result types for each match
 (def HWINS (mapv #(if (= "H" (mget % (COL-NUMS "FTR"))) 1 0) (slices RESULTS)))
 (def DRAWS (mapv #(if (= "D" (mget % (COL-NUMS "FTR"))) 1 0) (slices RESULTS)))
 (def AWINS (mapv #(if (= "A" (mget % (COL-NUMS "FTR"))) 1 0) (slices RESULTS)))


Minor code style change.

Minor code style change.

--- src/suricatta/impl.clj
+++ src/suricatta/impl.clj
@@ -67,7 +67,7 @@
   "Wraps a value that implements IParamType
   protocol in valid jOOQ Param implementation."
   [value]
-  (->
+  (suricatta.impl.ParamWrapper.
    (reify suricatta.impl.IParam
      (render [_ ^RenderContext ctx]
        (let [sql (proto/render value)]
@@ -75,8 +75,7 @@
      (bind [_ ^BindContext ctx]
        (let [stmt  (.statement ctx)
              index (.nextIndex ctx)]
-         (proto/bind value stmt index))))
-   (suricatta.impl.ParamWrapper.)))
+         (proto/bind value stmt index))))))

 (defn wrap-if-need
   [obj]


core helper functions to handle terraform_remote_state

--- src/terraboot/core.clj
+++ src/terraboot/core.clj
@@ -27,9 +27,9 @@
           [fn-seq]
           (partial merge-with
                    ((first fn-seq) (rest fn-seq))))]
+  ;; todo rediscover duplicates but not for the :output tree
   (def merge-in
-    (merge-with-fn-seq (conj (repeat merge-in*) sensitive-merge-in*
-                             merge-in*))))
+    (merge-with-fn-seq (repeat merge-in*))))

 (defn output-of [type resource-name & values]
   (str "${"
@@ -57,6 +57,12 @@
                                      (#(if (get-in % [:tags :Name])
                                          (assoc-in % [:tags :Name] (name-fn (get-in % [:tags :Name])))
                                          %))))))
+
+(defn output
+  [output-name type resource-name value]
+  {:output
+   {output-name
+    {:value (output-of type resource-name value)}}})

 (defn provider [type spec]
   {:provider
@@ -336,3 +342,13 @@
    (security-group (str "db-" name) {}
                    {:port 5432
                     :source_security_group_id (id-of "aws_security_group" (str "uses-db-" name))})))
+
+(defn remote-state [name]
+  (resource "terraform_remote_state" name
+            {:backend "s3"
+             :config {:bucket "terraboot"
+                      :key (str name ".tf")
+                      :region region}}))
+
+(defn remote-output-of [module name]
+  (output-of (str "terraform_remote_state." module) "output" name))


Make uberjar work at the command line with the name circle.Init.

--- backend/src/circle/init.clj
+++ backend/src/circle/init.clj
@@ -7,7 +7,7 @@
   ;; (:require circle.backend.nodes
   ;;           circle.backend.project.rails
   ;;           circle.backend.project.circle)
-  (:gen-class :name circle.Init :main true)
+  (:gen-class :name circle.Init)
   )

 (def init*


AB + CW | 22 | dissocing csrf-token from session before sending request to clauth-authorize endpoint

--- src/stonecutter/controller/oauth.clj
+++ src/stonecutter/controller/oauth.clj
@@ -22,6 +22,7 @@

 (defn authorise [request]
   (let [user (get-in request [:session :user])
+        request (update-in request [:session] dissoc :csrf-token)
         access-token (get-in request [:session :access_token])
         client-id (get-in request [:params :client_id])
         response (auth-handler (assoc-in request [:headers "accept"] "text/html"))]


breadcrumbs on "still awaiting" page

breadcrumbs on "still awaiting" page

--- src/strifescript/views/dashboard.clj
+++ src/strifescript/views/dashboard.clj
@@ -252,6 +252,7 @@
         scripts-by-team (zipmap (map :team-id all-scripts) all-scripts)]
     (layout
      [:div.page-header [:h1 "Still awaiting actions for some teams for " (models/exchange-name exchange)]]
+     (breadcrumbs ["Dashboard" (url-for page-dashboard)] [(str "Conflict: " (h (:name conflict))) (url-for page-conflict {:id (:id conflict)})] (models/exchange-name exchange))
      (row (span6
            [:table.table.table-condensed
             [:thead [:tr [:th "Team Name"]]]


More refinement of vault.data ideas.

More refinement of vault.data ideas.

--- src/vault/data.clj
+++ src/vault/data.clj
@@ -3,7 +3,13 @@
   (:require
     [clojure.string :as string]
     [fipp.printer :refer [pprint-document]]
-    [puget.printer :as puget]))
+    [puget.printer :as puget])
+  (:import
+    java.nio.charset.Charset))
+
+
+(def ^:private ^:const blob-charset
+  (Charset/forName "UTF-8"))

 (def ^:private ^:const blob-width
@@ -11,46 +17,31 @@
   100)

-; TODO: should this be a multimethod? byte arrays can be serialized 'raw'
-; and other structures can be printed canonically.
-(defn edn-blob
-  "Returns a canonical EDN representation suitable for serializing to a blob."
+(def ^:private ^:const blob-header
+  "Magic header which must appear as the first characters in a data blob."
+  "#vault/data")
+
+
+(defn- serialize-value
+  "Returns the canonical EDN representation for the given Clojure value."
   [value]
-  (let [doc (binding [puget/*colored-output* false
-                      puget/*strict-mode* true]
-              (puget/canonize value))
-        doc (if (puget/tagged-value-doc? doc)
-              (let [[op tag sep & more] doc]
-                `[~op ~tag :line ~@more])
-              doc)]
-    (-> doc
-        (pprint-document {:width blob-width})
+  (binding [puget/*colored-output* false
+            puget/*strict-mode* true]
+    (-> value
+        (puget/pprint {:width blob-width})
         with-out-str
         string/trim)))

-; PROBLEM:
-; An indexer is given a blob to index. From just the byte content, how can the
-; indexer tell (1) whether the blob has EDN content and (2) what type of data
-; does the content represent?
-;
-; IDEAS:
-; In some cases, the blob will be EXPECTED to contain EDN data, such as if a
-; content-type header specifies "application/edn", or if the value was linked
-; by another piece of data.
-;
-; From experiments trying to read randomly-generated byte sequences as EDN, if
-; the reader either throws an exception or returns a symbol, it's not a valid
-; EDN data blob.
-
-
-; PROBLEM:
-; Inline signatures need to sign the bytes which form the "primary value" in an
-; EDN data blob.
-;
-; IDEAS:
-; Write middle-layer proxy for InputStream or PushbackReader to capture bytes
-; from the beginning of the blob to one value read from the EDN reader.
+(defn edn-blob
+  "Returns a canonical EDN representation suitable for serializing to a blob."
+  [value]
+  (let [edn (serialize-value value)
+        metadata (select-keys (meta value) [:type :vault/version])
+        lines (if (empty? metadata)
+                [blob-header edn]
+                [blob-header (str \^ (serialize-value metadata)) edn])]
+    (string/join \newline lines)))

 (def data-readers
@@ -58,11 +49,18 @@
    'uri puget/read-uri})

-(defn read-blob
+(defn read-data
   "Reads the given input stream and attempts to parse it as an EDN data
   structure. If the data is not EDN, it returns a byte array of the blob
   contents."
   [input]
-  ; TODO: write blob data reader which either returns the parsed data structure
-  ; or some indication that it's raw byte data.
+  ; input > capturing proxy > InputStreamReader > PushbackReader
+  ; input > PushbackInputStream > capturing proxy > InputStreamReader > PushbackReader
+  ; - read first (count blob-header) bytes from the stream
+  ; - if no match, unread the bytes before returning the PushbackInputStream
+  ; - otherwise, read remainder of stream and parse out EDN value(s)
+  ; - first value is primary value - then save the output of the capturing proxy
+  ;     - ideally, disable it
+  ; - read remaining values (just signatures?)
+  ;     - attach as value metadata?
   nil)


Fix #24 by removing protocol overrides

Fix #24 by removing protocol overrides

--- src/tick/interval.cljc
+++ src/tick/interval.cljc
@@ -394,21 +394,6 @@
   (new-interval (t/beginning t) (t/end t)))

 (extend-protocol t/ITimeComparison
-  LocalDate
-  (< [x y] (t/< (interval x) (interval y)))
-  (<= [x y] (t/<= (interval x) (interval y)))
-  (> [x y] (t/> (interval x) (interval y)))
-  (>= [x y] (t/>= (interval x) (interval y)))
-  YearMonth
-  (< [x y] (t/< (interval x) (interval y)))
-  (<= [x y] (t/<= (interval x) (interval y)))
-  (> [x y] (t/> (interval x) (interval y)))
-  (>= [x y] (t/>= (interval x) (interval y)))
-  Year
-  (< [x y] (t/< (interval x) (interval y)))
-  (<= [x y] (t/<= (interval x) (interval y)))
-  (> [x y] (t/> (interval x) (interval y)))
-  (>= [x y] (t/>= (interval x) (interval y)))
   #?(:clj clojure.lang.APersistentMap :cljs PersistentArrayMap)
   (< [x y] (#{precedes? meets?} (basic-relation x y)))
   (<= [x y] (#{precedes? meets? equals? starts? overlaps? finished-by?} (basic-relation x y)))


added R for shuffle

added R for shuffle

--- src/tile_game/core.clj
+++ src/tile_game/core.clj
@@ -42,8 +42,10 @@
                          (doseq [piece moves]
                            (dosync (alter *board* slide piece))
                            (.repaint panel)
-                           (Thread/sleep 150)))))]
-    (dosync (ref-set *board* (create-board dim :shuffle)))
+                           (Thread/sleep 150)))))
+        shuffle-board! (fn [dim] (dosync (ref-set *board*
+                                                  (create-board dim :shuffle))))]
+    (shuffle-board! dim)
     (doto panel
       (.setPreferredSize (Dimension. size size))
       (.setFocusable true)
@@ -56,9 +58,10 @@
                          KeyEvent/VK_UP    (slide! :up)
                          KeyEvent/VK_DOWN  (slide! :down)
                          KeyEvent/VK_Q     (.dispose #^JFrame frame)
+                         KeyEvent/VK_R     (do (shuffle-board! dim) (.repaint panel))
                          KeyEvent/VK_S     (apply slide! (solve-next @*board*))
                          true)))))
     (doto frame (.setContentPane panel) .pack .show)
     slide!))

-(def slide! (main 3))
+(def slide! (main 5))


Add IPathRepr impl for `nil` and `keyword`.

--- src/bide/core.cljs
+++ src/bide/core.cljs
@@ -36,12 +36,15 @@
   (-replace-location [_ loc params]))

 (defprotocol IPathRepr
+  "Path parameters coercion protocol."
   (-repr [_] "Return a representation of object in path."))

 (extend-protocol IPathRepr
+  nil    (-repr [it] "")
   object (-repr [it] (str it))
   number (-repr [it] it)
-  string (-repr [it] it))
+  string (-repr [it] it)
+  cljs.core.Keyword (-repr [it] (name it)))

 ;; --- Low Level Routes API


curry indentation fixes

curry indentation fixes

--- src/cats/core.cljc
+++ src/cats/core.cljc
@@ -275,21 +275,21 @@
          ((((c+) 1) 2) 3)
          ;; => 6
      "
-    ([f]
-     (if (not (symbol? f))
-       (throw (IllegalArgumentException. "You must provide an arity for currying anonymous functions"))
-       (let [fvar (resolve f)]
-         (if-let [args (arglists fvar)]
-           (if (single-arity? fvar)
-             `(curry ~(arity fvar) ~f)
-             (throw (IllegalArgumentException. "The given function is either variadic or has multiple arities, provide an arity for currying.")))
-           (throw (IllegalArgumentException. "The given function doesn't have arity metadata, provide an arity for currying."))))))
-    ([n f]
-     {:pre [(or (< n 21)
-                (throw (IllegalArgumentException. "Clojure doesn't allow more than 20 positional arguments")))]}
-     (let [args (repeatedly n gensym)
-           body `(~f ~@args)]
-       `(curry* ~args ~body)))))
+     ([f]
+      (if (not (symbol? f))
+        (throw (IllegalArgumentException. "You must provide an arity for currying anonymous functions"))
+        (let [fvar (resolve f)]
+          (if-let [args (arglists fvar)]
+            (if (single-arity? fvar)
+              `(curry ~(arity fvar) ~f)
+              (throw (IllegalArgumentException. "The given function is either variadic or has multiple arities, provide an arity for currying.")))
+            (throw (IllegalArgumentException. "The given function doesn't have arity metadata, provide an arity for currying."))))))
+     ([n f]
+      {:pre [(or (< n 21)
+                 (throw (IllegalArgumentException. "Clojure doesn't allow more than 20 positional arguments")))]}
+      (let [args (repeatedly n gensym)
+            body `(~f ~@args)]
+        `(curry* ~args ~body)))))

 #?(:clj
    (defmacro lift-m


Added no-prefix helper func.

Added no-prefix helper func.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -16,6 +16,8 @@
 (println cbfg.ddl/hi)

 ;; ------------------------------------------------
+
+(defn no-prefix [s] (string/join "-" (rest (string/split s #"-"))))

 (defn get-el-value [elId] (.-value (gdom/getElement elId)))

@@ -269,8 +271,7 @@
                                       (put! step-ch true))}]
     (go-loop [run-control-ch (merge (map #(listen (gdom/getElement (str el-prefix "-" %)) "click")
                                          (keys run-controls)))]
-      ((get run-controls (string/join "-" (rest (string/split (.-id (.-target (<! run-control-ch)))
-                                                              #"-")))))
+      ((get run-controls (no-prefix (.-id (.-target (<! run-control-ch))))))
       (recur run-control-ch))))

 ;; ------------------------------------------------
@@ -339,8 +340,7 @@
            (make-fenced-pump world in-ch out-ch @max-inflight)))
     (let [toggle-ch (listen (gdom/getElement (str el-prefix "-html")) "click")]
       (go-loop []
-        (let [actx-id (string/join "-" (rest (string/split (.-id (.-target (<! toggle-ch)))
-                                                           #"-")))]
+        (let [actx-id (no-prefix (.-id (.-target (<! toggle-ch))))]
           (doseq [[actx actx-info] (:actxs @vis)]
             (when (= actx-id (last actx))
               (swap! vis #(assoc-in % [:actxs actx :closed] (not (:closed actx-info))))))


Refactored: unnecessary [[]] to []

Refactored: unnecessary [[]] to []

--- src/varjocafe/view.clj
+++ src/varjocafe/view.clj
@@ -9,22 +9,22 @@

 (html/defsnippet date-cell "templates/layout.html" [:.date]
                  [date]
-                 [[:.date]] (html/content (.print date-format date)))
+                 [:.date] (html/content (.print date-format date)))

 (html/defsnippet food-line "templates/layout.html" [:.food]
                  [food]
-                 [[:.food]] (html/content (:name food)))
+                 [:.food] (html/content (:name food)))

 (html/defsnippet menu-cell "templates/layout.html" [:.menu]
                  [restaurant date]
-                 [[:.food]] (html/clone-for [food (get-in restaurant [:menu date :data])]
-                                            (html/substitute (food-line food))))
+                 [:.food] (html/clone-for [food (get-in restaurant [:menu date :data])]
+                                          (html/substitute (food-line food))))

 (html/defsnippet restaurant-row "templates/layout.html" [:.restaurant-row]
                  [restaurant dates]
-                 [[:.restaurant-name]] (html/content (:name restaurant))
-                 [[:.menu]] (html/clone-for [date dates]
-                                            (html/substitute (menu-cell restaurant date))))
+                 [:.restaurant-name] (html/content (:name restaurant))
+                 [:.menu] (html/clone-for [date dates]
+                                          (html/substitute (menu-cell restaurant date))))

 (html/defsnippet area-restaurants "templates/layout.html" [#{:.area-row :.restaurant-row}]
                  [area dates]


Refactored: use clone-for instead of map

--- src/varjocafe/view.clj
+++ src/varjocafe/view.clj
@@ -17,26 +17,29 @@

 (html/defsnippet menu-cell "templates/layout.html" [:.menu]
                  [restaurant date]
-                 [[:.food]] (html/substitute (map #(food-line %) (get-in restaurant [:menu date :data]))))
+                 [[:.food]] (html/clone-for [food (get-in restaurant [:menu date :data])]
+                                            (html/substitute (food-line food))))

 (html/defsnippet restaurant-row "templates/layout.html" [:.restaurant-row]
                  [restaurant dates]
                  [[:.restaurant-name]] (html/content (:name restaurant))
-                 [[:.menu]] (html/substitute (map #(menu-cell restaurant %) dates)))
+                 [[:.menu]] (html/clone-for [date dates]
+                                            (html/substitute (menu-cell restaurant date))))

 (html/defsnippet area-restaurants "templates/layout.html" [#{:.area-row :.restaurant-row}]
                  [area dates]
                  [:.area-name] (html/set-attr :colspan (+ 1 (count dates)))
                  [:.area-name] (html/content (:name area))
-                 [:.restaurant-row] (html/substitute (map #(restaurant-row % dates)
-                                                          (:restaurants area))))
+                 [:.restaurant-row] (html/clone-for [restaurant (:restaurants area)]
+                                                    (html/substitute (restaurant-row restaurant dates))))

 (html/deftemplate layout "templates/layout.html"
                   [{:keys [dates areadata]}]
-                  [:.date] (html/substitute (map #(date-cell %) dates))
-                  [:.restaurant-row] nil                    ; inserted by area-restaurants
-                  [:.area-row] (html/substitute (map #(area-restaurants % dates)
-                                                     areadata)))
+                  [:.date] (html/clone-for [date dates]
+                                           (html/substitute (date-cell date)))
+                  [:.restaurant-row] nil                    ; will be inserted by area-restaurants
+                  [:.area-row] (html/clone-for [area areadata]
+                                               (html/substitute (area-restaurants area dates))))

 (defn main-page [data settings]
   (layout {:dates    (take 5 (core/dates data))


Make the Android project target Java 7

Make the Android project target Java 7

--- android/project.clj
+++ android/project.clj
@@ -7,7 +7,7 @@

   :source-paths ["src/clojure" "../common/clojure"]
   :java-source-paths ["src/java" "../common/java" "gen"]
-  :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
+  :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]

   :dependencies [[com.h2database/h2 "1.3.173"]
                  [markdown-clj "0.9.33"]


Minor changes

Minor changes

--- src/whisper2cyanite/metric_store.clj
+++ src/whisper2cyanite/metric_store.clj
@@ -35,8 +35,8 @@

 (defn- log-error
   "Log a error."
-  [e tenant rollup period path time]
-  (wlog/error (str "Metric store error: " e ", "
+  [error tenant rollup period path time]
+  (wlog/error (str "Metric store error: " error ", "
                    "tenant: " tenant ", "
                    "rollup " rollup ", "
                    "period: " period ", "
@@ -48,13 +48,13 @@
   [session statement chan-size data-stored?]
   (let [ch (async/chan chan-size)]
     (utils/go-while (not @data-stored?)
-                    (let [values (async/<! ch)]
-                      (if values
-                        (let [[_ _ tenant rollup period path time] values]
+                    (let [value (async/<! ch)]
+                      (if value
+                        (let [[_ _ tenant rollup period path time] value]
                           (try
                             (async/take!
                              (alia/execute-chan session statement
-                                                {:values values
+                                                {:values value
                                                  :consistency :any})
                              (fn [rows-or-e]
                                (if (instance? Throwable rows-or-e)


소스코드 인용 추가

소스코드 인용 추가


줄이 두번 나뉘어야 문단이 바뀐다

줄이 두번 나뉘어야 문단이 바뀐다


added support for :paredit-open-curly

added support for :paredit-open-curly

--- ccw.core/src/ccw/editors/antlrbased/PareditAutoEditStrategy.clj
+++ ccw.core/src/ccw/editors/antlrbased/PareditAutoEditStrategy.clj
@@ -13,7 +13,10 @@
   [] [[] (ref {})])

 ; TODO move this into paredit itself ...
-(def *one-char-command* {"(" :paredit-open-round "[" :paredit-open-square })
+(def *one-char-command*
+  {"(" :paredit-open-round
+   "[" :paredit-open-square
+   "{" :paredit-open-curly })

 (defn -customizeDocumentCommand
   [#^IAutoEditStrategy this, #^IDocument document, #^DocumentCommand command]


fix shutdown_app to cope with recent changes

--- test-resources/shutdown_app/main.clj
+++ test-resources/shutdown_app/main.clj
@@ -8,7 +8,9 @@

 (defn -main
   [& args]
-  (trapperkeeper/bootstrap ["--bootstrap-config" "test-resources/shutdown_app/bootstrap.cfg"])
+  (trapperkeeper/bootstrap
+    {:config "./test-resources/config/empty.ini"
+     :bootstrap-config "test-resources/shutdown_app/bootstrap.cfg"})
   (println "Waiting 60 seconds for a shutdown signal - use Ctrl-C or kill.")
   (println "You should see a message printed out when services are being shutdown.")
   (Thread/sleep 60000))


tweak starting width

tweak starting width

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspaces_list.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspaces_list.cljs
@@ -127,8 +127,8 @@
                                [:div {:style {:padding "1.1em 0 0 14px"
                                               :fontStyle (when-not description "oblique")}}
                                 (or description "No description provided")])}
-          {:header "Access Level" :starting-width 400 :sort-by WSAccessLevelKeyFunc
-           :sort-initial :asc
+          {:header "Access Level"
+           :sort-by WSAccessLevelKeyFunc :sort-initial :asc
            :content-renderer
            (fn [accessLevel]
              [:div {:style {:padding "1.1em 0 0 14px"}}


Precompute (floor (sqrt x)) operation in problem66.clj

Improves run time from ~800ms to ~500ms

--- euler_clojure/src/euler/problem66.clj
+++ euler_clojure/src/euler/problem66.clj
@@ -29,18 +29,19 @@
   ;; See problem64.clj for a link explaining this algorithm. Here we use 'D'
   ;; in place of 'S' to be consistent with the wording of the question.
   [D]
-  (map (comp int :a)
-       (iterate
-         (fn [{m :m d :d a :a}]
-           (let [next-m (- (* d a) m)
-                 next-d (/ (- D (expt next-m 2)) d)
-                 next-a (floor (/ (+ (floor (sqrt D)) next-m) next-d))]
-             {:m next-m
-              :d next-d
-              :a next-a}))
-         {:m 0
-          :d 1
-          :a (floor (sqrt D))})))
+  (let [floor-sqrt-D (floor (sqrt D))]
+    (map (comp int :a)
+         (iterate
+           (fn [{m :m d :d a :a}]
+             (let [next-m (- (* d a) m)
+                   next-d (/ (- D (expt next-m 2)) d)
+                   next-a (floor (/ (+ floor-sqrt-D next-m) next-d))]
+               {:m next-m
+                :d next-d
+                :a next-a}))
+           {:m 0
+            :d 1
+            :a floor-sqrt-D}))))

 (defn cont-frac
   "Return the continued fraction of the given values."


Use out counter for direct pcap foo.

Use out counter for direct pcap foo.

--- src/dsbdp/main.clj
+++ src/dsbdp/main.clj
@@ -109,7 +109,7 @@
                     (cond
                       (= "pcap-direct" scenario) (fn []
                                                    (proc-fn in-data)
-                                                   (.inc in-cntr))
+                                                   (.inc out-cntr))
                       (not (nil? in-data)) (fn []
                                              (doseq [i (repeat 1000 0)]
                                                (in-fn in-data)


remove old mocktridenttuple test (class was removed)

--- test/marceline/testing/functions.clj
+++ test/marceline/testing/functions.clj
@@ -1,16 +1,7 @@
 (ns marceline.testing.functions
-  (:import [storm.trident.testing MockTridentTuple])
   (:require [marceline.storm.testing :refer :all]
             [marceline.storm.trident :as t]
             [clojure.test :refer :all]))
-
-(deftest mock-tuple
-  (let [^MockTridentTuple tuple (MockTridentTuple. ["a" "b" "c"] [1 "bar" 4.3])]
-    (is (= 1 (t/first tuple)))
-    (is (= 4.3 (t/nth tuple 2)))
-    (is (= 3 (t/count tuple)))
-    (is (= [1 "bar" 4.3] (t/vals tuple)))
-    (is (= "bar" (t/get tuple "b")))))

 (deftest test-new-mock-tuple
   (let [tuple (new-mock-tuple :a 1 :b "bar" :c 4.3)]
@@ -44,4 +35,4 @@
   (is (= [[4]] (run-function t-double :a 2)))
   (is (= [[6]] (run-function multiply-x-y :x 2 :y 3)))
   (is (= [[0] [1] [2] [3] [4]] (run-function emit-five)))
-  (is (= [[2 4]] (run-function emit-orig-and-double :a 2))))+  (is (= [[2 4]] (run-function emit-orig-and-double :a 2))))


Removed redundant test.

Removed redundant test.

--- test/re-com/selection_list_test.cljs
+++ test/re-com/selection_list_test.cljs
@@ -41,25 +41,3 @@
       (is (false? (:multi-select? props))  "Expected :multi-select? to default to true.")))

-(deftest test-selection-list-with-id-fn
-  (let [selected (reagent/atom #{"2"})
-        new-comp (reagent/render-component
-                   [s-list/selection-list
-                    :choices [{:id "1" :name "item 1"} {:id "2" :name "item 2"} {:id "3" :name "item 3"}]
-                    :model selected
-                    :label-fn :name
-                    ;;:id-fn identity
-                    :on-change #(print "selected: " %)]
-                   (div-app))
-        props       (last (-> new-comp .-_renderedComponent .-props .-argv .-tail))
-        dom-node    (.getDOMNode new-comp)
-        firstCkGrp  (-> dom-node .-childNodes first .-childNodes first .-childNodes first .-childNodes)
-        firstCk     (first firstCkGrp)
-        firstLbl    (second firstCkGrp)]
-      (is (ifn?  (:id-fn props))       "Expected :id-fn to be a function.")
-      (is (ifn?  (:label-fn props))    "Expected :label-fn to be a function.")
-      (is (= "item 1" (.-textContent firstLbl)) "Expected label for the first check box to use the :name of the element.")
-      ;; Removed the next two lines as the click event doesn't update the model. Checkbox shows 'checked' after the click but no on-change is triggered.
-      #_(.click firstCk)
-      #_(is (= #{"1"} @selected) "Expected set of selected values to match first element.")))
-


New tests: test-get-test-jobs-prefix1/2

New tests: test-get-test-jobs-prefix1/2

--- test/emender_jenkins/config_test.clj
+++ test/emender_jenkins/config_test.clj
@@ -375,6 +375,23 @@
             (get-credentials-id {:configuration nil}) nil
             (get-credentials-id nil) nil)))

+(deftest test-get-test-jobs-prefix-1
+    "Check the behaviour of function emender-jenkins.config/get-test-jobs-prefix."
+    (testing "the behaviour of function emender-jenkins.config/get-test-jobs-prefix."
+        (are [x y] (= x y)
+            (get-test-jobs-prefix {:configuration {:jobs {:test-jobs-prefix nil}}})   nil
+            (get-test-jobs-prefix {:configuration {:jobs {:test-jobs-prefix false}}}) false
+            (get-test-jobs-prefix {:configuration {:jobs {:test-jobs-prefix true}}})  true
+            (get-test-jobs-prefix {:configuration {:jobs {:test-jobs-prefix "xyzzy"}}}) "xyzzy")))
+
+(deftest test-get-test-jobs-prefix-2
+    "Check the behaviour of function emender-jenkins.config/get-test-jobs-prefix."
+    (testing "the behaviour of function emender-jenkins.config/get-test-jobs-prefix."
+        (are [x y] (= x y)
+            (get-test-jobs-prefix {:configuration {:jobs nil}}) nil
+            (get-test-jobs-prefix {:configuration nil}) nil
+            (get-test-jobs-prefix nil) nil)))
+
 (deftest test-override-options-by-cli-1
     "Check the behaviour of function emender-jenkins.config/override-options-by-cli."
     (testing "the behaviour of function emender-jenkins.config/override-options-by-cli."


Test for function render-html-footer

Test for function render-html-footer

--- test/hurvinek/html_renderer_test.clj
+++ test/hurvinek/html_renderer_test.clj
@@ -137,3 +137,9 @@
             "test/expected/html_header3.html" (page/xhtml (render-html-header "http://10.20.30.40/" ""))
             "test/expected/html_header4.html" (page/xhtml (render-html-header "http://10.20.30.40/" "title")))))

+(deftest test-render-html-footer
+    "Checking the function hurvinek.html-renderer/render-html-footer."
+    (testing "the function hurvinek.html-renderer/render-html-footer."
+        (are [x y] (= (slurp x) y)
+            "test/expected/html_footer1.html" (page/xhtml (render-html-footer)))))
+


Did some stuff

Did some stuff

--- test/midje_doc/my_first_document.clj
+++ test/midje_doc/my_first_document.clj
@@ -20,7 +20,7 @@

 (fact
-  (+ 1 1) => 2
+  (+ 1 0) => 2
   (+ 1 3) => 2)

 (comment


show alert on email confirm

show alert on email confirm

--- src/webapp/client/init.cljs
+++ src/webapp/client/init.cljs
@@ -356,6 +356,12 @@
                 :endorsement-id (get-in @data-state [:submit :request :endorsement-id])}))
               ]
        (log (str "Submitted " @tt " " res))
+          (if (res :value)
+            (do
+              (update-data [:submit :status]  "Confirmed")
+              (js/alert "Email confirmed")
+              )
+            )
        )
      )
    )


find always by sid

find always by sid

--- s3/src/s3/blog.clj
+++ s3/src/s3/blog.clj
@@ -15,11 +15,15 @@
 (use-logging)

 (defn _id-to-id [mongo-object]
-  (let [id (str (:_id mongo-object))]
-    (-> mongo-object (dissoc :_id) (assoc :id id))))
+  (if (nil? mongo-object)
+    nil
+    (let [id (str (:_id mongo-object))]
+      (-> mongo-object (dissoc :_id) (assoc :id id)))))

 (defn id-to-sid [mongo-object]
-  (-> mongo-object (assoc :sid (:id mongo-object))))
+  (if (nil? mongo-object)
+    nil
+    (-> mongo-object (assoc :sid (:id mongo-object)))))

 (defn own? [user dbo]
   (= user (:user dbo)))
@@ -43,7 +47,7 @@
   {:drop []
    :transform {:distance to-human-distance
                :time to-human-time}
-   :validation [identity]})
+   :validation [identity :sid]})

 (defn from-db-to-user [obj]
   (-> obj (transform-fields-using from-db-to-user-transform) _id-to-id))
@@ -109,7 +113,7 @@
 (defn update-with [user blog]
   (let [new-blog (assoc blog :user user)
         id (:id new-blog)
-        db-object (find-blog-object id)]
+        db-object (find-blog-object-by-sid id)]
     (if (and (not= nil db-object) (own? user db-object))
       (-> new-blog
           (generate-title)
@@ -119,14 +123,16 @@
       (error "Db object deleted or not own. Refusing to update:" user new-blog id))))

 (defn find-by [user sid]
-  (info sid)
-  (let [obj (find-blog-object-by-sid sid)]
+  (let [obj (find-blog-object-by-sid sid)
+        user-obj (from-db-to-user obj)]
     (if (or (not (:draft obj)) (= (:user obj) user))
-      (from-db-to-user obj)
+      (if user-obj
+        user-obj
+        (error "cant find object" sid))
       (error "Cannot view draft from another user:" user sid))))

 (defn delete-by [user id]
-  (let [db-object (find-blog-object id)
+  (let [db-object (find-blog-object-by-sid id)
         oid (:_id db-object)]
     (if (and (not= nil db-object) (own? user db-object))
       {:id id


util.clj: (unique) uses second both for filtering and mapping.

--- clojure/org/gavrog/clojure/util.clj
+++ clojure/org/gavrog/clojure/util.clj
@@ -28,7 +28,7 @@
                       [seen nil false]
                       [(conj seen key) x true])))]
            (map second
-                (filter #(nth % 2) (reductions step [#{} nil false] coll)))))
+                (filter second (reductions step [#{} nil false] coll)))))
   ([coll]
     (unique identity coll)))


:no_mouth:

--- src/insta/core.clj
+++ src/insta/core.clj
@@ -42,17 +42,19 @@
 (defn get-images [x]
   "
   Get Images from Response
+  @param x
+  @return tuple of url's
   "
   (defn get-low-resolution-url [item]
     (if (contains? item :images)
-      (:url (:low_resolution (:images x)))
+      (:url (:low_resolution (:images item)))
       nil))

   (let [result (json/read-str (:body x) :key-fn keyword)
         data (:data result)]

-    ;; Remove
-    (map (fn [x] (:url (:low_resolution (:images x)))) data)))
+    ;; Remove nil and empty
+    (filter some? (map get-low-resolution-url data))))

 ;; Main


Put default protocol implementations at bottom

--- src/clj/rb.clj
+++ src/clj/rb.clj
@@ -56,10 +56,6 @@
   (clj->rb [_ _]
     nil)

-  Object
-  (clj->rb [v _]
-    v)
-
   clojure.lang.Keyword
   (clj->rb [v rt]
     (RubySymbol/newSymbol (ruby-runtime rt) (name v)))
@@ -74,13 +70,13 @@
     (reduce
       (fn [h [k v]] (doto h (.put (clj->rb k rt) (clj->rb v rt))))
       (RubyHash. (ruby-runtime rt))
-      v)))
+      v))
+
+  Object
+  (clj->rb [v _]
+    v))

 (extend-protocol Rb->Clj
-  Object
-  (rb->clj [v]
-    v)
-
   nil
   (rb->clj [_]
     nil)
@@ -97,7 +93,11 @@

   RubySymbol
   (rb->clj [v]
-    (keyword (str v))))
+    (keyword (str v)))
+
+  Object
+  (rb->clj [v]
+    v))

 (defn require
   "Requires each of `libs` in `rt`."


Fix misleading name

Fix misleading name

--- scripts/gosync.clj
+++ scripts/gosync.clj
@@ -87,7 +87,7 @@
    :buildNo (format "%s %s" pipelineRun stageRun)
    :build build})

-(defn send-to-go [builds]
+(defn put-to-buildviz [builds]
   (doseq [{jobName :jobName buildNo :buildNo build :build} builds]
     (println jobName buildNo build)
     (client/put (format "http://localhost:3000/builds/%s/%s" jobName buildNo)
@@ -100,4 +100,4 @@
               (map job-instances-for-stage
                    (stages-for-pipeline-group "Development")))))

-(send-to-go (map make-build-instance job-instances))
+(put-to-buildviz (map make-build-instance job-instances))


Make yaml snippet slightly more readable

--- frontend/components/integrations.cljs
+++ frontend/components/integrations.cljs
@@ -163,7 +163,11 @@
                        :text "The deployment of your application is configured through just a few lines of YAML that are kept safe in your source code. All you need to do to deploy to Heroku from CircleCI is configure your Heroku credentials in our UI, add a simple config file like this one into your project, and make a push. You can also easily deploy different branches to different Heroku apps (e.g. one for staging and one for production)."
                        :graphic [:div.console
                                  [:pre
-                                  "deployment:\n  staging:\n    branch: " [:span.value "master"] "\n    heroku:\n      appname: " [:span.value "my-app"]]]}
+                                  "deployment:\n"
+                                  "  staging:\n"
+                                  "    branch: " [:span.value "master"] "\n"
+                                  "      heroku:\n"
+                                  "        appname: " [:span.value "my-app"]]]}
                       {:title "Watch how to get started in minutes"
                        :text [:span "This video shows step-by-step how to configure CircleCI to test your application and deploy to Heroku, and how CircleCI keeps defects from getting into production. "
                     "See our docs for a " [:a {:href "/docs/continuous-deployment-with-heroku#part-2-multiple-environments"} "followup video"] " showing how to setup a more robust continuous delivery pipeline with staging and prod environments."]


Added description for the ontology_concept_record_gen rule

--- kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/pre-identifier-merge/step_a-ontology_to_ice/step_c/ontology_concept_record_gen.clj
+++ kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/pre-identifier-merge/step_a-ontology_to_ice/step_c/ontology_concept_record_gen.clj
@@ -3,6 +3,9 @@
 ;; -----------------------------------------------
 ;; creates ontology concept record for every ontology concept
 `{:name "ontology-concept-record-gen"
+  :description "This rule generates an instance of an Ontology Concept
+  Record (IAO_EXT_0000191) for each ontology concept, including field
+  values for the concept identifier, definition, and label."
   :head ((?/record rdf/type ccp/IAO_EXT_0000191) ; ontology concept record
          (?/record obo/BFO_0000051 ?/id_field_value) ; has part
          (?/id_field_value rdf/type ccp/IAO_EXT_0000194) ; id field value


delete side effect in rendering component

--- src-cljs/frontend/components/insights/project.cljs
+++ src-cljs/frontend/components/insights/project.cljs
@@ -330,8 +330,6 @@
                                     (map insights/add-queued-time))
               failed-tests (get-in state state/failed-builds-tests-path)
               junit-enabled? (get-in state state/failed-builds-junit-enabled?-path)]
-         (if (nil? failed-tests)
-           (assoc-in state state/failed-builds-tests-path []))
          (html
           [:div.insights-project
            (om/build insights-metadata state)


Pump the process-messages during the test.

--- test/ago/test.cljs
+++ test/ago/test.cljs
@@ -1,7 +1,8 @@
 (ns ago.test
   (:require-macros [cljs.core.async.macros :refer [go go-loop]]
                    [ago.macros :refer [ago]])
-  (:require [cljs.core.async :refer [chan close! <! >! alts! put! take!]]
+  (:require [cljs.core.async.impl.dispatch]
+            [cljs.core.async :refer [chan close! <! >! alts! put! take!]]
             [ago.core :refer [make-ago-world ago-chan ago-snapshot ago-restore
                               seqv+ compare-seqvs seqv-alive?]]
             [goog.dom :as gdom]
@@ -159,18 +160,26 @@
                     (>! ch0 :hi)
                     (>! ch0 :world)
                     (close! ch0)
-                    :sender-done)]
-    (go (println "ch1 got x" (<! ch1))
-        (println "ch1 got x" (<! ch1))
-        (println "ch1 got x" (<! ch1))
-        (println "echoer got x" (<! echoer))
-        (println "echoer got x" (<! echoer))
-        (println "sender got x" (<! sender))
-        (println "sender got x" (<! sender)))))
+                    :sender-done)
+        all-done (atom false)]
+    (go (assert (= {:msg :hi} (<! ch1)))
+        (assert (= {:msg :world} (<! ch1)))
+        (assert (= nil (<! ch1)))
+        (assert (= [:hi :world] (<! echoer)))
+        (assert (= nil (<! echoer)))
+        (assert (= :sender-done (<! sender)))
+        (assert (= nil (<! sender)))
+        (reset! all-done true))
+    (loop []
+      (when (not @all-done)
+        (cljs.core.async.impl.dispatch/process-messages)
+        (recur)))
+    @all-done))

 (defn ^:export run []
   (println "ago test run started.")
   (test-constructors)
   (test-seqvs)
   (test-put-take)
+  (println "ago test run PASS.")
   success)


The `X-Timestamp` header tells you when the reply was generated

--- src/layzee/adapters/web/api.clj
+++ src/layzee/adapters/web/api.clj
@@ -7,10 +7,12 @@
 (def content-type-plain-text {"Content-Type" "text/plain"})
 (def content-type-json {"Content-Type" "application/json"})

-(defn- ok[body] {
+(defn- ok
+  ([body] (ok content-type-json body))
+  ([headers body] {
                  :status  200
-                 :headers content-type-json
-                 :body    (json/write-str body)})
+                 :headers (merge headers content-type-json)
+                 :body    (json/write-str body)}))

 (defn- err[body] {
                  :status  500
@@ -23,7 +25,8 @@

 (defn- xxx[]
   (try
-   (ok (:result (lazy-web/run { :search-adapter-fn lazy-web-search })))
+   (let [reply (lazy-web/run { :search-adapter-fn lazy-web-search })]
+     (ok { "X-Timestamp" (str (:timestamp reply))} (:result reply)))
    (catch Exception e (err (str "caught exception: " (.getMessage e))))))

 (defn reply


Fix 'threadError' issue

Fix 'threadError' issue

Signed-off-by: Pratik Karki <48ee16e89cc3ed79ec6f449232f648624dd8c0a8@gmail.com>

--- src/lt/macros.cljc
+++ src/lt/macros.cljc
@@ -97,7 +97,7 @@
   [func]
   `(lt.objs.thread/thread*
     (fn ~(gensym "tfun") []
-      (let [orig# (js/argsArray js/arguments)
+      (let [orig# (js/argsArray (cljs.core/js-arguments))
             msg# (.shift orig#)
             args# (.map orig# cljs.reader/read-string)
             ~'raise (fn [obj# k# v#]


experimented with edit command (didn't work)

--- src/mapfs/core.clj
+++ src/mapfs/core.clj
@@ -1,6 +1,8 @@
 (ns mapfs.core
   (:require [clojure.string :as str]
-            [clojure.edn :as edn])
+            [clojure.edn :as edn]
+            ;[clojure.java.shell :refer [sh]]
+            )
   (:import [jline TerminalFactory TerminalFactory$Flavor]
            [jline.console ConsoleReader])
   (:gen-class :main true))
@@ -156,6 +158,14 @@
   "Move file to path. (Currently an alias to rename)."
   [src dest]
   (rename src dest))
+
+;(defn edit
+;  [value]
+;  (let [f (java.io.File/createTempFile "mapfs" "edn")]
+;    (spit f (pr-str value))
+;    (println f)
+;    (sh "vim" (.getAbsolutePath f)) ;; Doesn't work :(
+;    ))

 ;; SHELL COMMANDS


Make sure the charset is passed when returning the dtbook xml

--- src/mdr2/views.clj
+++ src/mdr2/views.clj
@@ -88,7 +88,8 @@
   (let [production (prod/find id)]
     (-> (dtbook production)
         response/response
-        (response/content-type "text/xml"))))
+        (response/content-type "text/xml")
+        (response/charset "UTF-8"))))

 (defn file-upload-form [request id & [errors]]
   (let [p (prod/find id)


When loading the next chapter, reset page to 1

--- src/cljs/comic_reader/handlers.cljs
+++ src/cljs/comic_reader/handlers.cljs
@@ -18,9 +18,10 @@
         (assoc db
                :page-list (next page-list)
                :waiting true)
-        new-location (assoc location :chapter
-                            (inc
-                             (read-string chapter)))]
+        new-location (assoc location
+                            :chapter (inc
+                                      (read-string chapter))
+                            :page 1)]
     (when (not page-list)
       (api/get-comic-pages site new-location))
     db))


Hot reloading fix.

Hot reloading fix.

--- src/cljs/org/broadinstitute/firecloud_ui/main.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/main.cljs
@@ -15,7 +15,8 @@

 ; Temporary replacement for the Broad Logo.
 (defn- text-logo []
-  [:div {:style {:fontSize "32px" :color (:button-blue style/colors) :fontWeight "bold"}} "FireCloud"])
+  [:div {:style {:fontSize "32px" :color (:button-blue style/colors) :fontWeight "bold"}}
+   "FireCloud"])

 (defn- footer []
   (let [thisyear (.getFullYear (js/Date.))
@@ -48,10 +49,10 @@
 (def top-nav-bar-items
   [{:key :workspaces
     :name "Workspaces"
-    :component workspaces/Page}
+    :render #(react/create-element workspaces/Page %)}
    {:key :methods
     :name "Method Repository"
-    :component method-repo/Page}])
+    :render #(react/create-element method-repo/Page %)}])

 (react/defc TopNavBarLink
@@ -99,7 +100,7 @@

         (let [item (first (filter #(= (% :key) page) top-nav-bar-items))]
           (if item
-            [(item :component) {:nav-context nav-context}]
+            ((item :render) {:nav-context nav-context})
             [:div {} "Page not found."]))]))})


New test format-date-using-desired-format-4 (AM/PM, era etc.)

--- test/clj_calendar/calendar_test.clj
+++ test/clj_calendar/calendar_test.clj
@@ -219,6 +219,20 @@
             (is (= "2000-02-01 10:20"  (format-date-using-desired-format calendar "yyyy-MM-dd hh:mm")))
             (is (= "2000-02-01 10:20:30"  (format-date-using-desired-format calendar "yyyy-MM-dd hh:mm:ss"))))))

+(deftest test-format-date-using-desired-format-4
+    "Check the function clj-calendar.calendar/format-date-using-desired-format"
+    (testing "the function clj-calendar.calendar/format-date-using-desired-format."
+        (let [calendar (get-calendar)]
+            (.set calendar 2000 01 01 10 20 30)
+            (is (= "AM"           (format-date-using-desired-format calendar "a")))
+            (is (= "AM"           (format-date-using-desired-format calendar "aa")))
+            (is (= "AM 2 AD"      (format-date-using-desired-format calendar "aa u GG"))))
+        (let [calendar (get-calendar)]
+            (.set calendar 2000 01 01 20 20 30)
+            (is (= "PM"           (format-date-using-desired-format calendar "a")))
+            (is (= "PM"           (format-date-using-desired-format calendar "aa")))
+            (is (= "PM 2 AD"      (format-date-using-desired-format calendar "aa u GG"))))))
+
 (deftest test-format-date-time-1
     "Check the function clj-calendar.calendar/format-date-time"
     (testing "the function clj-calendar.calendar/format-date-time"


test-read-description-1

--- test/clouseau/test_db_interface.clj
+++ test/clouseau/test_db_interface.clj
@@ -37,8 +37,10 @@
 ;;;

 (ns clouseau.test-db-interface
-  (:require [clojure.test :refer :all]
-            [clouseau.db-interface :refer :all]))
+  (:require [clojure.test           :refer :all]
+            [clouseau.db-interface  :refer :all]
+            [clojure.java.jdbc      :as jdbc]
+            [clouseau.db-spec       :as db-spec]))

 ;
 ; Common functions used by tests.
@@ -98,3 +100,18 @@
     (testing "if the clouseau.db-interface/store-changes definition exists."
         (is (callable? 'clouseau.db-interface/store-changes))))

+;
+; Tests for function behaviours
+;
+
+(deftest test-read-description-1
+    (testing "clouseau.db-interface/read-description"
+        ; use mock instead of jdbc/query
+        (with-redefs [jdbc/query (fn [product package] product)]
+            (let [product ["RHEL 6"
+                              {:classname   "org.sqlite.JDBC"
+                               :subprotocol "sqlite"
+                               :subname     "packages/rhel6/primary.sqlite"
+                           }]]
+            (is (= (second product) (read-description product "package-name")))))))
+