Formatting and add doc strings.

Formatting and add doc strings.

--- clj_record/core.clj
+++ clj_record/core.clj
@@ -8,7 +8,12 @@
 (defn table-name [model-name]
   (pluralize (if (string? model-name) model-name (name model-name))))

-(defn to-conditions [attributes]
+(defn to-conditions
+  "Converts the given attribute map into a clojure.contrib.sql style 'where-params,'
+  a vector containing a parameterized conditions string followed by ordered values for the parameters.
+  Conditions will be ANDed together.
+  Nil attributes will be turned into 'attr_name IS NULL' with no value in the vector."
+  [attributes]
   (let [[parameterized-conditions values] (reduce
       (fn [[parameterized-conditions values] [attribute value]]
         (if (nil? value)
@@ -18,7 +23,17 @@
       attributes)]
     (apply vector (str-utils/str-join " AND " parameterized-conditions) values)))

-(defn create [model-name attributes]
+(defn get-record
+  "Retrieves record by id, throwing if not found."
+  [model-name id]
+  (sql/with-connection db
+    (sql/with-query-results rows [(format "select * from %s where id = ?" (table-name model-name)) id]
+      (if (empty? rows) (throw (IllegalArgumentException. "Record does not exist")))
+      (merge {} (first rows)))))
+
+(defn create
+  "Inserts a record populated with attributes and returns it."
+  [model-name attributes]
   (sql/with-connection db
     (let
       [key-vector (keys attributes)
@@ -28,28 +43,30 @@
             (sql/with-query-results rows ["VALUES IDENTITY_VAL_LOCAL()"] (:1 (first rows))))] ; XXX: db-vendor-specific
       (get-record model-name id))))

-(defn get-record [model-name id]
-  (sql/with-connection db
-    (sql/with-query-results rows [(format "select * from %s where id = ?" (table-name model-name)) id]
-      (if (empty? rows) (throw (IllegalArgumentException. "Record does not exist")))
-      (merge {} (first rows)))))
-
-(defn find-records [model-name attributes]
+(defn find-records
+  "Returns a vector of records matching (-> attributes to-conditions)."
+  [model-name attributes]
   (let [[parameterized-where & values] (to-conditions attributes)
         select-query (format "select * from %s where %s" (table-name model-name) parameterized-where)]
     (sql/with-connection db
       (sql/with-query-results rows (apply vector select-query values)
         (doall (map #(merge {} %) rows))))))

-(defn update [model-name attributes]
+(defn update
+  "Updates by (partial-record :id), updating only those columns included in partial-record."
+  [model-name partial-record]
   (sql/with-connection db
-    (sql/update-values (table-name model-name) ["id = ?" (:id attributes)] (dissoc attributes :id))))
+    (sql/update-values (table-name model-name) ["id = ?" (:id partial-record)] (dissoc partial-record :id))))

-(defn destroy-record [model-name record]
+(defn destroy-record
+  "Deletes by (record :id)."
+  [model-name record]
   (sql/with-connection db
     (sql/delete-rows (table-name model-name) ["id = ?" (:id record)])))

-(defn destroy-records [model-name attributes]
+(defn destroy-records
+  "Deletes all records matching (-> attributes to-conditions)."
+  [model-name attributes]
   (sql/with-connection db
     (sql/delete-rows (table-name model-name) (to-conditions attributes))))

@@ -74,22 +91,29 @@
 (defn- setup-model-metadata [model-name]
   (dosync (commute all-models-metadata assoc model-name (ref {}))))

-(defmacro init-model [& options]
+(defmacro init-model
+  "Macro to turn a namespace into a 'model.'
+  The segment of the namespace following the last dot is used as the model-name.
+  Model-specific versions of most public functions in clj-record.core are defined
+  in the model namespace (where the model-name as first argument can be omitted).
+  Optional forms for associations and validation are specified here.
+  See clj_record/test/model/manufacturer.clj for an example."
+  [& option-groups]
   (let [model-name (last (str-utils/re-split #"\." (name (ns-name *ns*))))]
     (setup-model-metadata model-name)
-    (let [optional-forms (defs-from-option-groups model-name options)]
-    `(do
-      (defn ~'table-name [] (table-name ~model-name))
-      (defn ~'get-record [id#]
-        (get-record ~model-name id#))
-      (defn ~'find-records [attributes#]
-        (find-records ~model-name attributes#))
-      (defn ~'create [attributes#]
-        (create ~model-name attributes#))
-      (defn ~'update [attributes#]
-        (update ~model-name attributes#))
-      (defn ~'destroy-record [record#]
-        (destroy-record ~model-name record#))
-      (defn ~'validate [record#]
-        (clj-record.validation/validate ~model-name record#))
-      ~@optional-forms))))
+    (let [optional-defs (defs-from-option-groups model-name option-groups)]
+      `(do
+        (defn ~'table-name [] (table-name ~model-name))
+        (defn ~'get-record [id#]
+          (get-record ~model-name id#))
+        (defn ~'find-records [attributes#]
+          (find-records ~model-name attributes#))
+        (defn ~'create [attributes#]
+          (create ~model-name attributes#))
+        (defn ~'update [attributes#]
+          (update ~model-name attributes#))
+        (defn ~'destroy-record [record#]
+          (destroy-record ~model-name record#))
+        (defn ~'validate [record#]
+          (clj-record.validation/validate ~model-name record#))
+        ~@optional-defs))))


fix receiving of the first message

fix receiving of the first message

--- src/status_im/chat/handlers/receive_message.cljs
+++ src/status_im/chat/handlers/receive_message.cljs
@@ -106,7 +106,7 @@
 (register-handler :received-message-when-commands-loaded
   (u/side-effect!
     (fn [db [_ chat-id message]]
-      (if true #_(commands-loaded? db chat-id)
+      (if (commands-loaded? db chat-id)
         (dispatch [:received-message message])
         (s/execute-later
           #(dispatch [:received-message-when-commands-loaded chat-id message])


column width gardening

column width gardening

--- src/cellf/core.cljs
+++ src/cellf/core.cljs
@@ -36,7 +36,17 @@

 (defn capture-move [{:keys [ctx vid-node canvas-node vid-w vid-h]} cells]
-  (.drawImage ctx vid-node (/ (- vid-w vid-h) 2) 0 vid-h vid-h 0 0 capture-size capture-size)
+  (.drawImage
+   ctx
+   vid-node
+   (/ (- vid-w vid-h) 2)
+   0
+   vid-h
+   vid-h
+   0
+   0
+   capture-size
+   capture-size)
   (let [img-data (.toDataURL canvas-node "image/jpeg" 1)
         img-el   (js/Image.)
         pc       (promise-chan)]
@@ -84,7 +94,9 @@
       (let [even-inversions? (even? (inversions grid))]
         (or
           (and (odd? size) even-inversions?)
-          (and (even? size) (= even-inversions? (odd? (blank-at-row grid size)))))))))
+          (and
+           (even? size)
+           (= even-inversions? (odd? (blank-at-row grid size)))))))))

 (defn make-cell-list [size]
@@ -254,7 +266,17 @@
         (if-not (= idx :empty)
           (let [[x1 y1] (get-cell-xy idx grid-size)
                 [x2 y2] (get-cell-xy pos grid-size)]
-            (.drawImage playback-ctx img (* x1 s) (* y1 s) s s (* x2 s) (* y2 s) s s))))
+            (.drawImage
+             playback-ctx
+             img
+             (* x1 s)
+             (* y1 s)
+             s
+             s
+             (* x2 s)
+             (* y2 s)
+             s
+             s))))
       (.drawImage playback-ctx img 0 capture-size))))

@@ -315,7 +337,11 @@
                      :vid-w       vw
                      :vid-h       vh
                      :vid-ratio   (/ vw vh)
-                     :vid-offset  (* 100 (/ (max 1 (.abs js/Math (- vw vh))) (max 1 (* vw 2))))
+                     :vid-offset  (*
+                                   100
+                                   (/
+                                    (max 1 (.abs js/Math (- vw vh)))
+                                    (max 1 (* vw 2))))
                      :canvas-node canvas
                      :ctx         (.getContext canvas "2d")
                      :show-about? true
@@ -334,8 +360,8 @@
         (<! (paint-canvas! app idx))
         (.addFrame gif canvas #js {:delay ms :copy true}))
       (doto gif
-        (.on "finished" (fn [data]
-                          (om/update! app :result-gif (.createObjectURL js/URL data))
+        (.on "finished" (fn [_]
+                          (om/update! app :result-gif)
                           (om/update! app :gif-building? false)))
         (.render)))))

@@ -347,7 +373,8 @@
     (dom/div
       #js {:className
            (str "modal"
-             (when (or no-stream? media-error show-about? result-gif winner?) " active"))}
+             (when (or no-stream? media-error show-about? result-gif winner?)
+               " active"))}
       (cond
         media-error
           (dom/div nil
@@ -359,7 +386,9 @@
               (if camera-waiting?
                 [#js {:className "wait"} "hold on"]
                 [#js {:onClick get-camera!} "try again"]))
-            (dom/button #js {:onClick #(js/open source-url)} "view cellf source"))
+            (dom/button
+             #js {:onClick #(js/open source-url)}
+             "view cellf source"))

         no-stream?
           (dom/div nil
@@ -374,10 +403,13 @@
         result-gif
           (dom/div nil
             (dom/h1 nil "Your Cellf")
-            (dom/a #js {:href result-gif :download "cellf.gif" :className "download"}
+            (dom/a
+              #js {:href result-gif :download "cellf.gif" :className "download"}
               (dom/img #js {:src result-gif}))
             (:gif-result strings)
-            (dom/button #js {:onClick #(om/update! app :result-gif nil)} "✔ done"))
+            (dom/button
+              #js {:onClick #(om/update! app :result-gif nil)}
+              "✔ done"))

         winner?
           (dom/div nil
@@ -387,7 +419,9 @@
               (if gif-building?
                 [#js {:className "wait"} "hold on"]
                 [#js {:onClick #(make-gif app tick-ms)} "make gif replay"]))
-            (dom/button #js {:onClick #(set-grid-size! app grid-size)} "new game"))
+            (dom/button
+              #js {:onClick #(set-grid-size! app grid-size)}
+              "new game"))

         show-about?
           (dom/div nil
@@ -403,11 +437,15 @@
               (dom/a #js {:href home-url} "oxism.com")
               \.)

-            (dom/button #js {:onClick #(om/update! app :show-about? false)} "✔ got it"))))))
+            (dom/button
+              #js {:onClick #(om/update! app :show-about? false)}
+              "✔ got it"))))))

 (om/root
-  (fn [{:keys [stream moves tick tick-ms grid-size show-nums gif-building?] :as app} owner]
+  (fn [{:keys [stream moves tick tick-ms grid-size show-nums gif-building?]
+        :as app}
+       owner]
     (reify
       om/IDidMount
       (did-mount [_]
@@ -450,10 +488,11 @@
                   (str (inc tick) \/ (count moves)))

                 (dom/label #js {:htmlFor "show-nums"} "show numbers?")
-                (dom/input #js {:id       "show-nums"
-                                :type     "checkbox"
-                                :checked  show-nums
-                                :onChange #(om/update! app :show-nums (not show-nums))})
+                (dom/input
+                  #js {:id       "show-nums"
+                       :type     "checkbox"
+                       :checked  show-nums
+                       :onChange #(om/update! app :show-nums (not show-nums))})

                 (dom/label nil
                   (str "grid size (" grid-size \× grid-size ")")
@@ -463,23 +502,30 @@
                                 :min      "2"
                                 :max      "9"
                                 :step     "1"
-                                :onChange #(set-grid-size! app (js/parseInt (.. % -target -value)))})
+                                :onChange
+                                #(set-grid-size!
+                                  app
+                                  (js/parseInt (.. % -target -value)))})

                 (dom/label nil "playback speed")
-                (dom/input #js {:type     "range"
-                                :value    (- tick-ms)
-                                :min      "-1000"
-                                :max      "-30"
-                                :step     "10"
-                                :onChange #(set-tick-ms! app (- (js/parseInt (.. % -target -value))))})
+                (dom/input
+                  #js {:type     "range"
+                       :value    (- tick-ms)
+                       :min      "-1000"
+                       :max      "-30"
+                       :step     "10"
+                       :onChange #(set-tick-ms!
+                                    app
+                                    (- (js/parseInt (.. % -target -value))))})

                 (apply dom/button
                   (if gif-building?
                     [#js {:className "wait"} "hold on"]
                     [#js {:onClick #(make-gif app tick-ms)} "make gif"]))

-                (dom/button #js {:onClick #(om/update! app :show-about? true)} "help")
-
+                (dom/button
+                  #js {:onClick #(om/update! app :show-about? true)}
+                  "help")

                 (dom/p nil
                   (dom/a #js {:href source-url :target "_blank"} "source")


Fixes so that threats.clj compiles

Fixes so that threats.clj compiles

--- src/cia/threats.clj
+++ src/cia/threats.clj
@@ -166,7 +166,7 @@
   "See http://stixproject.github.io/data-model/1.2/campaign/CampaignType/"
   (merge
    m/GenericStixIdentifiers
-   {:timestamp Time
+   {:timestamp m/Time
     (s/optional-key :version) s/Str
     (s/optional-key :names) [s/Str]
     (s/optional-key :intended_effect) [m/IntendedEffect]
@@ -285,7 +285,7 @@
                                        m/OpenIOCSpecification)]

     ;; Extension fields:
-    (s/optional-key :expires) Time
+    (s/optional-key :expires) m/Time
     :producer s/Str

     ;; Not provided: handling
@@ -300,8 +300,8 @@
   "A feedback record at rest in the storage service"
   (merge Indicator
          {:owner s/Str
-          :created Time
-          :timestamp Time}))
+          :created m/Time
+          :timestamp m/Time}))

 ;; Incident
@@ -349,8 +349,8 @@
     (s/optional-key :source) m/Source
     (s/optional-key :security_compromise) m/SecurityCompromise
     (s/optional-key :discovery_method) m/DiscoveryMethod
-    (s/optional-key :coa_requested) [m/COARequested]
-    (s/optional-key :coa_taken) [m/COARequested]
+    (s/optional-key :coa_requested) [COARequested]
+    (s/optional-key :coa_taken) [COARequested]
     (s/optional-key :contact) m/Source
     (s/optional-key :history) m/History

@@ -378,7 +378,7 @@
    m/RelatedWrapper
    {:exploit_target  ExploitTargetReference}))

-(s/defschema ExploitTargets
+(s/defschema RelatedExploitTargets
   "See http://stixproject.github.io/data-model/1.2/ttp/ExploitTargetsType/"
   {(s/optional-key :scope) m/Scope
    :exploit_targets [RelatedExploitTarget]})


[CS] Fix dev.core config reading

[CS] Fix dev.core config reading

--- dev-src/dev/core.clj
+++ dev-src/dev/core.clj
@@ -8,7 +8,8 @@
             [vip.data-processor.validation.transforms :as t]
             [vip.data-processor.validation.zip :as zip]
             [vip.data-processor.db.postgres :as psql]
-            [vip.data-processor.s3 :refer [xml-filename]]))
+            [vip.data-processor.s3 :refer [xml-filename]]
+            [democracyworks.squishy.data-readers]))

 (def pipeline
   (concat [zip/unzip


Rename component function args

Rename component function args

--- dev/pot/core/ui.cljs
+++ dev/pot/core/ui.cljs
@@ -85,7 +85,7 @@
    :init-state {:channels channels}})

 (om/root
-  (fn [cursor owner]
+  (fn [_ _]
     (reify
       om/IDisplayName
       (display-name [_] "controls")


80 characters width in conexp.base

80 characters width in conexp.base

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

--- src/conexp/base.clj
+++ src/conexp/base.clj
@@ -10,7 +10,7 @@
   "Basic definitions for conexp-clj."
   (:require [clojure.math.combinatorics :as comb]))

-;;; def macros, inspired and partially copied from clojure.contrib.def, 1.3.0-SNAPSHOT
+;;; def macros, inspired and partially copied from clojure.contrib.def

 (defmacro def-
   "Same as def, but yields a private definition"
@@ -250,8 +250,8 @@
     (compare-order x y)))

 (defn order-by
-  "Returns a function on two arguments a and b that returns true if and only if b occurs
-  not after a in the given sequence (ascending order.)"
+  "Returns a function on two arguments a and b that returns true if and only if
+  b occurs not after a in the given sequence (ascending order.)"
   [sequence]
   (let [pos (zipmap sequence (range))]
     (fn [a b]
@@ -418,7 +418,8 @@
   given answer fulfills all given predicates."
   [prompt read & preds-and-fail-messages]
   (when-not (even? (count preds-and-fail-messages))
-    (illegal-argument "Every predicate needs to have a corresponding error message."))
+    (illegal-argument
+     "Every predicate needs to have a corresponding error message."))
   (let [predicates (partition 2 preds-and-fail-messages),
         sentinel   (Object.),
         read-fn    #(try (read) (catch Throwable _ sentinel))]
@@ -464,11 +465,13 @@
 (defmacro generic-equals
   "Implements a generic equals for class on fields."
   [[this other] class fields]
-  `(boolean (or (identical? ~this ~other)
-                (when (= (class ~this) (class ~other))
-                  (and ~@(map (fn [field]
-                                `(= ~field (. ~(vary-meta other assoc :tag class) ~field)))
-                              fields))))))
+  `(boolean
+    (or (identical? ~this ~other)
+        (when (= (class ~this) (class ~other))
+          (and ~@(map (fn [field]
+                        `(= ~field
+                            (. ~(vary-meta other assoc :tag class) ~field)))
+                      fields))))))

 (defn hash-combine-hash
   "Combines the hashes of all things given."
@@ -590,22 +593,24 @@
                      (long (/ power 2))))))))))

 (defn distinct-by-key
-  "Returns a sequence of all elements of the given sequence with distinct key values,
-  where key is a function from the elements of the given sequence. If two elements
-  correspond to the same key, the one is chosen which appeared earlier in the sequence.
-
-  This function is copied from clojure.core/distinct and adapted for using a key function."
+  "Returns a sequence of all elements of the given sequence with distinct key
+  values, where key is a function from the elements of the given sequence. If
+  two elements correspond to the same key, the one is chosen which appeared
+  earlier in the sequence.
+
+  This function is copied from clojure.core/distinct and adapted for using a key
+  function."
   [sequence key]
   (let [step (fn step [xs seen]
                (lazy-seq
-                 ((fn [xs seen]
-                    (when-let [s (seq xs)]
-                      (let [f     (first xs)
-                            key-f (key f)]
-                        (if (contains? seen key-f)
-                          (recur (rest s) seen)
-                          (cons f (step (rest s) (conj seen key-f)))))))
-                  xs seen)))]
+                ((fn [xs seen]
+                   (when-let [s (seq xs)]
+                     (let [f     (first xs)
+                           key-f (key f)]
+                       (if (contains? seen key-f)
+                         (recur (rest s) seen)
+                         (cons f (step (rest s) (conj seen key-f)))))))
+                 xs seen)))]
     (step sequence #{})))

 (defn reduce!
@@ -673,7 +678,8 @@
 ;;; Searching for minimum covers

 (defn- covers?
-  "Technical Helper. Tests wheterh all elements in base-set are contained at least one set in sets."
+  "Technical Helper. Tests wheterh all elements in base-set are contained at
+  least one set in sets."
   [sets base-set]
   (if (empty? base-set)
     true
@@ -687,9 +693,10 @@
             (recur new-rest (next sets))))))))

 (defn- redundant?
-  "Technical Helper. For a given set base-set, a collection cover of sets and a map mapping elements
-  from base-set to the number of times they occur in sets in cover, tests whether the cover is
-  redundant or not, i.e. if a proper subcollection of cover is already a cover or not."
+  "Technical Helper. For a given set base-set, a collection cover of sets and a
+  map mapping elements from base-set to the number of times they occur in sets
+  in cover, tests whether the cover is redundant or not, i.e. if a proper
+  subcollection of cover is already a cover or not."
   [base-set cover count]
   (exists [set cover]
     (forall [x set]
@@ -879,7 +886,7 @@

 (defn parallel-closures
   "Returns the set of all closures of the closure operator on the given base set.
-Computes the closures in parallel, to the extent possible."
+  Computes the closures in parallel, to the extent possible."
   [base clop]
   (loop [n        0
          closures #{(clop #{})}
@@ -1007,8 +1014,8 @@
       (contains? other-set x))))

 (defn minimal-hypergraph-transversals
-  "Returns all minimal hypergraph transversals of the hypergraph defined by «edges» on the
-  vertex sets «vertices»."
+  "Returns all minimal hypergraph transversals of the hypergraph defined by
+  «edges» on the vertex sets «vertices»."
   [vertices edges]
   (let [cards    (map-by-fn (fn [x]
                               (count (set-of X | X edges :when (contains? X x))))


add new (disabled) test

add new (disabled) test

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -248,6 +248,14 @@
              :comp (ps-tree comp morph)})
       (morph tree))))

+;; should fail fast: instead seems to run forever.
+(deftest difficult-generate
+  (let [synsem
+        {:synsem {:sem {:pred :be
+                        :subj {:pred :città}
+                        :obj {:pred :calzoni}}}}]
+    (is (or true ;; test won't complete (yet) without disabling with this 'or true'.
+            (not (nil? (generate synsem)))))))


add comment about a new roundtrip case

add comment about a new roundtrip case

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -78,6 +78,8 @@
 (deftest forbid-mispelling
  (is (empty? (parse (fo "la donna difficila") np-grammar))))

+;;babel.test.it> (take 1000 (repeatedly #(let [generated (fo (generate :top)) parsed (parse generated medium)] (log/info (str "generated: " generated)) (log/info (str "semantics: " (or (strip-refs (get-in (first parsed) [:synsem :sem])) "NO PARSE FOUND FOR: " generated))))))
+
 ;; <roundtrip parsing tests>
 ;; these tests will not pass if you
 ;; don't have enough linguistic material


cleanup

cleanup

--- solutions/day07/solution.clj
+++ solutions/day07/solution.clj
@@ -7,7 +7,7 @@
               "NOT" #(bit-not %)
               "SET" #(identity %)})

-(defn parse-input
+(defn make-input
   [x]
   (fn [circuit]
     (if (re-find #"^[0-9]+$" x)
@@ -20,10 +20,8 @@
         parts (str/split input #" ")
         commands (set (keys cmd->fn))
         cmd (or (first (filter commands parts)) "SET")
-        func (cmd->fn cmd)
-        operands (map parse-input (remove commands parts))]
-    {:instruction instruction
-     :fn func
+        operands (map make-input (remove commands parts))]
+    {:fn (cmd->fn cmd)
      :operands operands
      :target target
      :inputs (fn [circuit] (map #(% circuit) operands))}))


simplify copying in (moreover-comp)

simplify copying in (moreover-comp)

--- src/babel/over.cljc
+++ src/babel/over.cljc
@@ -188,10 +188,9 @@
           (do
             (log/trace (str "child: " child " failed pre-check."))
             :fail)
-          (unify
-           (copy parent)
-           (unifyc {:comp child}
-                   {:comp {:synsem {:sem (lexfn-sem-impl (get-in child '(:synsem :sem) :top))}}})))]
+          (unifyc parent
+                  {:comp child}
+                  {:comp {:synsem {:sem (lexfn-sem-impl (get-in child '(:synsem :sem) :top))}}}))]
     (if (not (fail? result))
       (merge {:comp-filled true}
              result)


tentative v0.1.0 releas

tentative v0.1.0 releas

--- src/hydrox/core.clj
+++ src/hydrox/core.clj
@@ -92,7 +92,17 @@
   ([state project]
    (Regulator. state project)))

+(defn once-off
+  [path]
+  (let [proj  (read-project (io/file path))
+        folio (-> proj
+                  (create-folio)
+                  (init-folio))
+        state (atom folio)]
+    (regulator state proj)))
+
 (defn import-docstring
+  ([] )
   ([reg] (import-docstring reg :all))
   ([reg ns] (import-docstring reg ns nil))
   ([{:keys [state project] :as reg} ns var]
@@ -149,7 +159,7 @@

   (:references @(:state reg))

-
+
   (import-docstring reg 'hydrox.doc.structure)
   (purge-docstring reg 'hydrox.analyse.test)


Improve a bit recommendation view

Improve a bit recommendation view

--- src/kmg/client.cljs
+++ src/kmg/client.cljs
@@ -42,11 +42,12 @@
      (clojure.string/join ", ")))

 (em/defsnippet recommendation tmpl ".recommendation" [{:keys [recommendation media backgrounds translations authors]}]
-  "#recommendation-title" (ef/content (str (:media/title media) " " (:media/type media)))
+  "#recommendation-title" (ef/content (str (:media/title media) " " ))
   "#recommendation-authors" (ef/content (authors-string authors))
   "#recommendation-description" (ef/content
-     (str (:recommendation/description recommendation)
-          " Necessary: " (:recommendation/necessary recommendation) " Priority: " (:recommendation/priority recommendation))
+     (str (:recommendation/description recommendation) " <br/> "
+          " Necessary: " (:recommendation/necessary recommendation) " Priority: " (:recommendation/priority recommendation)
+          " Type: " (:media/type media))
      )

   "#complete" (events/listen :click #(try-mark-as-completed recommendation))


Reflections.

Reflections.

--- src/cgdata/core.clj
+++ src/cgdata/core.clj
@@ -264,7 +264,7 @@
   [docroot referrer md]
   (let [refs (->> md
                   (keys)
-                  (filter #(.startsWith % ":")))]
+                  (filter #(.startsWith ^String % ":")))]
     (into {} (map vector refs (map
                                 #(when-let [path (md %)] ; don't resolve nil
                                    (str (path-from-ref docroot referrer path)))
@@ -419,7 +419,7 @@
   "Pick first non-blank line if it starts with #. Don't scan more
   than 20 lines."
   [lines]
-  (when-let [header (first (filter not-blank? (take 20 lines)))]
+  (when-let [^String header (first (filter not-blank? (take 20 lines)))]
     (when (comment? header)
       (subs header (inc (.indexOf header "#"))))))


Experimental put-to-chan idea

Experimental put-to-chan idea

--- src/zooniverse_live/project_list.cljs
+++ src/zooniverse_live/project_list.cljs
@@ -4,6 +4,12 @@
             [clojure.string :refer [trim-newline]]
             [om-tools.dom :as dom :include-macros true]
             [cljs.core.async :refer [<! put! chan]]))
+
+
+(defn put-to-chan
+  [chan & args]
+  (fn [e]
+    (apply put! chan args)))

 (defn project
   "Om component for new project"
@@ -15,7 +21,7 @@
               display_name
               (dom/div {:className "editor"}
                (dom/label "Enabled: "
-                          (dom/input {:type "checkbox" :checked enabled :onChange (fn [e] (put! disable project))}))
+                          (dom/input {:type "checkbox" :checked enabled :onChange (put-to-chan disable project)}))
                (dom/label "Color: "
                           (dom/input {:type "color" :value color :onChange (fn [e] (put! color-chan [project (.-value (.-target e))]))})))))))

@@ -47,7 +53,7 @@
       (dom/div
        (dom/div {:className "projects-title"}
                 (dom/h1 "Projects")
-                (dom/button {:type "button" :onClick (fn [e] (put! edit-mode true))} "Edit"))
+                (dom/button {:type "button" :onClick (put-to-chan edit-mode true)} "Edit"))
        (dom/ul {:className (when (:edit-mode data) "edit")}
                (om/build-all project
                              (filter #(or (:edit-mode data) (:enabled (second %))) (:projects data))


Nostettu scala-cas versio 1.1.0

Nostettu scala-cas versio 1.1.0

--- clj-cas/project.clj
+++ clj-cas/project.clj
@@ -4,7 +4,6 @@
   :license {:name "EUPL"
             :url "http://www.osor.eu/eupl/"}
   :plugins [[lein-modules "0.3.11"]]
-  :dependencies [[fi.vm.sade/scala-cas_2.12 "0.7.0-SNAPSHOT"]
-                 [org.http4s/http4s-blaze-client_2.12 "0.15.9"]]
-
+  :dependencies [[fi.vm.sade/scala-cas_2.12 "1.1.0-SNAPSHOT"]
+                 [org.http4s/http4s-blaze-client_2.12 "0.16.6a"]]
 )


Remove the let hack by inlining it exactly, which is the idiom. Somehow it didn't occur to me to try that.

--- clj_record/core.clj
+++ clj_record/core.clj
@@ -21,11 +21,9 @@
       (find-record model-name id))))

 (defmacro setup-model [model-name]
-  (let [find-record-fn-name 'find-record
-        create-fn-name 'create]
-    `[(defn ~find-record-fn-name [id#]
-        (find-record ~model-name id#))
-      (defn ~create-fn-name [attributes#]
-        (create ~model-name attributes#))]))
+  `[(defn ~'find-record [id#]
+      (find-record ~model-name id#))
+    (defn ~'create [attributes#]
+      (create ~model-name attributes#))])


better sente handling

better sente handling

--- src-cljs/frontend/sente.cljs
+++ src-cljs/frontend/sente.cljs
@@ -10,31 +10,22 @@
 (defn send-msg [sente-state message & [timeout-ms callback-fn :as rest]]
   (if (-> sente-state :state deref :open?)
     (apply (:send-fn sente-state) message rest)
-    ;; wait for connection (this probably works)
-    (let [tap (async/chan (async/sliding-buffer 1))]
-      (async/tap (:ch-recv-mult sente-state) tap)
-      (async/take! tap
-                   (fn [val]
-                     (apply (:send-fn sente-state) message rest))))))
+    (let [watch-id (utils/uuid)]
+      (add-watch (:state sente-state) watch-id
+                 (fn [key ref old new]
+                   (when (:open? new)
+                     (apply (:send-fn sente-state) message rest)
+                     (remove-watch ref watch-id)))))))

-(defn subscribe-to-document [sente-state app-state document-id]
+(defn subscribe-to-document [sente-state document-id]
   (send-msg sente-state [:frontend/subscribe {:document-id document-id}] 10000
-            (fn [{:keys [document layers chats client-uuid]}]
-              ;; TODO: if this is a good idea, then make it the default
-              (put! (get-in @app-state [:comms :controls])
-                    [:show-mouse-toggled {:client-uuid client-uuid
-                                          :show-mouse? true}])
-              (d/transact! (:db @app-state)
-                           (concat layers chats)
-                           {:server-update true}))))
+            (fn [data]
+              (put! (:ch-recv sente-state) [:chsk/recv [:frontend/subscribe data]]))))

-(defn fetch-subscribers [sente-state app-state document-id]
+(defn fetch-subscribers [sente-state document-id]
   (send-msg sente-state [:frontend/fetch-subscribers {:document-id document-id}] 10000
-            (fn [{:keys [subscribers]}]
-              (swap! app-state update-in [:subscribers] (fn [s]
-                                                          (merge-with merge
-                                                                      subscribers
-                                                                      s))))))
+            (fn [data]
+              (put! (:ch-recv sente-state) [:chsk/recv [:frontend/fetch-subscribers data]]))))

 (defmulti handle-message (fn [app-state message data]
                            (utils/mlog "handle-message" message data)
@@ -65,6 +56,24 @@
 (defmethod handle-message :frontend/update-subscriber [app-state message data]
   (swap! app-state update-in [:subscribers (:client-uuid data)] merge (:subscriber-data data)))

+;; These are a little bit different, we're putting the message on the channel in a send-msg callback
+(defmethod handle-message :frontend/subscribe [app-state message data]
+  (let [{:keys [document layers chats client-uuid]} data]
+    ;; TODO: if this is a good idea, then make it the default
+    (put! (get-in @app-state [:comms :controls])
+          [:show-mouse-toggled {:client-uuid client-uuid
+                                :show-mouse? true}])
+    (d/transact! (:db @app-state)
+                 (concat layers chats)
+                 {:server-update true})))
+
+(defmethod handle-message :frontend/fetch-subscribers [app-state message {:keys [subscribers]}]
+  (swap! app-state update-in [:subscribers] (fn [s]
+                                              (merge-with merge
+                                                          subscribers
+                                                          s))))
+
+
 (defn do-something [app-state sente-state]
   (let [tap (async/chan (async/sliding-buffer 10))
         mult (:ch-recv-mult sente-state)]
@@ -82,6 +91,4 @@
 (defn init [app-state]
   (let [{:keys [chsk ch-recv send-fn state] :as sente-state} (sente/make-channel-socket! "/chsk" {:type :auto})]
     (swap! app-state assoc :sente (assoc sente-state :ch-recv-mult (async/mult ch-recv)))
-    (subscribe-to-document (:sente @app-state) app-state (-> @app-state :document/id))
-    (fetch-subscribers (:sente @app-state) app-state (-> @app-state :document/id))
     (do-something app-state (:sente @app-state))))


adding s3 based type test

adding s3 based type test

--- test/celestial/integration/puppet.clj
+++ test/celestial/integration/puppet.clj
@@ -14,23 +14,31 @@
     [celestial.fixtures :only (with-conf redis-prox-spec redis-ec2-spec redis-type)]))

 (defn run-cycle [spec type]
-    (clear-all)
-    (p/add-type type)
-    (let [id (p/add-system spec)]
+  (clear-all)
+  (p/add-type type)
+  (let [id (p/add-system spec)]
+    (try
       (reload (assoc spec :system-id id))
       (puppetize type (p/get-system id))
-      (destroy (assoc (p/get-system id) :system-id id))))
+      (finally
+        (destroy (assoc (p/get-system id) :system-id id))))))

-(fact "provisioning a proxmox instance" :integration :puppet
+(fact "provisioning a proxmox instance" :integration :puppet :proxmox
       (with-conf
         (run-cycle redis-prox-spec redis-type)))

-#_(fact "provisioning an ec2 instance" :integration :puppet
+(fact "provisioning an ec2 instance" :integration :puppet :ec2
       "assumes a working ec2 defs in ~/.celestial.edn"
-      (let [puppet-ami (assoc-in redis-ec2-spec [:aws :image-id] "ami-4eb1ba3a")]
+      (let [puppet-ami (assoc-in redis-ec2-spec [:aws :image-id] "ami-f5e2ff81")]
         path => truthy
         (run-cycle puppet-ami redis-type)))

+(fact "ec2 with s3 source url type" :integration :puppet :ec2 :s3
+      "assumes a working ec2 defs in ~/.celestial.edn"
+      (let [puppet-ami (assoc-in redis-ec2-spec [:aws :image-id] "ami-f5e2ff81")
+            s3-redis (assoc-in redis-type [:puppet-std :module :src] "s3://opsk-sandboxes/redis-sandbox-0.3.4.tar.gz")]
+        path => truthy
+        (run-cycle puppet-ami s3-redis)))


forgot to delete this commented out code

--- test/midje/internal_ideas/t_fakes.clj
+++ test/midje/internal_ideas/t_fakes.clj
@@ -1,9 +1,4 @@
 ;; -*- indent-tabs-mode: nil -*-
-
-;(def private-fns [folded-fake? augment-substitutions
-;  flatten-fake generate-fakes mockable-funcall? unfolding-step merge-metaconstant-bindings
-;  data-fakes-to-metaconstant-bindings binding-map-with-function-fakes unique-vars
-;  call-faker best-call-action usable-default-function? arg-matcher-maker make-result-supplier])

 (ns midje.internal-ideas.t-fakes
   (:use [midje sweet test-util]


Positive test for the function proper-word-for-whitelist?

--- test/zg/dictionary_interface_test.clj
+++ test/zg/dictionary_interface_test.clj
@@ -75,3 +75,16 @@
             "Test!"
             "This is test!")))

+(deftest test-proper-word-for-whitelist?
+    "Check the function zg.dictionary-interface/proper-word-for-whitelist?"
+    (testing "the function zg.dictionary-interface/proper-word-for-whitelist?"
+        (are [x] (seq (proper-word-for-whitelist? x))
+            "test"
+            "Test"
+            "TEST"
+            "Test0"
+            "0"
+            "I'm"
+            "This is test"
+            "This is test.")))
+


Clean up routes

Clean up routes

--- src/icecap/rest.clj
+++ src/icecap/rest.clj
@@ -42,25 +42,24 @@
   [cap & {store :store}]
   (async/into {} (delete! store cap)))

+(defn ^:private cap-url
+  [request cap]
+  (let [netloc (str (:server-name request) ":" (:server-port request))
+        path (:uri request)
+        encoded-cap (safebase64-encode cap)]
+    (str "http://" netloc path "/" encoded-cap)))
+
 (defroutes routes
   (context "/v0/caps" {store :store kdf :kdf scheme :scheme}
            (POST "/" {plan :body-params :as request}
-                 (let [{cap :cap} (<!! (create-cap plan
-                                                   :store store
-                                                   :kdf kdf
-                                                   :scheme scheme))
-                       netloc (str (:server-name request)
-                                   ":" (:server-port request))
-                       path (:uri request)
-                       encoded-cap (safebase64-encode cap)
-                       url (str "http://" netloc path netloc "/" encoded-cap)]
-                   {:body url}))
+                 (let [{cap :cap} (<!! (create-cap plan :store store :kdf kdf :scheme scheme))]
+                   {:body (cap-url request cap)}))
            (context "/:encoded-cap" [encoded-cap]
                     (GET "/" []
-                         (<!! (get-cap (safebase64-decode encoded-cap)
-                                       :store store :kdf kdf :scheme scheme)))
+                         (let [cap (safebase64-decode encoded-cap)]
+                           (<!! (get-cap cap :store store :kdf kdf :scheme scheme))))
                     (DELETE "/" []
-                            (<!! (delete-cap (safebase64-decode encoded-cap)
+                     (<!! (delete-cap (safebase64-decode encoded-cap)
                                              :store store))))))

 (defn ^:private wrap-components


update

update

--- src/jepsen/tidb.clj
+++ src/jepsen/tidb.clj
@@ -168,9 +168,9 @@
     (cu/grepkill "java")
     (Thread/sleep 2000)
     ; (meh (c/exec "/root/hbase/bin/stop-hbase.sh"))
-    ;(meh (c/exec :rm :-rf "/var/lib/hbase/"))
-    ;(meh (c/exec :rm :-rf "/root/hbase/logs/"))
-    (meh (c/exec :rm :-rf "/tmp/hbase/"))
+    (meh (c/exec :rm :-rf (c/lit "/var/lib/hbase/*")))
+    (meh (c/exec :rm :-rf (c/lit "/root/hbase/logs/*")))
+    (meh (c/exec :rm :-rf (c/lit "/tmp/hbase/*")))
     )
   (info node "hbase stopped"))

@@ -208,6 +208,7 @@

             (jepsen/synchronize test)
             (start-tidb-server! node)
+            (Thread/sleep 3000)

             (jepsen/synchronize test)
             (info node "set up"))


adjust jepsen test msg timeout

adjust jepsen test msg timeout

--- jepsen/src/nsq/core.clj
+++ jepsen/src/nsq/core.clj
@@ -36,6 +36,7 @@
 (def nsqlookupd-logfile "/var/log/nsqlookupd.log")
 (def nsqlookupd-pidfile "/var/run/nsqlookupd.pid")
 (def etcd-cluster-url "http://etcd0.example.com:2379/v2/keys/NSQMetaData/test-jepsen-dev-1")
+(def nsq-package "nsq-0.3.7-HA.1.5.3.1.linux-amd64.go1.7.4")

 (defn prepare-binary!
   [test node]
@@ -51,14 +52,14 @@
           (when-not (cu/exists? "build/nsqd")
             (c/exec :mkdir :-p "/opt/nsq/build")
             (c/exec :chmod :-R "a+rwx" "/opt/nsq")
-            (c/exec :rm :-f (c/lit "/opt/nsq/nsq-0.3.7-HA.1.5.3.1.linux-amd64.go1.7.4.tar.gz*"))
+            (c/exec :rm :-f (c/lit (str "/opt/nsq/" nsq-package ".tar.gz*")))
             (info node "downloading nsq")
             ;(c/exec :wget "https://github.com/absolute8511/nsq/releases/download/v0.3.7-HA.1.5.3.1/nsq-0.3.7-HA.1.5.3.1.linux-amd64.go1.7.4.tar.gz")
-            (c/upload (.getFile (io/resource "nsq-0.3.7-HA.1.5.3.1.linux-amd64.go1.7.4.tar.gz")) "/opt/nsq/nsq-0.3.7-HA.1.5.3.1.linux-amd64.go1.7.4.tar.gz")
+            (c/upload (.getFile (io/resource (str nsq-package ".tar.gz"))) (str "/opt/nsq/" nsq-package ".tar.gz"))
             (info node "tar nsq")
-            (c/exec :tar :-xvzf "nsq-0.3.7-HA.1.5.3.1.linux-amd64.go1.7.4.tar.gz")
+            (c/exec :tar :-xvzf (str nsq-package ".tar.gz"))
             (info node "copying nsq binary")
-            (c/exec :cp :-rp (c/lit "nsq-0.3.7-HA.1.5.3.1.linux-amd64.go1.7.4/bin/*") "build/"))
+            (c/exec :cp :-rp (c/lit (str nsq-package "/bin/*")) "build/"))
           (info node "copying nsq")
           (c/exec :cp :-rp (c/lit "build/*") "/usr/bin/"))))

@@ -195,6 +196,7 @@
 (def ^NSQConfig nsqconf
   (let [conf (NSQConfig.)]
     (.setConsumerName conf "jepsen-ch")
+    (.setMsgTimeoutInMillisecond conf 5000)
     conf))

 (defn dequeue!


Fix arg order bug.

Fix arg order bug.

--- src/clj/com/draines/postal/stress.clj
+++ src/clj/com/draines/postal/stress.clj
@@ -44,7 +44,7 @@

 (defn spam
   ([host port from to n]
-     (spam host from to port n 0))
+     (spam host port from to n 0))
   ([host port from to n delay]
      (log (format "(thread: %s) %s msgs -> %s"
                   (-> (Thread/currentThread) .getId)


docstr about compscribe return val

docstr about compscribe return val

--- src/cljc/commos/delta/compscribe.cljc
+++ src/cljc/commos/delta/compscribe.cljc
@@ -535,7 +535,8 @@

 (defn compscribe
   "Internally creates a compscribe service and makes the subscription
-  at specifier.  Useful for testing, uses default cache settings."
+  at specifier.  Useful for testing, uses default cache settings,
+  returns a function to end subscription."
   {:arglists '([target-ch service spec id])}
   ([target-ch service spec id]
    (let [service (compscriber service)]


x out of 5 is now x / 5

x out of 5 is now x / 5

--- src/cljs/conference_rating/panel.cljs
+++ src/cljs/conference_rating/panel.cljs
@@ -33,7 +33,7 @@
      [:div {:class "media-container icon-wrap icon-md"}
       [:span {:class (str "glyphicon " icon)}]]]
     [:div {:class "media-body"}
-     [:h3 {:class "media-body range-label"} (str absolute " out of 5")]
+     [:h3 {:class "media-body range-label"} (str absolute " / 5")]
      [:div {:class "text-uppercase"} name]]]
    [:div {:class "progress-xs"}
     [:div {:style {:width (str percentage "%")} :class "progressbar progressbar-light"}]]


Don't clear canvas when drawing selection outline

--- src/cljs/goya/components/drawing.cljs
+++ src/cljs/goya/components/drawing.cljs
@@ -250,7 +250,6 @@
    (let [preview-context (.getContext preview-canvas-elem "2d")
          [x1 y1 x2 y2] (om/get-state owner :selection)
          zoom-factor (get-in app [:zoom-factor])]
-     (clear-preview-canvas)
      (set! (.-strokeStyle preview-context) "#ffffff")
      (.setLineDash preview-context #js [5])
      (.rect preview-context


Minor naming changes on server.clj.

Minor naming changes on server.clj.

--- src/clojure/catacumba/impl/server.clj
+++ src/clojure/catacumba/impl/server.clj
@@ -47,8 +47,8 @@
       (:handler-type metadata))))

 (defmethod setup-handler :catacumba/router
-  [handler ^RatpackServerSpec spec]
-  (.handlers spec ^Action (ch/fn->action handler)))
+  [factory ^RatpackServerSpec spec]
+  (.handlers spec ^Action (ch/fn->action factory)))

 (defmethod setup-handler :default
   [handler ^RatpackServerSpec spec]


Removing do-nothing function. We should not unindex a provider here.

--- src/cmr/bootstrap/data/bulk_index.clj
+++ src/cmr/bootstrap/data/bulk_index.clj
@@ -58,17 +58,10 @@
         num-collections (index/bulk-index {:system (:indexer system)} concept-batches)]
     (info "Indexed" num-collections "collection(s) for provider" provider-id)))

-(defn- unindex-provider
-  "Remove all records from elastic related to the given provider including indexes."
-  [system provider-id]
-  ;; FIXME - Implement this when done with bulk migration
-  )
-
 (defn- index-provider
   "Bulk index a provider."
   [system provider-id]
   (info "Indexing provider" provider-id)
-  (unindex-provider system provider-id)
   (index-provider-collections system provider-id)
   (index-granules-for-provider system provider-id)
   (info "Indexing of provider" provider-id "completed."))


examples

examples

Signed-off-by: Chris Granger <5654cde260ae99bc4d30054171b8bcd902efd19a@gmail.com>

--- src/aurora/runtime/core.cljs
+++ src/aurora/runtime/core.cljs
@@ -67,26 +67,93 @@

 (comment
-(def e (make-env #{[3 5] [9 8 7] [:tick]}
-                 [
-                  ;;clean up rules
-                  [(rule {:name :wait :time t :id i}
-                         (- {:name :wait :time t :id i}))]
-                  ;;program rules
-                  [(rule [:tick]
-                         (- [:tick])
-                         (+ {:name :wait :time 1000 :id 1}))
-                   (rule {:name :tick :id 1 :timestamp ts}
-                         (+ [:tick])
-                         (+ ["Os Ms Gs ticked!" ts]))
-                   ]]))

-(run e)
+  (def tick (-> (make-env #{[3 5] [9 8 7] [:tick]}
+                          [
+                           ;;clean up rules
+                           [(rule {:name :wait :time t :id i}
+                                  (- {:name :wait :time t :id i}))]
+                           ;;program rules
+                           [(rule [:tick]
+                                  (- [:tick])
+                                  (+ {:name :wait :time 1000 :id 1}))
+                            (rule {:name :tick :id 1 :timestamp ts}
+                                  (+ [:tick])
+                                  (+ ["hi!" ts]))
+                            ]])
+                (run)))

-(pause e)
-(unpause e)
+  (pause tick)
+  (unpause tick)
+  @tick

-@e
+  (def clock (-> (make-env #{[:tick]}
+                           [
+                            ;;clean up rules
+                            [(rule {:name :wait :time t :id i}
+                                   (- {:name :wait :time t :id i}))
+                             (rule {:name :ui/text :id "time-value" :text text}
+                                   (- {:name :ui/text :id "time-value" :text text}))]
+                            ;;program rules
+                            [(rule [:tick]
+                                   (- [:tick])
+                                   (+ {:name :wait :time 1000 :id "clock"}))
+                             (rule {:name :tick :id "clock" :timestamp ts}
+                                   (+ {:name :wait :time 1000 :id "clock"})
+                                   (+ {:name :ui/elem :id "time" :tag "p"})
+                                   (+ {:name :ui/child :id "time" :child "time-value" :pos 0})
+                                   (+ {:name :ui/text :id "time-value" :text (str "time is: " (js/Date. ts))})
+                                   )
+                             ]])
+                 (run)))
+
+  (pause clock)
+  (unpause clock)
+  @clock
+
+
+  (def incrementer (-> (make-env #{{:name "counter" :value 0}}
+                                 [
+                                  ;;clean up rules
+                                  [(rule {:name :ui/text :id "counter-value" :text text}
+                                         (- {:name :ui/text :id "counter-value" :text text}))
+                                   ]
+                                  ;;program rules
+                                  [(rule {:name :ui/onClick :id "incr-button"}
+                                         {:name "counter" :value v}
+                                         (- {:name :ui/onClick :id "incr-button"})
+                                         (- {:name "counter" :value v})
+                                         (+ {:name "counter" :value (inc v)}))]
+                                  [(rule {:name "counter" :value v}
+                                         (+ {:name :ui/elem :id "counter-ui" :tag "p"})
+                                         (+ {:name :ui/child :id "counter-ui" :child "counter-value" :pos 0})
+                                         (+ {:name :ui/text :id "counter-value" :text (str v)})
+                                         (+ {:name :ui/elem :id "incr-button" :tag "button"})
+                                         (+ {:name :ui/event-listener :id "incr-button" :event "onClick"})
+                                         (+ {:name :ui/child :id "incr-button" :child "incr-value" :pos 0})
+                                         (+ {:name :ui/text :id "incr-value" :text "increment"})
+                                         )
+                                   ]])
+                       (run)))
+
+  (pause incrementer)
+  (unpause incrementer)
+  (:kn @incrementer)
+
+
+  (def +s-test (-> (make-env #{[:tick] [:whee] [:zomg]}
+                             [
+                              ;;clean up rules
+                              [(rule {:name :ui/text :id "counter-value" :text text}
+                                     (- {:name :ui/text :id "counter-value" :text text}))
+                               ]
+                              ;;program rules
+                              [(rule [:tick]
+                                     (-s (map vector [:tick :zomg]))
+                                     (+s [{:name "foo"} {:name "zomg"}])
+                                     )
+                               ]])
+                   (run)))

   )


dep-tree -> print-deps

dep-tree -> print-deps

--- boot/core/src/boot/task/built_in.clj
+++ boot/core/src/boot/task/built_in.clj
@@ -81,6 +81,13 @@
               `(boot.notify/failure! ~theme ~failure))
             (throw t)))))))

+(core/deftask print-deps
+  "Print the project's dependency graph."
+  []
+  (core/with-pre-wrap
+    (pod/call-worker
+      `(boot.aether/print-dep-tree ~(core/get-env)))))
+
 (core/deftask print-env
   "Print the boot environment map."
   []
@@ -184,13 +191,6 @@
         (pod/call-worker
           `(boot.repl-client/client ~cli-opts))))))

-(core/deftask dep-tree
-  "Print the project's dependency graph."
-  []
-  (core/with-pre-wrap
-    (pod/call-worker
-      `(boot.aether/print-dep-tree ~(core/get-env)))))
-
 (core/deftask pom
   "Write the project's pom.xml file."


remove unneeded require

remove unneeded require

--- src/babel/english/writer.clj
+++ src/babel/english/writer.clj
@@ -4,10 +4,6 @@
 (require '[babel.english.grammar :refer [small small-plus-vp-pronoun]])
 (require '[babel.english.lexicon :refer [lexicon]])
 (require '[babel.english.morphology :refer [fo]])
-
-;; lets us do things like:
-;; (es/fo (es/expression {:synsem {:sem {:pred :have-fun}}}))
-(require '[babel.espanol.writer :as es])

 (require '[babel.reader :refer [read-all read-one]])
 (require '[babel.writer :as writer


+{:synsem {:subcat '()}} when generating expressions

--- src/babel/espanol/writer.clj
+++ src/babel/espanol/writer.clj
@@ -70,7 +70,8 @@
            (fn [verb]
              (log/debug (str "verb: " (strip-refs verb)))
             (let [root-form (get-in verb [:espanol :espanol])
-                  spec {:root {:espanol {:espanol root-form}}}]
+                  spec {:root {:espanol {:espanol root-form}}
+                        :synsem {:subcat '()}}]
               (log/info (str "generating with verb: '" root-form "'"))
                (writer/generate-from-spec
                 model (strip-refs spec)


sticky navbar

sticky navbar

--- src/clj/just_married/css.clj
+++ src/clj/just_married/css.clj
@@ -112,7 +112,9 @@
                          :text-align "center"
                          :text-decoration "none"
                          :color (:gold COLOR-PALLETTE)
-                         :margin-bottom "50px"}
+                         :margin-bottom "50px"
+                         :position "sticky"
+                         :top "0"}

     ;; FIXME: should be less generic here
     [:a {:color (:white COLOR-PALLETTE)}]


using password hashing

using password hashing

--- src/clj/movement/handler.clj
+++ src/clj/movement/handler.clj
@@ -20,7 +20,7 @@
             [buddy.auth.backends.session :refer [session-backend]]
             [buddy.auth.middleware :refer [wrap-authentication wrap-authorization]]

-            [buddy.hashers :as hs]))
+            [buddy.hashers :as hashers]))

 (def uri "datomic:dev://localhost:4334/movement8")
 (def conn (d/connect uri))
@@ -115,8 +115,7 @@
 (def authdata {:admin "pw"
                :test "pw"})

-(defn unauthorized-handler
-  [request metadata]
+(defn unauthorized-handler [request metadata]
   ;; If request is authenticated, raise 403 instead
   ;; of 401 (because user is authenticated but permission
   ;; denied is raised).
@@ -131,8 +130,7 @@
 (def auth-backend
   (session-backend {:unauthorized-handler unauthorized-handler}))

-(defn home
-  [req]
+(defn home [req]
   (when (not (authenticated? req))
     (throw-unauthorized {:message "Not authorized"}))
   (render-file "templates/index.html" {:dev (env :dev?)}))
@@ -143,45 +141,26 @@
 (defn logout [req]
   (assoc (redirect "/") :session nil))

-(defn login-authenticate
-  "Check request username and password against authdata username and passwords.
-  On successful authentication, set appropriate user into the session and
-  redirect to the value of (:query-params (:next request)).
-  On failed authentication, renders the login page."
-  [request]
-  (let [username (get-in request [:form-params "username"])
-        password (get-in request [:form-params "password"])
-        session (:session request)
-        found-password (get authdata (keyword username))]
-    (if (and found-password (= found-password password))
-      (let [next-url (get-in request [:query-params :next] "/")
+(defn find-user [username]
+  (hashers/encrypt "password"))
+
+(defn login-authenticate [req]
+  (let [username (get-in req [:form-params "username"])
+        password (get-in req [:form-params "password"])
+        session (:session req)
+        found-password (find-user username)
+        #_(get authdata (keyword username))]
+    (if (and found-password (hashers/check password found-password))
+      (let [next-url (get-in req [:query-params :next] "/")
             updated-session (assoc session :identity (keyword username))]
         (-> (redirect "/")
             (assoc :session updated-session)))
       (render-file "templates/login.html" {:dev (env :dev?)}))))

-(defn do-login [req]
-  (let [resp (login-authenticate req)]))
-
-;adding users to db
-(defn add-user!
-  [ds user]
-  (hs/encrypt ""))
-
-(defn auth-user
-  [ds credentials]
-  (let [user "find user in db"
-        unauthed [false {:message "Invalid username or password"}]]
-    (if user
-      (if (hs/check (:password credentials) (:password user))
-        [true {:user (dissoc user :password)}]
-        unauthed)
-      unauthed)))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;

 (defroutes routes
-           (resources "/")
+
            (GET "/" [] home)

            (GET "/raw" [] (render-file "templates/indexraw.html" {:dev (env :dev?)}))
@@ -200,7 +179,7 @@
                                                                               categories))))

            (GET "/user/:id" [id] (generate-response (str "Hello user " id)))
-
+           (resources "/")
            (not-found "Not Found"))

 (def app


Save file from data URI

Save file from data URI

--- src/clj/salava/core/util.clj
+++ src/clj/salava/core/util.clj
@@ -2,7 +2,9 @@
   (:require [clojure.java.io :as io]
             [clojure.string :as str]
             [slingshot.slingshot :refer :all]
-            [clj-http.client :as client]))
+            [clj-http.client :as client]
+            [pantomime.mime :refer [extension-for-name mime-type-of]]
+            [buddy.core.codecs :refer [base64->bytes base64->str]]))

 (def config (-> (clojure.java.io/resource "config/core.edn") slurp read-string))

@@ -16,12 +18,10 @@
   (let [digest (.digest (java.security.MessageDigest/getInstance algo) (.getBytes string))]
     (.toString (new java.math.BigInteger 1 digest) 16)))

-
 (defn ordered-map-values
   "Returns a flat list of keys and values in a map, sorted by keys."
   [coll]
   (flatten (seq (into (sorted-map) coll))))
-

 (defn flat-coll [item]
   "Returns a sorted and flattened collection"
@@ -29,24 +29,28 @@
     (list item)
     (flatten (map flat-coll (if-not (map? item) item (ordered-map-values item))))))

-
 (defn map-sha256
   "Calculates SHA-256 hex digest of (ordered) content in a collection"
   [coll]
   (hex-digest "SHA-256" (apply str (flat-coll coll))))

 (defn file-extension [filename]
-  (last (str/split (str filename) #"\.")))
+  (let [ext (last (str/split (str filename) #"\."))]
+    (if ext (str "." ext))))
+
+(defn public-path-from-content
+  [content extension]
+  (let [checksum (hex-digest "SHA-256" content)]
+    (apply str (concat (list "file/")
+                       (interpose "/" (take 4 (char-array checksum)))
+                       (list "/" checksum extension)))))

 (defn public-path
   "Calculate checksum for file and use it as a filename under public dir"
   ([filename] (public-path filename (file-extension filename)))
   ([filename extension]
-   (let [content (slurp filename)
-         checksum (hex-digest "SHA-256" content)]
-     (apply str (concat (list "file/")
-                        (interpose "/" (take 4 (char-array checksum)))
-                        (list "/" checksum "." extension))))))
+    (let [content (slurp filename)]
+      (public-path-from-content content extension))))

 (defn fetch-file-content [url]
   "Fetch file content from url"
@@ -61,22 +65,41 @@
     (subs path 0 (.lastIndexOf path "?"))
     path))

+(defn save-file-data
+  [content path]
+  (let [filename (trim-path path)
+        data-dir (get config :data-dir)
+        fullpath (str data-dir "/" filename)]
+    (try+
+      (if-not (.exists (io/as-file data-dir))
+        (throw+ "Data directry does not exist"))
+      (do
+        (io/make-parents fullpath)
+        (with-open [w (io/output-stream fullpath)]
+          (.write w content))
+        filename)
+      (catch Object _
+        (throw+ (str "Error copying file: " _))))))
+
+(defn save-file-from-http-url
+  [url]
+  (let [content (fetch-file-content url)
+        path (public-path url)]
+    (save-file-data content path)))
+
+(defn save-file-from-data-url
+  [data-str comma-pos]
+  (if (> comma-pos -1)
+    (let [base64-data (subs data-str (inc comma-pos))
+          content (base64->bytes base64-data)
+          content-str (base64->str base64-data)
+          ext (-> content mime-type-of extension-for-name)
+          path (public-path-from-content content-str ext)]
+      (save-file-data content path))))
+
 (defn file-from-url
   [url]
-  (if (re-find #"https?" (str url))
-    (let [content (fetch-file-content url)
-          path (public-path url)
-          fname (trim-path path)
-          data-dir (get config :data-dir)
-          fullpath (str data-dir "/" fname)]
-      (try+
-        (if-not (.exists (io/as-file data-dir))
-          (throw+ "Data directry does not exist"))
-        (do
-          (io/make-parents fullpath)
-          (with-open [w (io/output-stream fullpath)]
-            (.write w content))
-          fname)
-        (catch Object _
-          (throw+ "Error copying file: " _))))
-    (throw+ "Error in file url: " url)))+  (cond
+    (re-find #"https?" (str url)) (save-file-from-http-url url)
+    (re-find #"data?" (str url)) (save-file-from-data-url url (.lastIndexOf url ","))
+    :else (throw+ (str "Error in file url: " url))))


fix pagination off-by-one error

fix pagination off-by-one error

--- src/clj_money/pagination.clj
+++ src/clj_money/pagination.clj
@@ -66,14 +66,14 @@
        [:div.col-sm-5.text-left
         [:div.btn-group
          [:a.btn.btn-default {:href (-> url
-                                        (url/query {:page (if (= (- page-count 1) page)
-                                                            (- page-count 1)
+                                        (url/query {:page (if (= page-count page)
+                                                            page-count
                                                     (+ page 1))
                                                     :per-page per-page})
                                         url/format-url)}
           [:span.glyphicon.glyphicon-step-forward {:aria-hidden true}]]
          [:a.btn.btn-default {:href (-> url
-                                        (url/query {:page (- page-count 1)
+                                        (url/query {:page page-count
                                                     :per-page per-page})
                                         url/format-url)}
           [:span.glyphicon.glyphicon-fast-forward {:aria-hidden true}]]]]]])])


Guess similarity threshold separated into config

--- src/cljs/db_quiz/config.cljs
+++ src/cljs/db_quiz/config.cljs
@@ -24,4 +24,5 @@
             ; Space between hexagons in % of their size
             :space 8}
    :letters ["A" "B" "C" "Č" "D" "E" "F" "G" "H" "Ch" "I" "J" "K" "L"
-             "M" "N" "O" "P" "R" "Ř" "S" "Š" "T" "U" "V" "W" "Z" "Ž"]})
+             "M" "N" "O" "P" "R" "Ř" "S" "Š" "T" "U" "V" "W" "Z" "Ž"]
+   :guess-similarity-threshold 0.94})


Fix lack of unquoting in single-armed `compile-if`.

--- src/clojure/parkour/util.clj
+++ src/clojure/parkour/util.clj
@@ -68,7 +68,7 @@
 (defmacro compile-if
   "Evaluate `exp` and if it returns logical true and doesn't error, expand to
 `then`.  Else expand to `else` if provided."
-  ([exp then] `(compile-if exp then nil))
+  ([exp then] `(compile-if ~exp ~then nil))
   ([exp then else]
      (if (try (eval exp) (catch Throwable _ false))
        `(do ~then)


fixed up gap in events panel

fixed up gap in events panel

--- src/day8/re_frame_10x/view/event.cljs
+++ src/day8/re_frame_10x/view/event.cljs
@@ -252,10 +252,12 @@
     :align :end
     :style {:margin-bottom "2px"}
     :children [[rc/checkbox
-                :style {:align :end}
                 :model execution-order?
                 :label "show trace in execution order"
                 :on-change (handler-fn (rf/dispatch [:code/set-execution-order (not execution-order?)]))]
+               [rc/box
+                :size "1"
+                :child ""]
                [repl-msg-area]
                [rc/box
                 :size "1"


Fix errors in the tree walker

Fix errors in the tree walker

--- src/cyanite_remover/core.clj
+++ src/cyanite_remover/core.clj
@@ -560,7 +560,9 @@
             (let [path (vec path)]
               (map #(conj path %) (keys (get-in @tree path)))))))
       (t-path-leaf? [this path]
-        (not= (type (get-in @tree path)) clojure.lang.PersistentArrayMap))
+        (let [val (get-in @tree path)]
+          (and (not (instance? clojure.lang.PersistentHashMap val))
+               (not (instance? clojure.lang.PersistentArrayMap val)))))
       (t-path-empty? [this path]
         (= (get-in @tree path) {}))
       (t-delete-path [this path]
@@ -624,7 +626,8 @@
     (letfn [(walk [path]
               (when-not (t-path-leaf? tree-impl path)
                 (dorun (map walk (t-get tree-impl path))))
-              (tp-process-path processor path))]
+              (when (seq path)
+                (tp-process-path processor path)))]
       (try
         (prog/set-progress-bar!
          "[:bar] :percent :done/:total Elapsed :elapseds ETA :etas")


added HTML generator function for common links

--- src/distillery/view/html.clj
+++ src/distillery/view/html.clj
@@ -123,6 +123,14 @@
   [js content]
   {:tag :a :attrs {:href (jshref js)} :content (safe-content content)})

+
+(defn link
+  "Create a link tag with the given URL an optional target and some content."
+  ([url content]
+   {:tag :a :attrs {:href url} :content (safe-content content)})
+  ([url target content]
+   (assoc-in (link url content) [:attrs :target] target)))
+
 (defn menu
   "Builds a menu structure from a menu title and a sequence of label/url pairs."
   [items & {:keys [title]}]


Typo fixed

Typo fixed

--- src/foreclojure/data_set.clj
+++ src/foreclojure/data_set.clj
@@ -717,7 +717,7 @@

       (insert! :problems
           {:_id 69
-           :title "Merge with Function"
+           :title "Merge with a Function"
            :times-solved 0
            :restricted ["merge-with"]
            :description "Write a function which takes a function f and a variable number of maps.  Your function should return a map that consists of the rest of the maps conj-ed onto the first.  If a key occurs in more than one map, the new value should be calculated by applying f to each of the two original values."


changed predicate comprender

changed predicate comprender

from understand to understand-deeply


Add support for last n tags

Add support for last n tags

--- src/github_changelog/cli.clj
+++ src/github_changelog/cli.clj
@@ -8,7 +8,10 @@
             [github-changelog.formatters.markdown :refer [format-tags]]))

 (def cli-options
-  [["-h" "--help"]])
+  [["-l" "--last LAST" "Generate changes only for the last n tags"
+     :parse-fn #(Integer/parseInt %)
+     :validate [#(< 0 %) "Must be a positive number"]]
+    ["-h" "--help"]])

 (defn- join-lines [lines]
   (str/join \newline (flatten lines)))
@@ -26,10 +29,10 @@
 (defn- read-config [file]
   (edn/read-string (slurp file)))

-(defn- generate [file]
-  (->> (read-config file)
-       changelog
-       format-tags))
+(defn- generate [file last]
+  (let [all-tags (changelog (read-config file))
+        tags (if last (take last all-tags) all-tags)]
+    (format-tags tags)))

 (defn- usage [options-summary]
   (join-lines ["Usage: program-name [options] <config.edn> ..."
@@ -38,13 +41,14 @@
                options-summary]))

 (defn -main [& args]
-  (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
+  (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)
+        {:keys [help last]} options]
     (cond
-      (:help options) (exit 0 (usage summary))
+      help (exit 0 (usage summary))
       (empty? arguments) (exit 1 (usage summary))
       errors (exit 1 (error-msg errors)))

     (doseq [config-file arguments]
-      (println (generate config-file)))
+      (println (generate config-file last)))

     (exit 0 nil)))


refactor parameters for schema and resolver-fn

--- src/graphql_clj/executor.clj
+++ src/graphql_clj/executor.clj
@@ -103,7 +103,7 @@

 (defn get-field-type-from-object-type
   "FIXME"
-  [type-meta-fn object-type field-selection]
+  [schema resolver-fn object-type field-selection]
   (log/debug (format "get-field-type-from-object-type: object-type: %s." object-type))
   (log/debug (format "get-field-type-from-object-type: field-selection: %s." field-selection))
   (let [field-name (get-selection-object-name field-selection)
@@ -112,12 +112,12 @@
         type (get-in object-type [:fields (keyword field-name) :type])]
     (cond
       (map? type) type
-      (keyword? type) (type-meta-fn type)
+      (keyword? type) (type/get-type-in-schema type)
       (nil? type) (throw (ex-info (format "Cannot find field type (%s) in object(%s)." field-name object-type) {})))))

 (defn resolve-field-on-object
   "FIXME"
-  [context parent-object field-type inner-field-type field-entry]
+  [context schema resolver-fn parent-object field-type inner-field-type field-entry]
   (let [field-name (get-selection-object-name field-entry)
         arguments (get-selection-arguments field-entry)
         resolve-fn (or (:resolve-fn field-type)
@@ -180,7 +180,7 @@
 (declare execute-fields)

 (defn complete-value
-  [context type-meta-fn field-type result sub-selection-set fragments]
+  [context schema resolver-fn field-type result sub-selection-set fragments]
   (log/debug "*** complete-value: context: " context)
   (log/debug "field-type: " field-type)
   (log/debug "result: " result)
@@ -195,27 +195,27 @@
     (cond
       (is-scalar-field-type? field-type) result
       (is-enum-field-type? field-type) result
-      (is-object-field-type? field-type) (log/spy (execute-fields context type-meta-fn field-type result sub-selection-set fragments))
-      (is-list-field-type? field-type) (log/spy (map #(execute-fields context type-meta-fn (type-meta-fn (:innerType field-type)) % sub-selection-set fragments) result))
-      (is-not-null-type? field-type) (log/spy (let [not-null-result (complete-value context type-meta-fn (type-meta-fn (:innerType field-type)) result sub-selection-set fragments)]
+      (is-object-field-type? field-type) (log/spy (execute-fields context schema resolver-fn field-type result sub-selection-set fragments))
+      (is-list-field-type? field-type) (log/spy (map #(execute-fields context schema resolver-fn (type/get-type-in-schema schema (:innerType field-type)) % sub-selection-set fragments) result))
+      (is-not-null-type? field-type) (log/spy (let [not-null-result (complete-value context schema resolver-fn (type/get-type-in-schema schema (:innerType field-type)) result sub-selection-set fragments)]
                                                 (if not-null-result
                                                   not-null-result
                                                   (throw (ex-info (format "NOT_NULL type %s returns null." field-type {:field-type field-type}))))))
       :else (throw (ex-info (format "Unhandled field type %s." field-type) {:field-type field-type})))))

-(defn get-field-entry [context type-meta-fn parent-type parent-object field fragments]
+(defn get-field-entry [context schema resolver-fn parent-type parent-object field fragments]
   (log/debug "*** get-field-entry: " field)
   (log/debug "get-field-entry: fragments: " fragments)
   (log/debug "get-field-entry: parent-object: " parent-object)
   (let [first-field-selection field
         response-key (get-selection-name first-field-selection)
-        field-type (get-field-type-from-object-type type-meta-fn parent-type first-field-selection)
+        field-type (get-field-type-from-object-type schema resolver-fn parent-type first-field-selection)
         inner-type (:innerType field-type)
-        inner-field-type (when inner-type (type-meta-fn inner-type))
+        inner-field-type (when inner-type (type/get-type-in-schema schema inner-type))
         field-entry first-field-selection]
     (log/debug "field-type" field-type)
     (if (not (nil? field-type))
-      (let [resolved-object (resolve-field-on-object context parent-object field-type inner-field-type field-entry)
+      (let [resolved-object (resolve-field-on-object context schema resolver-fn parent-object field-type inner-field-type field-entry)
             field-selection-set (get-field-selection-set field)
             fields (collect-fields field-type field-selection-set fragments)]
         (log/debug "get-field-entry: fields: " fields)
@@ -226,12 +226,12 @@
                              ; that an entry exists in the result map
                              ; whose value is null.
           (let [;; sub-selection-set (merge-selection-sets field-selection-set)
-                response-value (complete-value context type-meta-fn field-type resolved-object fields fragments)]
+                response-value (complete-value context schema resolver-fn field-type resolved-object fields fragments)]
             [response-key (log/spy response-value)])))
       (log/debug "WARNING: field-type is nil!"))))

 (defn execute-fields
-  [context type-meta-fn parent-type root-value fields fragments]
+  [context schema resolver-fn parent-type root-value fields fragments]
   (log/debug "*** execute-fields")
   (log/debug "execute-fields: parent-type: " parent-type)
   (log/debug "execute-fields: root-value: " root-value)
@@ -241,36 +241,36 @@
                   (let [response-key (get-selection-name field)
                         ;; field-type (get-field-type-from-object-type parent-type field)
                         ;; resolved-object (resolve-field-on-object field-type root-value field)
-                        field-entry (get-field-entry context type-meta-fn parent-type root-value field fragments)]
+                        field-entry (get-field-entry context schema resolver-fn parent-type root-value field fragments)]
                     (log/spy field-entry)))
                 fields)))

-(defn execute-query [context query type-meta-fn fragments]
+(defn execute-query [context schema resolver-fn query fragments]
   (let [selection-set (:selection-set query)
         _ (log/debug "fragments: " fragments)
-        object-type (type-meta-fn :query)
+        object-type (type/get-type-in-schema schema :query)
         fields (collect-fields object-type selection-set fragments)]
-    (execute-fields context type-meta-fn object-type :root fields fragments)))
+    (execute-fields context schema resolver-fn object-type :root fields fragments)))

 (defn execute-definition
-  [context definition type-meta-fn]
+  [context schema resolver-fn definition]
   (log/debug "*** execute-definition: " definition)
   (let [operation (:operation-definition definition)
         operation-type (:operation-type operation)
         fragments (:fragments definition)]
     (log/debug "*** execute-definition: fragments: " fragments)
     (case operation-type
-      "query" (log/spy (execute-query context operation type-meta-fn fragments))
+      "query" (log/spy (execute-query context schema resolver-fn operation fragments))
       (throw (ex-info (format "Unhandled operation root type: %s." operation-type) {})))))

 (defn execute
-  [context document type-meta-fn]
+  [context schema resolver-fn document]
   (let [root (first document)
         definitions (rest document)]
     (if (not (= root :document))
       (throw (ex-info (format "Root(%s) is not a valid document" root) {}))
       {:data (into {} (log/spy (map (fn [definition]
-                                      (execute-definition context definition type-meta-fn)) definitions)))})))
+                                      (execute-definition context schema resolver-fn definition)) definitions)))})))

 (comment
   (execute nil (parser/transform (parser/parse "query {user {id}}")) (graphql-clj.type/create-type-meta-fn graphql-clj.type/demo-schema))


Formatting

Formatting

--- src/grimoire/api/fs/read.clj
+++ src/grimoire/api/fs/read.clj
@@ -120,10 +120,10 @@
   (let [versions (api/thing->prior-versions config thing)]
     (if (succeed? versions)
       (-> (for [prior-thing (result versions)
-                :let  [v (t/thing->name (t/thing->version prior-thing))
-                       h (impl/thing->handle config :examples prior-thing)]
-                ex    (.listFiles h)
-                :when (.isFile ex)]
+                :let        [v (t/thing->name (t/thing->version prior-thing))
+                             h (impl/thing->handle config :examples prior-thing)]
+                ex          (.listFiles h)
+                :when       (.isFile ex)]
             (t/->Example thing, (.getPath ex)))
           succeed)


Bugfix: ::t/file wasn't being set on Art, Grp

This patch fixes the behavior of -list-notes in the context of a
filesystem so relative file location data is correctly attached for edit
link generation.

Fixes clojure-grimoire/grimoire#197

--- src/grimoire/api/fs/read.clj
+++ src/grimoire/api/fs/read.clj
@@ -102,30 +102,34 @@

 (defmethod api/-list-notes ::fs/Config [config thing]
   {:pre [(t/thing? thing)]}
-  (if (t/versioned? thing)
-    (let [versions (api/thing->prior-versions config thing)
-          lhs      (.toPath (io/file (:notes config)))]
-      (if (succeed? versions)
-        (succeed
-         (for [prior-thing (result versions)
-               :let  [v (t/thing->name (t/thing->version prior-thing))
-                      h (impl/thing->notes-handle config prior-thing)]
-               :when (.exists h)
-               :when (.isFile h)]
-           (let [rhs (.toPath h)
-                 p   (.relativize lhs rhs)]
-             (-> thing
-                 (t/->Note (.getName h)
-                           (.getPath h))
-                 (assoc ::t/file (.toString p))))))
-
-        ;; versions is a Fail, pass it down
-        versions))
-
-    (let [^java.io.File h (impl/thing->notes-handle config thing)]
-      (if (.exists h)
-        (succeed [(t/->Note thing, (.getName h), (.getPath h))])
-        (fail "No notes file!")))))
+  (let [lhs      (.toPath (io/file (:notes config)))]
+    (if (t/versioned? thing)
+      (let [versions (api/thing->prior-versions config thing)]
+        (if (succeed? versions)
+          (succeed
+           (for [prior-thing (result versions)
+                 :let  [v (t/thing->name (t/thing->version prior-thing))
+                        h (impl/thing->notes-handle config prior-thing)]
+                 :when (.exists h)
+                 :when (.isFile h)]
+             (let [rhs (.toPath h)
+                   p   (.relativize lhs rhs)]
+               (-> thing
+                   (t/->Note (.getName h)
+                             (.getPath h))
+                   (assoc ::t/file (.toString p))))))
+
+          ;; versions is a Fail, pass it down
+          versions))
+
+      (let [^java.io.File h (impl/thing->notes-handle config thing)]
+        (if (.exists h)
+          (let [rhs (.toPath h)
+                p   (.relativize lhs rhs)]
+            (succeed [(-> thing
+                          (t/->Note (.getName h), (.getPath h))
+                          (assoc ::t/file (.toString p)))]))
+          (fail "No notes file!"))))))

 (defmethod api/-list-examples ::fs/Config [config thing]
   {:pre [(t/thing? thing)]}


cleanup for profiles

cleanup for profiles

--- src/leiningen/new/reagent/project.clj
+++ src/leiningen/new/reagent/project.clj
@@ -98,10 +98,4 @@
                                              {:source-paths ["env/prod/cljs"]
                                               :compiler
                                               {:optimizations :advanced
-                                               :pretty-print false}}}}}
-
-             :production {:ring {:open-browser? false
-                                 :stacktraces?  false
-                                 :auto-reload?  false}
-                          :cljsbuild {:builds {:app {:compiler {:main "{{name}}.prod"}}}}
-                          }})
+                                               :pretty-print false}}}}}})


bug: proper index file passed to indexer

--- src/help_me_im_dumb/core.clj
+++ src/help_me_im_dumb/core.clj
@@ -16,6 +16,6 @@
     (nil? args) (usage)
     (= "-index" (first args))
     (do
-      (index/create-indicies (first args))
+      (index/create-indicies (second args))
       (println "Index created successfully!"))
     :else (usage)))


Clean up.

Clean up.

--- clj_record/core.clj
+++ clj_record/core.clj
@@ -8,13 +8,10 @@
   (pluralize (if (string? model-name) model-name (name model-name))))

 (defn run-callbacks [model-name record hook] ; XXX: Reasonable way to move this? Argh dependencies.
-  (let [callbacks (model-metadata-for model-name :callbacks)]
-    (if (nil? callbacks)
-      record
-      (let [funcs (callbacks hook)]
-        (loop [r record fs funcs]
-          (if (empty? fs) r
-            (recur ((first fs) r) (rest fs))))))))
+  (loop [r record
+         funcs ((or (model-metadata-for model-name :callbacks) {}) hook)]
+    (if (empty? funcs) r
+      (recur ((first funcs) r) (rest funcs)))))

 (defn to-conditions
   "Converts the given attribute map into a clojure.contrib.sql style 'where-params,'


Refactor Error Messages

Refactor Error Messages

--- src/lens/routes.clj
+++ src/lens/routes.clj
@@ -8,6 +8,9 @@

 (def media-types ["application/json" "application/transit+json"
                   "application/edn"])
+
+(defn decode-etag [etag]
+  (subs etag 1 (dec (count etag))))

 ;; ---- Routes ----------------------------------------------------------------

@@ -23,6 +26,14 @@

 (defn path-for [handler & params]
   (apply bidi/path-for routes handler params))
+
+(defn error-body [msg]
+  {:links {:up {:href (path-for :service-document-handler)}}
+   :error msg})
+
+(defn error [status msg]
+  {:status status
+   :body (error-body msg)})

 (defn workbook-path [workbook]
   (path-for :workbook-handler :id (:workbook/id workbook)))
@@ -102,8 +113,7 @@
      :id (:workbook/id workbook)})

   :handle-not-found
-  {:links {:up {:href (path-for :service-document-handler)}}
-   :error "Workbook not found."})
+  (error-body "Workbook not found."))

 ;; ---- Create Workbook -------------------------------------------------------

@@ -144,12 +154,10 @@
   (fnk [branch] (branch-path branch))

   :handle-not-found
-  {:links {:up {:href (path-for :service-document-handler)}}
-   :error "Workbook not found."}
+  (error-body "Workbook not found.")

   :handle-unprocessable-entity
-  {:links {:up {:href (path-for :service-document-handler)}}
-   :error "Branch name is missing."})
+  (error-body "Branch name is missing."))

 ;; ---- Add Query -------------------------------------------------------------

@@ -205,17 +213,7 @@
      :name (:branch/name branch)})

   :handle-not-found
-  {:links {:up {:href (path-for :service-document-handler)}}
-   :error "Branch not found."})
-
-(defn decode-etag [etag]
-  (subs etag 1 (dec (count etag))))
-
-(defn error [status msg]
-  {:status status
-   :body
-   {:links {:up {:href (path-for :service-document-handler)}}
-    :error msg}})
+  (error-body "Branch not found."))

 (defnk put-branch-handler [[:params conn id] headers :as req]
   (if-let [new-workbook-id (:workbook-id (:params req))]


Add Self Link to Service Document

Add Self Link to Service Document

--- src/lens/routes.clj
+++ src/lens/routes.clj
@@ -31,7 +31,8 @@
     :version version
     :last-loaded last-loaded
     :links
-    {:lens/all-study-events {:href "/study-events"}
+    {:self {:href "/"}
+     :lens/all-study-events {:href "/study-events"}
      :lens/all-forms {:href "/forms"}}
     :forms
     {:lens/query


Updated remote package loading method

Updated remote package loading method

--- src/spekl_package_manager/package.clj
+++ src/spekl_package_manager/package.clj
@@ -24,22 +24,27 @@

 (defn read-conf [conf]
   (yaml/parse-string conf))
+
+
+(defn create-package-url [name version]
+  (str constants/api-raw constants/org-name "/" name "/" version "/" (constants/package-filename)  ))
+
 ;;
 ;; used mostly for debugging, this function allows a LOCAL version of a package file to override a remote one
 ;;
-(defn locate-shadow-package-file [file-name]
+(defn locate-shadow-package-file [package version file-name]
   (try
     (if (.exists (io/as-file file-name))
       (io/as-file file-name)
-      (.getFile (io/resource file-name))
+      (create-package-url package version)
       )
     (catch NullPointerException e (throw (PackageLoadException. (str  "Cannot load local (resource-based) package file: " file-name))))
     )
   )

 (defn read-remote-conf
-    ([package version] (read-local-conf (locate-shadow-package-file (str "packages/" package "-" version ".yml"))))
-    ([package] (read-local-conf (locate-shadow-package-file (str "packages/" package ".yml")))))
+    ([package version] (read-local-conf (locate-shadow-package-file package version (str "packages/" package "-" version ".yml"))))
+    ([package] (read-local-conf (locate-shadow-package-file package "master" (str "packages/" package ".yml")))))

 (defn accuire-remote-package [package version]
   (log/info "[command-install] Finding package" package "in remote repository")


Improve the documentation of the bitrate calculation

--- src/mdr2/encode.clj
+++ src/mdr2/encode.clj
@@ -98,11 +98,16 @@
   [128 112 96 80 64 56 48])

 (defn ideal-bitrate
-  "Calculate the ideal bitrate based on the size of a production and
-  how much will generally fit on a CD-ROM. It will first try a higher
+  "Calculate the ideal bitrate based on the size of a production and how
+  much will generally fit on a CD-ROM. It will first try a higher
   bitrate (see `bitrates`). If the production still doesn't fit on one
   CD it will subsequently try lesser bitrates. Return 0 if the content
-  doesn't even fit on one CD with the lowest bitrate."
+  doesn't even fit on one CD with the lowest bitrate.
+
+  See also this web based [Audio File Size
+  Calculator](https://www.colincrawley.com/audio-file-size-calculator/)
+  and in particular the underlying [javascript
+  code](https://www.colincrawley.com/cc/wp-content/plugins/audio-file-size-calculator/audiofilesizecalculator.js)"
   [production]
   (let [dtb (path/recorded-path production)
         duration (quot (dtb/audio-length dtb) 1000) ; convert from millisecs to secs
@@ -111,7 +116,9 @@
         ;; two. The legacy system just added a tolerance of 2% for
         ;; stereo productions.
         sampling-ratio (if (dtb/mono? dtb) 1 1.02)
-        max-bitrate (/ (* (/ max-capacity duration sampling-ratio) 8) 1000)]
+        ;; BitRate is measured in kilobits per second
+        ;; BitRate (kbps) = (File Size (bytes) / Duration (seconds)) * 8/1000
+        max-bitrate (* (/ max-capacity duration sampling-ratio) (/ 8 1000))]
     (->> bitrates
          ;; for stereo productions use only bitrates larger than 96
          (filter #(or (dtb/mono? dtb) (>= % 96)))


removed require of test-utila from midje.sweet

--- src/midje/sweet.clj
+++ src/midje/sweet.clj
@@ -20,7 +20,6 @@
                                   future-fact-variant-names]])
   (:require [midje.ideas.background :as background]
             midje.checkers
-            [midje.test-util :as test-util]
             [midje.internal-ideas.report :as report]))

 (immigrate 'midje.unprocessed)


set of keys for restart listener "on-change"

--- src/mount/core.cljc
+++ src/mount/core.cljc
@@ -314,10 +314,11 @@
     (doseq [k ks]
       (swap! watchers update k #(conj % state))))

-  (on-change [_ k]
-    (let [states (@watchers k)]
-      (apply stop states)
-      (apply start states))))
+  (on-change [_ ks]
+    (doseq [k ks]
+      (let [states (@watchers k)]
+        (apply stop states)
+        (apply start states)))))

 (defn restart-listner
   ([]


csv obeys format

csv obeys format

--- src/ontrail/csv.clj
+++ src/ontrail/csv.clj
@@ -36,33 +36,40 @@
       (join-with ";" tags)
       (first tags))
     ""))
-
-(def extract-fields
+
+(def extract-funs
+  {"date" (comp to-csv-date :creationDate)
+   "title" :title
+   "sport" :sport
+   "distance" :distance
+   "duration" :duration
+   "pace" :pace
+   "avghr" :avghr
+   "url" (comp as-link :_id)
+   "distancetext" (comp to-human-distance :distance)
+   "durationtext" (comp to-human-time :duration)
+   "pacetext" get-pace
+   "tags" tags})
+
+(def default-keys
+  ["date" "title" "sport" "distance" "duration" "pace" "avghr" "url" "distancetext" "durationtext" "pacetext" "tags"])
+
+(defn extract-fields [keys]
   (apply juxt (mapv #(comp csv-escape %)
-                    [(comp to-csv-date :creationDate)
-                     :title
-                     :sport
-                     :distance
-                     :duration
-                     :pace
-                     :avghr
-                     (comp as-link :_id)
-                     (comp to-human-distance :distance)
-                     (comp to-human-time :duration)
-                     get-pace
-                     tags])))
+                    (mapv (partial get extract-funs) keys))))

 (defn ex-filter [year user]
   {"$and" [{:creationDate {"$gte" (time/date-time year 1 1)}} {:creationDate {"$lt" (time/date-time (inc year) 1 1)}} {:user user}]})

-(defn to-csv [exs]
+(defn to-csv [keys exs]
   (str
-   "date,title,sport,distance,duration,pace,avghr,url,distancetext,durationtext,pacetext,tags\r\n"
-   (join-with "\r\n" (map (partial join-with ",") (map extract-fields exs)))))
+   (join-with "," keys) "\r\n"
+   (join-with "\r\n" (map (partial join-with ",") (map (extract-fields keys) exs)))))

 (defn export [params]
   (.info logger (str "Exporting csv " params))
   (if-let [user (:user params)]
-    (let [year (if (:year params) (Integer/valueOf (:year params)) (time/year (time/now)))]
-      (to-csv (exs (ex-filter year user))))
+    (let [keys (if (:format params) (string/split (:format params) #",") default-keys)
+          year (if (:year params) (Integer/valueOf (:year params)) (time/year (time/now)))]
+      (to-csv keys (exs (ex-filter year user))))
     ""))


keep it to one line

keep it to one line

--- src/pcl/chap_03.clj
+++ src/pcl/chap_03.clj
@@ -58,13 +58,10 @@

 ;; probably a simpler, more efficient approach
 (defn save-db [db filename]
-  (spit
-   filename
-   (pr-str db)))
+  (spit filename (pr-str db)))

 (defn load-db [filename]
-  (with-in-str (slurp filename)
-    (read)))
+  (read-string (slurp filename)))

 ; fn literal instead of lambda
 ; :artist key in function position


[lein] bump deps

[lein] bump deps

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -1,22 +1,23 @@
-{:user {:plugins [[lein-cloverage                    "1.0.6"]
+{:user {:plugins [[lein-cloverage                    "1.0.9"]
                   [lein-fore-prob                    "0.1.2"]

                   ; Check for outdated dependencies
                   [lein-ancient                      "0.6.10"]

                   ; Code quality
-                  [lein-kibit                        "0.1.3"]
+                  [lein-kibit                        "0.1.5"]
                   [lein-bikeshed                     "0.4.1"]
-                  [jonase/eastwood                   "0.2.3"]
+                  [jonase/eastwood                   "0.2.4"]

                   [lein-pprint                       "1.1.2"]
-                  [lein-figwheel                     "0.5.9"]
+                  [lein-figwheel                     "0.5.10"]
                   [cider/cider-nrepl                 "0.14.0"]
                   [venantius/ultra                   "0.5.1"]
                   [venantius/yagni                   "0.1.4"]]

         :dependencies [; Code quality
-                       [slamhound                    "1.5.5"]]
+                       [slamhound                    "1.5.5"]
+                       [walmartlabs/datascope        "0.1.1"]]

         :aliases {"slamhound" ["run" "-m" "slam.hound"]}
         :signing {:gpg-key "E5B26621"}}}


Added cider NREPL

Added cider NREPL

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -1,11 +1,15 @@
 {:user
   {:plugins [
+    [cider/cider-nrepl "0.10.1"]
+    [refactor-nrepl "2.0.0-SNAPSHOT"]
+    [lein-cljfmt "0.3.0"]
     [lein-pprint "1.1.1"]
     [lein-assoc "0.1.0"]
     [jonase/eastwood "0.0.2"]
     [lein-expectations "0.0.7"]
     [lein-autoexpect "0.2.5"]
     [lein-ancient "0.5.5"]]
+  :repl-options {:timeout 300000}
   :aliases {"slamhound" ["run" "-m" "slam.hound"]}
   :dependencies [[slamhound "RELEASE"]
                  ;[clj-stacktrace "0.2.5"]


146/147

--- stuf/src/sandbox/4clojure.clj
+++ stuf/src/sandbox/4clojure.clj
@@ -1262,3 +1262,9 @@

 ;;145 For the win
 [1 5 9 13 17 21 25 29 33 37]
+
+;;146 Trees into tables
+#(into {} (for [[i m] %  [j v] m] [[i j] v]))
+
+;;147 Pascal's Trapezoid
+(fn [xs] (iterate #(map (partial apply +') (partition 2 1 (concat [0] % [0]))) xs))


Removing explicit dependency on test.check.


Update clojure version.

Update clojure version.


Increased version number

Increased version number


CSS aldaketak ere jaso

CSS aldaketak ere jaso


Version 1.6.3

Version 1.6.3


Upgrade postgresql driver version

Upgrade postgresql driver version


Don't check host keys

Don't check host keys


Make the tests pass

Make the tests pass

--- src/caesium/magicnonce/secretbox.clj
+++ src/caesium/magicnonce/secretbox.clj
@@ -130,7 +130,8 @@

   If no nonce argument is specified, a random nonce is automatically
   selected for you, and the NMR scheme is applied on top of that."
-  ([msg nonce key])
+  ([msg nonce key]
+   (secretbox-pfx msg (xor-inplace! (synthetic-nonce msg key) nonce) key))
   ([msg key]
    (secretbox-nmr msg (random-nonce!) key)))


fix token refreshing

fix token refreshing

--- src/chat/server/extensions/asana.clj
+++ src/chat/server/extensions/asana.clj
@@ -61,19 +61,21 @@

 (defn refresh-token
   [ext]
-  (let [refresh-token (:refresh-token ext)]
+  (let [refresh-tok (:refresh-token ext)]
     (let [resp @(http/post token-url
                            {:form-params {"grant_type" "refresh_token"
                                           "client_id" client-id
                                           "client_secret" client-secret
                                           "redirect_uri" redirect-uri
-                                          "refresh_token" refresh-token}})]
+                                          "refresh_token" refresh-tok}})]
       (if (= 200 (:status resp))
         (let [{:strs [access_token refresh_token]} (json/read-str (:body resp))]
           (db/with-conn
             (db/save-extension-token! (ext :id) {:access-token access_token
-                                                 :refresh-token refresh_token})))
-        (timbre/warnf "Bad response when exchanging token %s" (:body resp))))))
+                                                 :refresh-token (or refresh_token
+                                                                    refresh-tok)})))
+        (do (timbre/warnf "Bad response when exchanging token %s" (:body resp))
+            nil)))))

 ;; Webhooks
 (defn register-webhook
@@ -101,7 +103,9 @@
                   {:oauth-token (ext :token)})]
       (if (= 200 (:status resp))
         (-> resp :body json/read-str)
-        (timbre/warnf "token expired %s" (:body resp))))))
+        (do (timbre/warnf "token expired %s" (:body resp))
+            (when (refresh-token ext)
+              (fetch-asana-info extension-id path)))))))

 (defn available-workspaces
   [extension-id]


Trying more designs with core.logic

Trying more designs with core.logic

--- src/clj/algorithms_clj/ancestors.clj
+++ src/clj/algorithms_clj/ancestors.clj
@@ -26,7 +26,8 @@

 ;; http://kti.ms.mff.cuni.cz/~bartak/prolog/how.html

-(defn test-dbg
+(defn test-dbg-1
+  "First modelization: parent several times"
   []
   (pldb/db-rel link src dst)

@@ -41,6 +42,30 @@
   (defn has-parent?
     [x]
     (fresh [z] (link z x)))
+
+  (pldb/with-db dbg-facts
+    (run* [childs]
+      (has-parent? childs))
+    ))
+
+
+(defn test-dbg-2
+  "Different modelization: parent of a bunch of childs"
+  []
+  (pldb/db-rel link src dst)
+
+  (def dbg-facts
+    (pldb/db
+      [link 'a ['b 'c]] ;; Sets would be nicer, but seems not supported in core.logic
+      [link 'b ['c 'd]]
+      ))
+
+  (defn has-parent?
+    [x]
+    (fresh [parent childs]
+      (link parent childs)
+      (member1o x childs)
+      ))

   (pldb/with-db dbg-facts
     (run* [childs]


Add example to BlockEnumerator note.

Add example to BlockEnumerator note.

--- src/blocks/core.clj
+++ src/blocks/core.clj
@@ -206,7 +206,8 @@
 ; Protocol which returns a lazy sequence of every block in the store, along with
 ; an opaque marker which can be used to resume the stream in the same position.
 ; Blocks are explicitly **not** returned in any defined order; it is assumed the
-; store will enumerate them in the most efficient order available.
+; store will enumerate them in the most efficient order available. For example,
+; a file store could iterate them in on-disk order.

 (defn list


Add TODO note about efficient storage protocol.

--- src/blocks/core.clj
+++ src/blocks/core.clj
@@ -256,6 +256,8 @@

   If the source is a file, it will be streamed into the store. Otherwise, the
   content is read into memory, so this may not be suitable for large sources."
+  ; TODO: protocol for efficient storage? `store/receive!` maybe?
+  ; May need a protocol for turning a value into a block, as well.
   ([store source]
    (store! store source default-algorithm))
   ([store source algorithm]


done and tested move of form to root

done and tested move of form to root

--- src/casper/core.clj
+++ src/casper/core.clj
@@ -74,9 +74,12 @@

 (defroutes casper-routes

-  (GET "/" {context :context} (redirect (str context "/create")))
+  (GET "/" {context :context} (create-html context))

-  (GET "/create" {context :context}  (create-html context))
+  ; good example of a redirect
+  ; (GET "/" {context :context} (redirect (str context "/create")))
+
+  (GET "/create" {context :context}  "TBD")

   (GET "/secret/:id" [id]
     (let [ record  (first (select-secret id)) ]
@@ -110,7 +113,7 @@
       (build-response http-status-bad-request "Missing json form field" )
     )
   )
-  (POST "/create" {context :context, params :params,port :server-port,server :server-name}
+  (POST "/" {context :context, params :params,port :server-port,server :server-name}
     (if (not= nil (get params :secret))
       (let [ ttl (get params :ttl default-ttl )]


Fixed the default-material glitch.

Fixed the default-material glitch.

--- src/clj3D/fenvs.clj
+++ src/clj3D/fenvs.clj
@@ -41,7 +41,7 @@
     (.getResource (.getContextClassLoader (Thread/currentThread))
         "com/jme3/asset/Desktop.cfg")))

-(def default-material
+(defn default-material []
   (doto (Material. asset-manager "Common/MatDefs/Light/Lighting.j3md")
     (.setBoolean "UseMaterialColors" true)
     (.setColor "Ambient"  (get colors :black))
@@ -59,5 +59,5 @@
   [side]
   (let* [box (Box. (Vector3f. 0 0 0) side side side)
          cube (Geometry. "cube" box)]
-    (.setMaterial cube default-material)
+    (.setMaterial cube (default-material))
     cube))


Fixed bug with short file name

Fixed bug with short file name

--- src/export_server/utils/responce.clj
+++ src/export_server/utils/responce.clj
@@ -22,7 +22,7 @@
       (header "Access-Control-Allow-Headers" "X-Requested-With")))

 (defn file-success [byte-array file-name file-extention]
-  (let [file  ((partial apply #(File/createTempFile %1 %2) [file-name file-extention]))
+  (let [file  ((partial apply #(File/createTempFile %1 %2) ["anychart-export-tmp" file-extention]))
         fos (new FileOutputStream file)]
     (.write fos byte-array)
     (-> (response file)


Use map-indexed instead of a home-grown construct

--- src/mdr2/abacus.clj
+++ src/mdr2/abacus.clj
@@ -108,7 +108,7 @@
         (create-row 4 (production/dam-number production))] ; for legacy purposes
        (remove nil?) ; remove empty rows
        wrap-rows ; wrap the payload
-       (map #(conj %2 %1) (iterate inc 1)) ; number each row
+       (map-indexed #(conj %2 %1)) ; number each row
        (map #(string/join "," %))
        (map println-str)
        (string/join)))