Fix blending

Fix blending

--- src/zaffre/glterminal.clj
+++ src/zaffre/glterminal.clj
@@ -422,7 +422,7 @@
               i         (+ (* 4 (+ (* texture-columns row) col)) (* layer-size layer))
               [x y]     (get character->col-row chr)
               transparent (get character->transparent chr)]
-          (log/info "Drawing " layer-id "at col row" col row "character from atlas col row" x y c "(index=" i ") transparent" transparent )
+          ;(log/info "Drawing " layer-id "at col row" col row "character from atlas col row" x y c "(index=" i ") transparent" transparent )
           (when (zero? col)
             ;(log/info "glyph texture" glyph-texture-width glyph-texture-height)
             ;(log/info "resetting position to start of line" layer row col i)
@@ -617,13 +617,14 @@
         (assert (not (nil? font-texture-width)) "font-texture-width nil")
         (assert (not (nil? font-texture-height)) "font-texture-height")
         (assert (not (nil? font-texture)) "font-texture nil")
-        (log/info "drawing with" (mapv vec [glyph-textures fg-textures bg-textures glyph-image-data fg-image-data bg-image-data]))
+        ;(log/info "drawing with" (mapv vec [glyph-textures fg-textures bg-textures glyph-image-data fg-image-data bg-image-data]))
         ;; Setup render to FBO
         (try
           (GL30/glBindFramebuffer GL30/GL_FRAMEBUFFER, fbo-id)
           (GL11/glEnable GL11/GL_BLEND)
-          (GL30/glEnablei GL11/GL_BLEND fbo-id)
-          (GL14/glBlendFuncSeparate GL11/GL_SRC_ALPHA GL11/GL_ONE_MINUS_SRC_ALPHA GL11/GL_ONE GL11/GL_ONE_MINUS_SRC_ALPHA)
+          (GL11/glDisable GL11/GL_DEPTH_TEST)
+          (GL14/glBlendEquation GL14/GL_FUNC_ADD)
+          (GL11/glBlendFunc GL11/GL_ONE GL11/GL_ONE_MINUS_SRC_ALPHA)
           (GL11/glViewport 0 0 framebuffer-width framebuffer-height)
           (except-gl-errors (str "glViewport " framebuffer-width framebuffer-height))
           (GL11/glClearColor 0.0 0.0 0.0 0.0)
@@ -735,7 +736,6 @@
           (GL11/glViewport 0 0 framebuffer-width framebuffer-height)
           (GL11/glClearColor 0.0 0.0 0.0 0.0)
           (GL11/glClear (bit-or GL11/GL_COLOR_BUFFER_BIT GL11/GL_DEPTH_BUFFER_BIT))
-          (GL11/glBlendFunc GL11/GL_ONE GL11/GL_ONE_MINUS_SRC_ALPHA)
           (GL20/glUseProgram fb-program-id)
           (GL20/glUniformMatrix4fv u-fb-PMatrix false (ortho-matrix-buffer framebuffer-width framebuffer-height p-matrix-buffer))
           (except-gl-errors (str "u-fb-PMatrix - glUniformMatrix4  " u-fb-PMatrix))
@@ -747,10 +747,10 @@
               [framebuffer-width framebuffer-height 1.0]
               mv-matrix-buffer))
           (except-gl-errors (str "u-fb-MVMatrix - glUniformMatrix4  " u-fb-MVMatrix))
-          (GL20/glEnableVertexAttribArray 0);pos-vertex-attribute)
+          (GL20/glEnableVertexAttribArray 0);pos-vertex-attribute
           (except-gl-errors "vbo bind - glEnableVertexAttribArray")
           ;;; Setup uv buffer
-          (GL20/glEnableVertexAttribArray 1);texture-coords-vertex-attribute)
+          (GL20/glEnableVertexAttribArray 1);texture-coords-vertex-attribute
           (except-gl-errors "texture coords bind")
           ;;; Setup font texture
           (GL13/glActiveTexture GL13/GL_TEXTURE0)


Combine results of providers. Kind of hacky but i'll do.

--- src/tobias/cv.clj
+++ src/tobias/cv.clj
@@ -1,7 +1,7 @@
 (ns tobias.cv
   (:require [clj-http.client :as http]
             [clojure.data.json :as json]
-            [clojure.core.async :refer [chan alts!! thread >!!]]
+            [clojure.core.async :as async]
             [tobias.util :refer [timed load-config]])
   (:refer-clojure :exclude [name]))

@@ -85,16 +85,23 @@
 (defn get-features
   "Returns a normalized response for the features in the image"
   ([image]
-   (get-features image [sightcorp microsoft faceplus]))
+   (get-features image [sightcorp microsoft]))

   ([image providers]
-   (->> providers
-        (map (fn [provider]
-               (thread
-                 (timed (name provider)
-                        (->> image
-                             (features provider)
-                             (extract-json-body)
-                             (normalize provider))))))
-        (alts!!)     ; get the first result / chan pair
-        (first))))   ; only return the result
+   (let [merged-channels (->> providers
+                              (map (fn [provider]
+                                     (async/thread
+                                       (timed (name provider)
+                                              (->> image
+                                                   (features provider)
+                                                   (extract-json-body)
+                                                   (normalize provider))))))
+                              (async/merge))
+         one (first (async/<!! merged-channels))
+         two (first (async/<!! merged-channels))
+         combined-results (apply merge
+                                 (if (contains? one :clothing) ; sightcorp less accurate
+                                   [one two]
+                                   [two one]))]
+     (prn combined-results)
+     (conj [] combined-results))))


Доработка вывода сообщения об ошибке в транзите

--- radiolamp-6P3S/src/ixinfestor/net.cljs
+++ radiolamp-6P3S/src/ixinfestor/net.cljs
@@ -31,18 +31,25 @@

 (defn get-data [uri params success-fn & [error-fn complete-fn disable-progress-element?]]
-  (letfn [(print-error [s ee show-alert]
+  (letfn [(get-response-as-transit-or-text [ee]
+            (try
+              (t/read r (.getResponseText ee))
+              (catch js/Error e
+                (.getResponseText ee))))
+
+          (print-error [s ee show-alert]
             (println "ERROR IN " s "\n"
                      "LastErrorCode: " (.getLastErrorCode ee) "\n"
                      "Status: " (.getStatus ee) " - " (.getStatusText ee) "\n"
                      "Content-Type: " (.getResponseHeader ee "Content-Type") "\n"
                      "---------------------------------------------------------\n"
-                     (.getResponseText ee)
+                     (get-response-as-transit-or-text ee)
                      "\n---------------------------------------------------------\n\n")
             (when show-alert
               (js/alert (str
                          "ERROR IN [" s "]\n"
-                         "Status: " (.getStatus ee) " - " (.getStatusText ee)))))
+                         "Status: " (.getStatus ee) " - " (.getStatusText ee) "\n"
+                         (get-response-as-transit-or-text ee)))))

           ;; (redirect-to-root-when-not-transit [ee]
           ;;   (let [ct (.getResponseHeader ee "Content-Type")]


Fix merge omission--actually invoke shape-result

--- src/uruk/core.clj
+++ src/uruk/core.clj
@@ -362,14 +362,15 @@
   may be passed as a map of Strings or with String names corresponding
   to maps describing the variable using mandatory key `:value` and
   optional keys `:namespace` and `:type`.`"
-  [request-factory session query options variables types]
+  [request-factory session query options variables types shape]
   (let [req (sling/try+ (.submitRequest session
                                         (request-obj request-factory options variables))
                         (catch Exception e ;; XXX specifically XQueryException?
                           (sling/throw+ (doto (Exception. (.toString e))
                                           (.setStackTrace (:stack-trace &throw-context))))))]
-    (cond (= :raw types) req
-          :else          (convert-types req types))))
+    (shape-results (cond (= :raw types) req
+                         :else          (convert-types req types))
+                   shape)))

 (defn execute-xquery
   "Execute the given xquery query as a request to the database


(maint) Trim require line down to under 80 chars

--- test/integration/puppetlabs/services/jruby/puppet_environments_int_test.clj
+++ test/integration/puppetlabs/services/jruby/puppet_environments_int_test.clj
@@ -3,7 +3,8 @@
             [puppetlabs.puppetserver.bootstrap-testutils :as bootstrap]
             [puppetlabs.http.client.sync :as http-client]
             [puppetlabs.services.jruby.jruby-testutils :as jruby-testutils]
-            [puppetlabs.puppetserver.testutils :as testutils :refer [ssl-request-options catalog-request-options get-catalog]]
+            [puppetlabs.puppetserver.testutils :as testutils :refer
+             [ssl-request-options catalog-request-options get-catalog]]
             [me.raynes.fs :as fs]
             [puppetlabs.trapperkeeper.app :as tk-app]
             [puppetlabs.kitchensink.core :as ks]


Throw error by default when no representation

The previous code returned empty bodies when a produced representation
could not be rendered.

--- src/yada/body.clj
+++ src/yada/body.clj
@@ -181,20 +181,24 @@

 ;; defaults

-;; The error of 'No implementation for render-map for media-type: null, representation is {:representation nil}' is not acceptable in production, so as a workaround we return empty strings for the default renderer. In the future, we have different profiles for dev and prod which logic can use to balance trade-offs (fail-fast versus recover).
 (defmethod render-map :default
   [m representation]
-  (warnf "No implementation for render-map for media-type: %s, representation is %s. Rendering to an empty string."
-         (:name (:media-type representation))
-         {:representation representation})
-  "")
+  (throw
+   (ex-info
+    (format "No implementation for render-map for media-type: %s, representation is %s."
+            (:name (:media-type representation))
+            {:representation representation})
+    {:representation representation})))

 (defmethod render-seq :default
   [m representation]
-  (warnf "No implementation for render-seq for media-type: %s, representation is %s. Rendering to an empty string."
-         (:name (:media-type representation))
-         {:representation representation})
-  "")
+
+  (throw
+   (ex-info
+    (format "No implementation for render-seq for media-type: %s, representation is %s."
+            (:name (:media-type representation))
+            {:representation representation})
+    {:representation representation})))

 ;; Errors


Use shorthand for .item div

Use shorthand for .item div

--- src-cljs/frontend/components/pieces/card.cljs
+++ src-cljs/frontend/components/pieces/card.cljs
@@ -55,7 +55,7 @@
     (html
      [:div
       (for [card cards]
-        [:div.item card])]))))
+        [:.item card])]))))

 (dc/do
   (defcard basic-card


GAWB-1206: make it more robust

GAWB-1206: make it more robust

--- src/cljs/main/broadfcui/common/gcs_file_preview.cljs
+++ src/cljs/main/broadfcui/common/gcs_file_preview.cljs
@@ -28,12 +28,14 @@
           (labeled "Google Bucket" (:bucket-name props))
           (labeled "Object" (:object props))
           [:div {:style {:marginTop "1em"}}
-           [:div {} (when-not (= data-size "0") "Previews for some filetypes may be unsupported. ")]
+           [:div {} (if (or (= data-size "0") (clojure.string/blank? data-size))
+                      "File empty"
+                      "Previews for some filetypes may be unsupported. ")]
            (when (> data-size preview-byte-count) (str "Last " (:preview-line-count @state)
                                                        " lines are shown. Use link below to view entire file."))
            ;; The max-height of 206 looks random, but it's so that the top line of the log preview is half cut-off
            ;; to hint to the user that they should scroll up.
-           (when-not (= data-size "0")
+           (when-not (or (= data-size "0") (clojure.string/blank? data-size))
              (react/create-element
                [:div {:ref "preview" :style {:marginTop "1em" :whiteSpace "pre-wrap" :fontFamily "monospace"
                                              :fontSize "90%" :overflowY "auto" :maxHeight 206


Revert "Fixed concept validation."

Revert "Fixed concept validation."

This reverts commit 655dc1e140fe7dadae2c914aeab9bf8a8ca2ddb2.

--- src/cmr/metadata_db/services/concept_validations.clj
+++ src/cmr/metadata_db/services/concept_validations.clj
@@ -21,12 +21,12 @@
 (defn concept-id-validation
   [concept]
   (when-let [concept-id (:concept-id concept)]
-    (cc/validate-concept-id concept-id)))
+    (cc/concept-id-validation concept-id)))

 (defn concept-id-match-fields-validation
   [concept]
   (when-let [concept-id (:concept-id concept)]
-    (when-not (cc/validate-concept-id concept-id)
+    (when-not (cc/concept-id-validation concept-id)
       (let [{:keys [concept-type provider-id]} (cc/parse-concept-id concept-id)]
         (when-not (and (= concept-type (:concept-type concept))
                        (= provider-id (:provider-id concept)))


Changes 'Failed to get mesos agent state' log from ERROR to INFO (#1436)

--- scheduler/src/cook/mesos/sandbox.clj
+++ scheduler/src/cook/mesos/sandbox.clj
@@ -228,7 +228,7 @@
                         (send pending-sync-agent aggregate-pending-sync-hostname host :pending))
                       :success)
                     (catch Exception e
-                      (log/error e "Failed to get mesos agent state on" host)
+                      (log/info e "Failed to get mesos agent state on" host)
                       (send pending-sync-agent aggregate-pending-sync-hostname host :error)
                       :error)))
             cs (swap! mesos-agent-query-cache


Remove extraneous 49.

Remove extraneous 49.

--- src/mash_commander/core.cljs
+++ src/mash_commander/core.cljs
@@ -171,7 +171,7 @@
   [cursor]
   (as-> cursor c
     (assoc c :history [])
-    (assoc c :active {:state [:empty] :letters []})))49
+    (assoc c :active {:state [:empty] :letters []})))

 (defmethod dispatch-enter "say"
   [cursor]


minor cleanup

minor cleanup

--- src/metabase/driver/sync.clj
+++ src/metabase/driver/sync.clj
@@ -369,13 +369,14 @@

 (defn- mark-json-field!
   "Mark FIELD as `:json` if it's textual, doesn't already have a special type, the majority of it's values are non-nil, and all of its non-nil values
-   are valid serialized JSON dictionaries or arrays."
+   are valid serialized JSON dictionarie"
   [driver field]
   (when (and (not (:special_type field))
              (contains? #{:CharField :TextField} (:base_type field)))
     (try
       (let [valid-json-values-balance (atom 0)]
-        (doseq [val (field-values-lazy-seq driver field)]
+        (doseq [val (->> (field-values-lazy-seq driver field)
+                         (take max-sync-lazy-seq-results))]
           (if (s/blank? val)
             (swap! valid-json-values-balance dec)
             ;; If val is non-nil, check that it's a JSON dictionary or array. We don't want to mark Fields containing other types of valid JSON values as :json


Back to random games

Back to random games

--- src/obb_demo/views/play.cljs
+++ src/obb_demo/views/play.cljs
@@ -14,10 +14,11 @@
   #_(assoc-in game [:stash :p1] (dissoc (get-in game [:stash :p1]) :crusader))
   game)

-(defn- deployed-game
-  "Creates a deployed game"
+(defn- new-game
+  "Creates a new game"
   []
-  (-> (stash/create :rain 100
+  (game/random)
+  #_(-> (stash/create :rain 100
                     :raptor 100
                     :pretorian 40
                     :vector 50
@@ -25,7 +26,12 @@
                     :kamikaze 50
                     :fenix 25
                     :crusader 25)
-      (game/create)
+      (game/create)))
+
+(defn- deployed-game
+  "Creates a deployed game"
+  []
+  (-> (new-game)
       (tune-up)
       (turn/process-actions :p1 [[:auto-deploy :firingsquad]])
       (result/result-board)


Remove trailing whitespace

Remove trailing whitespace

--- src/main/clojure/clojure/test/check/clojure_test.clj
+++ src/main/clojure/clojure/test/check/clojure_test.clj
@@ -35,10 +35,10 @@
                              [*default-test-count* (first args)])
         options            (cond (nil? options)
                                  {:num-tests *default-test-count*}
-
+
                                  (integer? options)
                                  {:num-tests options}
-
+
                                  (map? options)
                                  (if (:num-tests options)
                                    options


simple speed test

simple speed test

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@10528 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/test.clj
+++ acqEngine/src/org/micromanager/test.clj
@@ -107,3 +107,8 @@
       (time (def q (doall (take-while identity (pop-n n))))))
   (println (count q) (core isBufferOverflowed)))

+(defn simple-test [n]
+  (core startSequenceAcquisition n 0 true)
+  (time (dotimes [i n]
+          (core popNextImage))))
+


moved docstring before arglist in validate-topology-name!

--- storm-multicore/src/clj/backtype/storm/daemon/nimbus.clj
+++ storm-multicore/src/clj/backtype/storm/daemon/nimbus.clj
@@ -285,8 +285,9 @@

 (def DISALLOWED-TOPOLOGY-NAME-STRS #{"/" "." ":" "\\"})

-(defn validate-topology-name! [name]
+(defn validate-topology-name!
   "Check that the name of the topology is valid."
+  [name]
   (if (some #(.contains name %) DISALLOWED-TOPOLOGY-NAME-STRS)
     (throw (InvalidTopologyException.
              (str "Topology name cannot contain any of the following: " (pr-str DISALLOWED-TOPOLOGY-NAME-STRS))))


Some optimizations for DL semantics

Some optimizations for DL semantics

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

--- src/conexp/contrib/dl/framework/semantics.clj
+++ src/conexp/contrib/dl/framework/semantics.clj
@@ -42,7 +42,7 @@
                                                   (interpretation-language interpretation)
                                                   (interpretation-base-set interpretation)
                                                   (interpretation-function interpretation))))]
-    (.write out (.trim output))))
+    (.write ^java.io.Writer out (.trim output))))

 ;;; Interpretations

@@ -63,7 +63,8 @@
   [interpretation dl-expression]
   ((compile-expression (if (dl-expression? dl-expression)
                         dl-expression
-                        (make-dl-expression (interpretation-language interpretation) dl-expression)))
+                        (make-dl-expression (interpretation-language interpretation)
+                                            dl-expression)))
    interpretation))

 (defmethod compile-expression ::base-case [dl-expression]
@@ -79,6 +80,7 @@
 	  ((base-semantics dl-expression) interpretation))
 	result))))

+
 ;;; base semantics (i.e. what to do if nothing else applies)

 (defmacro define-base-semantics
@@ -132,6 +134,7 @@
 (define-constructor inverse
   (let [r-I (interpret interpretation (first (arguments dl-exp)))]
     (set-of [y x] [[x y] r-I])))
+

 ;;; interpretation syntax

@@ -157,7 +160,8 @@
   [name language base-set & interpretations]
   `(def ~name (interpretation ~language ~base-set ~@interpretations)))

-;;; Most Specific Concepts
+
+;;; most specific concepts

 (defmulti most-specific-concept
   "Computes the model based most specific concept of a set of objects
@@ -238,27 +242,31 @@
     (runner data)))

 (defn- next-tbox-interpretation
-  "Defines a new interpretation on the defined concepts of tbox in
-  interpretation through an interpretation i of the defined concepts
-  of tbox."
+  "Defines a new interpretation function on the defined concepts of
+  tbox in interpretation through an interpretation i of the defined
+  concepts of tbox."
   [interpretation tbox i]
   (let [new-interpretation (extend-interpretation interpretation i)]
-    (into {} (for [[sym sym-def] (tbox-definition-map tbox)]
-               [sym (interpret new-interpretation (definition-expression sym-def))]))))
+    (reduce! (fn [map [sym sym-def]]
+               (assoc! map sym (interpret new-interpretation
+                                          (definition-expression sym-def))))
+             {}
+             (tbox-definition-map tbox))))

 (defn- constant-tbox-interpretation
-  "Returns an interpretation on the defined concepts of tbox,
+  "Returns an interpretation function on the defined concepts of tbox,
   constantly returning value."
   [tbox value]
-  (into {} (for [concept (defined-concepts tbox)]
-             [concept value])))
+  (map-by-fn (constantly value)
+             (defined-concepts tbox)))

 (defn gfp-model
   "Returns the gfp-model of tbox in interpretation."
   [tbox interpretation]
   (extend-interpretation
    interpretation
-   (fixed-point (fn [i] (next-tbox-interpretation interpretation tbox i))
+   (fixed-point (fn [i]
+                  (next-tbox-interpretation interpretation tbox i))
                 (constant-tbox-interpretation tbox
                                               (interpretation-base-set interpretation)))))

@@ -267,7 +275,8 @@
   [tbox interpretation]
   (extend-interpretation
    interpretation
-   (fixed-point (fn [i] (next-tbox-interpretation interpretation tbox i))
+   (fixed-point (fn [i]
+                  (next-tbox-interpretation interpretation tbox i))
                 (constant-tbox-interpretation tbox #{}))))

 ;;;


fix debug statement

fix debug statement

--- src/cylon/oauth/impl/authorization_server.clj
+++ src/cylon/oauth/impl/authorization_server.clj
@@ -226,7 +226,7 @@
                               :exp (plus (now) (days 1)) ; expiry
                               :iat (now)}]

-                   (info "Claim is %s" claim)
+                   (infof "Claim is %s" claim)

                    {:status 200
                     :body (encode {"access_token" access-token


Fix scale fn to use a midi note as the root and to actually return the correct result. Thanks to Iain Wood for spotting this and working on a solution.

--- src/overtone/music/pitch.clj
+++ src/overtone/music/pitch.clj
@@ -288,14 +288,17 @@
   (map #(if (keyword? %) (DEGREE %) %) degrees))

 (defn scale
-  ([root scale-name] (scale root scale-name (range 1 8) 4))
-  ([root scale-name degrees] (scale root scale-name degrees 4))
-  ([root scale-name degrees octave]
+  "Returns a list of notes for the specified scale. The root must be in
+   midi note format i.e. :C4 or :Bb4
+
+   (scale :c4 :major)  ; c major      -> (60 62 64 65 67 69 71 72)
+   (scale :Bb4 :minor) ; b flat minor -> (70 72 73 75 77 78 80 82)"
+
+  ([root scale-name] (scale root scale-name (range 1 8)))
+  ([root scale-name degrees]
      (let [root (resolve-note root)
-           degrees (resolve-degrees degrees)
-           scale (resolve-scale scale-name)
-           base (octave-note octave root)]
-       (map #(+ % base) scale))))
+           degrees (resolve-degrees degrees)]
+       (cons root (map #(+ root (nth-interval scale-name %)) degrees)))))

 (def CHORD
   (let [major  #{0 4 7}


further minor scale tweaks

further minor scale tweaks


Clean up docstrings

Clean up docstrings

--- src/overtone/music/pitch.clj
+++ src/overtone/music/pitch.clj
@@ -1,7 +1,7 @@
-(ns
-    ^{:doc "Functions to help generate and manipulate frequencies and sets of
-           related frequencies. This is the place for functions representing
-           general musical knowledge, like scales, chords, intervals, etc."
+(ns ^{:doc "Functions to help generate and manipulate frequencies and
+    sets of related frequencies. This is the place for functions
+    representing general musical knowledge, like scales, chords,
+    intervals, etc."
       :author "Jeff Rose, Sam Aaron & Marius Kempe"}
   overtone.music.pitch
   (:use [overtone.util old-contrib]
@@ -30,8 +30,9 @@
 (defratio min-sixth 8/5)

 (defn cents
-  "Returns a frequency computed by adding n-cents to freq.  A cent is a
-  logarithmic measurement of pitch, where 1-octave equals 1200 cents."
+  "Returns a frequency computed by adding n-cents to freq.  A cent is
+  a logarithmic measurement of pitch, where 1-octave equals 1200
+  cents."
   [freq n-cents]
   (* freq (java.lang.Math/pow 2 (/ n-cents 1200))))

@@ -61,8 +62,8 @@
   (shift phrase notes +1))

 (defn invert
-  "Invert a sequence of notes using either the first note as the stationary
-  pivot point or the optional second argument."
+  "Invert a sequence of notes using either the first note as the
+  stationary pivot point or the optional second argument."
   [notes & [pivot]]
   (let [pivot (or pivot (first notes))]
     (for [n notes] (- pivot (- n pivot)))))
@@ -133,7 +134,8 @@
     matches))

 (defn note-map
-  "Takes a match array returned by a regexp match and returns a map of note info"
+  "Takes a match array returned by a regexp match and returns a map of
+  note info"
   [midi-string]
   (let [[match pitch-class octave] (validate-midi-string! midi-string)
         pitch-class                (canonical-pitch-class-name pitch-class)
@@ -160,9 +162,10 @@
     res))

 (defn note
-  "Resolves note to MIDI number format. Resolves upper and lower-case keywords
-  and strings in MIDI note format. If given an integer or nil, returns them
-  unmodified. All other inputs will raise an exception.
+  "Resolves note to MIDI number format. Resolves upper and lower-case
+  keywords and strings in MIDI note format. If given an integer or
+  nil, returns them unmodified. All other inputs will raise an
+  exception.

   Usage examples:

@@ -187,9 +190,9 @@
     :else (throw (IllegalArgumentException. (str "Unable to resolve note: " n ". Wasn't a recognised format (either an integer, keyword, string or nil)")))))

 (defn match-note
-  "Returns the first midi-note formatted substring in s. If passed optional prev
-   and pos strings will use them to generate positive look ahead and behind
-   matchers. "
+  "Returns the first midi-note formatted substring in s. If passed
+   optional prev and pos strings will use them to generate positive
+   look ahead and behind matchers. "
   ([s] (match-note s "" ""))
   ([s prev-str post-str]
      (let [look-behind (if prev-str (str "(?<=" prev-str ")") "")
@@ -260,19 +263,22 @@
    :messiaen7         [1 1 1 2 1 1 1 1 2 1]}))

 (defn resolve-scale
-  "Either looks the scale up in the map of SCALEs if it's a keyword or simply
-  returns it unnmodified. Allows users to specify a scale either as a seq
-  such as [2 2 1 2 2 2 1] or by keyword such as :aeolian"
+  "Either looks the scale up in the map of SCALEs if it's a keyword or
+  simply returns it unnmodified. Allows users to specify a scale
+  either as a seq such as [2 2 1 2 2 2 1] or by keyword such
+  as :aeolian"
   [scale]
   (if (keyword? scale)
     (SCALE scale)
     scale))

-(defn scale-field [skey & [sname]]
-  "Create the note field for a given scale.  Scales are specified with a keyword
-  representing the key and an optional scale name (defaulting to :major):
+(defn scale-field
+  "Create the note field for a given scale.  Scales are specified with
+  a keyword representing the key and an optional scale
+  name (defaulting to :major):
   (scale-field :g)
   (scale-field :g :minor)"
+  [skey & [sname]]
   (let [base (NOTES skey)
         sname (or sname :major)
         intervals (SCALE sname)]
@@ -284,12 +290,13 @@
             (take (* 8 12) (cycle intervals)))))))

 (defn nth-interval
-  "Return the count of semitones for the nth degree from the start of the
-  diatonic scale in the specific mode (or ionian/major by default).
-
-  i.e. the ionian/major scale has an interval sequence of 2 2 1 2 2 2 1
-       therefore the 4th degree is (+ 2 2 1 2) semitones from the start of the
-       scale."
+  "Return the count of semitones for the nth degree from the start of
+  the diatonic scale in the specific mode (or ionian/major by
+  default).
+
+  i.e. the ionian/major scale has an interval sequence of 2 2 1 2 2 2
+       1 therefore the 4th degree is (+ 2 2 1 2) semitones from the
+       start of the scale."
   ([n] (nth-interval :diatonic n))
   ([scale n]
      (reduce + (take n (cycle (scale SCALE))))))
@@ -334,27 +341,28 @@
          :semitone-shift semitone-shift}))))

 (defn degree->interval
-  "Converts the degree of a scale given as a roman numeral keyword and converts
-  it to the number of intervals (semitones) from the tonic of the specified
-  scale.
-
-  Trailing #, b, + - represent sharps, flats, octaves up and down respectively.
-  An arbitrary number may be added in any order."
-  ([degree scale]
-     (cond
-      (nil? degree) nil
-      (= :_ degree) nil
-
-      (number? degree) (nth-interval scale (dec degree))
-
-      (keyword? degree) (let [degree     (resolve-degree degree)
-                              interval   (nth-interval scale (dec (:degree degree)))
-                              oct-shift  (* 12 (:octave-shift degree))
-                              semi-shift (:semitone-shift degree)]
-                          (+ interval oct-shift semi-shift)))))
+  "Converts the degree of a scale given as a roman numeral keyword and
+  converts it to the number of intervals (semitones) from the tonic of
+  the specified scale.
+
+  Trailing #, b, + - represent sharps, flats, octaves up and down
+  respectively.  An arbitrary number may be added in any order."
+  [degree scale]
+  (cond
+    (nil? degree) nil
+    (= :_ degree) nil
+
+    (number? degree) (nth-interval scale (dec degree))
+
+    (keyword? degree) (let [degree     (resolve-degree degree)
+                            interval   (nth-interval scale (dec (:degree degree)))
+                            oct-shift  (* 12 (:octave-shift degree))
+                            semi-shift (:semitone-shift degree)]
+                        (+ interval oct-shift semi-shift))))

 (defn degrees->pitches
-  "Convert intervals to pitches in MIDI number format.  Supports nested collections."
+  "Convert intervals to pitches in MIDI number format.  Supports
+  nested collections."
   [degrees scale root]
   (let [root (note root)]
     (when (nil? root)
@@ -374,8 +382,8 @@
   (map #(if (keyword? %) (DEGREE %) %) degrees))

 (defn scale
-  "Returns a list of notes for the specified scale. The root must be in
-   midi note format i.e. :C4 or :Bb4
+  "Returns a list of notes for the specified scale. The root must be
+   in midi note format i.e. :C4 or :Bb4

    (scale :c4 :major)  ; c major      -> (60 62 64 65 67 69 71 72)
@@ -450,9 +458,9 @@
      :i7         dim7}))

 (defn resolve-chord
-  "Either looks the chord up in the map of CHORDs if it's a keyword or simply
-  returns it unnmodified. Allows users to specify a chord either with a set
-  such as #{0 4 7} or by keyword such as :major"
+  "Either looks the chord up in the map of CHORDs if it's a keyword or
+  simply returns it unnmodified. Allows users to specify a chord
+  either with a set such as #{0 4 7} or by keyword such as :major"
   [chord]
   (if (keyword? chord)
     (CHORD chord)
@@ -484,8 +492,8 @@
     (zero? shift) notes))

 (defn chord
-  "Returns a set of notes for the specified chord. The root must be in midi note
-  format i.e. :C3.
+  "Returns a set of notes for the specified chord. The root must be in
+  midi note format i.e. :C3.

   (chord :c3 :major)  ; c major           -> #{60 64 67}
   (chord :a4 :minor)  ; a minor           -> #{57 60 64}
@@ -500,9 +508,10 @@
        (invert-chord notes inversion))))

 (defn rand-chord
-  "Generates a random list of MIDI notes with cardinality num-pitches bound
-  within the range of the specified root and pitch-range and only containing
-  pitches within the specified chord-name. Similar to Impromptu's pc:make-chord"
+  "Generates a random list of MIDI notes with cardinality num-pitches
+  bound within the range of the specified root and pitch-range and
+  only containing pitches within the specified chord-name. Similar to
+  Impromptu's pc:make-chord"
   [root chord-name num-pitches pitch-range]
   (let [chord (chord root chord-name)
         root (note root)
@@ -542,21 +551,22 @@
 (defn nth-octave
   "Returns the freq n octaves from the supplied reference freq

-   i.e. (nth-ocatve 440 1) will return 880 which is the freq of the next octave
-   from 440."
+   i.e. (nth-ocatve 440 1) will return 880 which is the freq of the
+   next octave from 440."
   [freq n]
   (* freq (java.lang.Math/pow 2 n)))

 (defn nth-equal-tempered-freq
-  "Returns the frequency of a given scale interval using an equal-tempered
-  tuning i.e. dividing all 12 semi-tones equally across an octave. This is
-  currently the standard tuning."
+  "Returns the frequency of a given scale interval using an
+  equal-tempered tuning i.e. dividing all 12 semi-tones equally across
+  an octave. This is currently the standard tuning."
   [base-freq interval]
   (* base-freq (java.lang.Math/pow 2 (/ interval 12))))

 (defn interval-freq
-  "Returns the frequency of the given interval using the specified mode and
-  tuning (defaulting to ionian and equal-tempered respectively)."
+  "Returns the frequency of the given interval using the specified
+  mode and tuning (defaulting to ionian and equal-tempered
+  respectively)."
   ([base-freq n] (interval-freq base-freq n :ionian :equal-tempered))
   ([base-freq n mode tuning]
      (case tuning
@@ -585,23 +595,25 @@
   (REVERSE-NOTES (mod note 12)))

 (defn- fold-note
-  "Folds note intervals into a 2 octave range so that chords using notes
-  spread across multiple octaves can be correctly recognised."
+  "Folds note intervals into a 2 octave range so that chords using
+  notes spread across multiple octaves can be correctly recognised."
   [note]
   (if (or (< 21 note) (contains? #{20 19 16 12} note))
     (fold-note (- note 12))
      note ))

 (defn- simplify-chord
-  "expects notes to contain 0 (the root note) Reduces all notes into 2 octaves. This will allow
-  identification of fancy jazz chords, but will miss some simple chords if they are spread over
-  more than 1 octave."
+  "expects notes to contain 0 (the root note) Reduces all notes into 2
+  octaves. This will allow identification of fancy jazz chords, but
+  will miss some simple chords if they are spread over more than 1
+  octave."
   [notes]
   (set (map (fn [x] (fold-note x)) notes)))

 (defn- compress-chord
-  "expects notes to contain 0 (the root note) Reduces all notes into 1 octave. This will lose
-  all the fancy jazz chords but recognise sparse multiple octave smple chords"
+  "expects notes to contain 0 (the root note) Reduces all notes into 1
+  octave. This will lose all the fancy jazz chords but recognise
+  sparse multiple octave smple chords"
   [notes]
   (set (map (fn [x] (mod x 12)) notes)))


deferred model-session creation

deferred model-session creation

--- src/er_cassandra/model/alia/model_session.clj
+++ src/er_cassandra/model/alia/model_session.clj
@@ -51,8 +51,11 @@
 (defnk create-session
   [contact-points keyspace {port nil} :as args]
   (with-context deferred-context
-    (mlet [alia-session (a/create-session args)]
-      (->AliaModelSession alia-session))))
+    (mlet [[alia-session _] (a/create-session args)
+           :let [model-session (->AliaModelSession alia-session)]]
+      (return
+       [model-session
+        (fn [] (ms/-close model-session))]))))

 (defrecord AliaModelSpySession [alia-session model-spy-log-atom]
   ModelSession
@@ -125,16 +128,20 @@
     (reset! model-spy-log-atom [])
     (s/reset-spy-log alia-session)))

-(defn create-spy-session*
-  [alia-session]
-  (->AliaModelSpySession alia-session (atom [])))
-
 (defnk create-spy-session
   [contact-points keyspace {port nil} {truncate-on-close nil} :as args]
-  (let [alia-session (a/create-spy-session args)]
-    (create-spy-session* alia-session)))
+  (with-context deferred-context
+    (mlet [[alia-session _] (a/create-spy-session args)
+           :let [spy-session (->AliaModelSpySession alia-session (atom []))]]
+      (return
+       [spy-session
+        (fn [] (ms/-close spy-session))]))))

 (defnk create-test-session
   [{contact-points nil} {port nil} {datacenter nil} keyspace :as args]
-  (let [alia-session (a/create-test-session args)]
-    (create-spy-session* alia-session)))
+  (with-context deferred-context
+    (mlet [[alia-test-session _] (a/create-test-session args)
+           :let [model-test-session (->AliaModelSpySession alia-test-session (atom []))]]
+      (return
+       [model-test-session
+        (fn [] (ms/-close model-test-session))]))))


put autofocus back

put autofocus back

Former-commit-id: 7db357150897e9cd998b9a12915bc5cd18ec16a8

--- src/syng_im/components/chat/plain_message_input.cljs
+++ src/syng_im/components/chat/plain_message_input.cljs
@@ -34,8 +34,8 @@
                                              :fontSize   14
                                              :fontFamily "Avenir-Roman"
                                              :color      "#9CBFC0"}
-                     :autoFocus             false
-                     :placeholder           "Type"
+                     :autoFocus             true
+                     :placeholder           "Type your message here"
                      :value                 @text
                      :onChangeText          (fn [new-text]
                                               (dispatch [:generate-suggestions new-text])


Improve regex, demand http/s prefix

Improve regex, demand http/s prefix


Add docstrings to test helper fns

Add docstrings to test helper fns

--- src/test/clojure/clojure/tools/test_logging.clj
+++ src/test/clojure/clojure/tools/test_logging.clj
@@ -7,31 +7,41 @@
     [clojure.tools.logging.test :as log-test :refer [logged?
                                                      matches]]))

-; TODO: Improve tools.logging.test so that the ability to check the thread is
-;       not so hacky/out-of-band from the normal flow.
-
-
-(defn log-entry-with-thread [logger-ns level throwable message]
+
+(defn log-entry-with-thread
+  "Returns a log entry that also captures the current thread."
+  [logger-ns level throwable message]
   (assoc (log-test/->LogEntry logger-ns level throwable message)
          ::thread (Thread/currentThread)))

-(defn same-thread? [log-entry]
+(defn same-thread?
+  "Returns true if the thread that created the log entry is the current thread."
+  [log-entry]
+  (when-not (::thread log-entry)
+    (throw (ex-info "Log entry does not have a thread." log-entry)))
   (identical? (::thread log-entry)
               (Thread/currentThread)))

-(defn direct-logged? [logger-ns level throwable message]
+(defn direct-logged?
+  "Returns true if there is a matching entry that also was created with the
+  current thread, i.e., not via an agent."
+  [logger-ns level throwable message]
   (->> (log-test/matches logger-ns level throwable message)
     (filter same-thread?)
     seq
     boolean))

-(defn agent-logged? [logger-ns level throwable message]
+(defn agent-logged?
+  "Returns true if there is a matching entry that also was created with a thread
+  other than the current thread, i.e., via an agent."
+  [logger-ns level throwable message]
   (->> (log-test/matches logger-ns level throwable message)
     (remove same-thread?)
     seq
     boolean))

-(defmacro with-log [& body]
+(defmacro with-log
+  [& body]
   `(let [stateful-log# (log-test/atomic-log log-entry-with-thread)
          logger-factory# (log-test/logger-factory stateful-log# (constantly true))]
      (binding [log-test/*stateful-log*   stateful-log#


Better error message

Better error message

--- modules/less/src/modular/less.clj
+++ modules/less/src/modular/less.clj
@@ -69,8 +69,12 @@
   "A constructor returning a configured Less compiler for Twitter Bootstrap resources"
   [& {:keys [version] :or {version "3.3.0"} :as opts}]

-  (assert (io/resource (format "META-INF/resources/webjars/bootstrap/%s/less/bootstrap.less" version))
-          "Bootstrap resources not found on classpath")
+  (if-not (io/resource (format "META-INF/resources/webjars/bootstrap/%s/less/bootstrap.less" version))
+    (throw
+     (ex-info
+      (format "Bootstrap resources not found on classpath, have you added [org.webjars/bootstrap \"%s\"] to project.clj?" version)
+      {})))
+
   (->> opts
     (merge {:engine :nashorn
             :resource-dir "resources/less"


Fix indent on clojure testing function

Fix indent on clojure testing function

--- storm-core/src/clj/org/apache/storm/testing.clj
+++ storm-core/src/clj/org/apache/storm/testing.clj
@@ -90,13 +90,13 @@
   []
   (Time/stopSimulating))

- (defmacro with-simulated-time
-   [& body]
-   `(try
-     (start-simulating-time!)
-     ~@body
-     (finally
-       (stop-simulating-time!))))
+(defmacro with-simulated-time
+  [& body]
+  `(try
+    (start-simulating-time!)
+    ~@body
+    (finally
+      (stop-simulating-time!))))

 (defn advance-time-ms! [ms]
   (Time/advanceTime ms))


wording in warning

wording in warning

--- src/re_frame/middleware.cljs
+++ src/re_frame/middleware.cljs
@@ -103,7 +103,7 @@
                           (fn? explanation)     (explanation db event-vec)
                           (string? explanation) explanation
                           (nil? explanation)    ""
-                          :else (warn "re-frame: undoable given bad parameter. Got: " explanation))]
+                          :else (warn "re-frame: undoable given a bad parameter. Got: " explanation))]
       (store-now! explanation)
       (handler db event-vec)))))


Mihir | Making recursion TCO

Mihir | Making recursion TCO

--- src/aggregate_query_service/core.clj
+++ src/aggregate_query_service/core.clj
@@ -33,13 +33,15 @@

 (defn render-query
   [query-params-map query]
-  (if (empty? query-params-map)
-    query
-    (let [key (ffirst query-params-map)
-          reduced-map (dissoc query-params-map key)
-          param-value (get query-params-map key)
-          param-name (name key)]
-      (render-query reduced-map (replace-param query param-value param-name)))))
+  (loop [query-params-map query-params-map
+         query query]
+    (if (empty? query-params-map)
+      query
+      (let [key (ffirst query-params-map)
+            reduced-map (dissoc query-params-map key)
+            param-value (get query-params-map key)
+            param-name (name key)]
+        (recur reduced-map (replace-param query param-value param-name))))))

 (defn render-queries
   [query-params-map query-list]


updates dependency versions to avoid conflicts (#1547)

--- waiter/project.clj
+++ waiter/project.clj
@@ -83,11 +83,11 @@
                  [org.clojure/clojure "1.10.3"]
                  [org.clojure/core.async "1.5.648"
                   :exclusions [org.clojure/clojure org.clojure/tools.reader]]
-                 [org.clojure/core.memoize "1.0.236"
+                 [org.clojure/core.memoize "1.0.253"
                   :exclusions [org.clojure/clojure]]
                  [org.clojure/data.codec "0.1.1"]
                  [org.clojure/data.json "1.0.0"]
-                 [org.clojure/data.priority-map "1.0.0"]
+                 [org.clojure/data.priority-map "1.1.0"]
                  [org.clojure/data.zip "1.0.0"]
                  [org.clojure/tools.cli "1.0.194"]
                  [org.clojure/tools.logging "1.1.0"]


Remove misleading failure messages

Remove misleading failure messages

There are a couple tests that logically can fail but statistically
cannot, as the probabilities involved are too astronomical. Removed the
the uncertainty in the error message and attached comments about the
estimated probability of failure.

The code used to estimate those probabilities is below for posterity:

(let [total-possibilities (apply *' (repeat 10000 3))
      ways-to-return-exactly-one-thing 3
      ways-to-return-exactly-two-things (- (* 3 (apply *' (repeat 10000 2)))
                                           ways-to-return-exactly-one-thing)
      ways-to-fail (+ ways-to-return-exactly-one-thing
                      (* 2/3 ways-to-return-exactly-two-things))
      prob-of-failure (/ ways-to-fail total-possibilities)]
  (count (str (quot (denominator prob-of-failure) (numerator prob-of-failure)))))
;; => 1761

(let [total-possibilities (apply *' (repeat 10000 4))
      ways-to-return-exactly-one-thing 4
      ways-to-return-exactly-two-things (- (* 6 (apply *' (repeat 10000 2)))
                                           ways-to-return-exactly-one-thing)
      ways-to-return-exactly-three-things (- (* 4 (apply *' (repeat 10000 3)))
                                             ways-to-return-exactly-two-things
                                             ways-to-return-exactly-one-thing)
      ways-to-fail (+ ways-to-return-exactly-one-thing
                      ways-to-return-exactly-two-things
                      ways-to-return-exactly-three-things)
      prob-of-failure (/ ways-to-fail total-possibilities)]
  (count (str (quot (denominator prob-of-failure) (numerator prob-of-failure)))))
;; => 1249

--- src/test/clojure/clojure/test/check/test.cljc
+++ src/test/clojure/clojure/test/check/test.cljc
@@ -718,10 +718,10 @@
            r (random/make-random)]
       (cond
        (== trials 10000)
-       (is nil (str "rand-range didn't return both of its bounds after 10000 trials; "
-                    "it is possible for this to fail without there being a problem, "
-                    "but we should be able to rely upon probability to not bother us "
-                    "too frequently."))
+       ;; the probability of this happening by chance is roughly 1 in
+       ;; 10^1761 so we can safely assume something's wrong if it does
+       (is nil "rand-range didn't return both of its bounds after 10000 trials")
+
        (empty? bounds) (is true)
        :else (let [[r1 r2] (random/split r)]
                (recur (inc trials) (disj bounds (rand-range r1)) r2))))))
@@ -734,10 +734,9 @@
                  (gen/sample-seq (gen/elements options)))
              (take 10000)
              (some empty?))
-        (str "elements didn't return all of its candidate values after 10000 trials; "
-             "it is possible for this to fail without there being a problem, "
-             "but we should be able to rely upon probability to not bother us "
-             "too frequently."))))
+        ;; the probability of this happening by chance is roughly 1 in
+        ;; 10^1249 so we can safely assume something's wrong if it does
+        "elements didn't return all of its candidate values after 10000 trials")))

 ;; shuffling a vector generates a permutation of that vector
 ;; ---------------------------------------------------------------------------


fix accessibility

fix accessibility

--- src/status_im/ui/screens/wallet/accounts/sheets.cljs
+++ src/status_im/ui/screens/wallet/accounts/sheets.cljs
@@ -22,7 +22,7 @@
       {:theme               :accent
        :title               (i18n/label :t/scan-tokens)
        :icon                :main-icons/refresh
-       :accessibility-label :wallet-manage-assets
+       :accessibility-label :wallet-scan-token
        :on-press            #(hide-sheet-and-dispatch
                               [:wallet/update-balances nil true])}]
      [quo/list-item


Fixed index exception when text field has very small h-size

--- flatguiwidgets/src/flatgui/widgets/textfield.clj
+++ flatguiwidgets/src/flatgui/widgets/textfield.clj
@@ -286,7 +286,7 @@
                   (if (or
                         (> (+ old-first-visible-symbol i) (.length text))
                         (>= (awt/strw component (subs text old-first-visible-symbol (+ old-first-visible-symbol i))) diff))
-                    i
+                    (min i (dec (.length text)))
                     (recur
                       (inc i))))))
             old-first-visible-symbol))))


Removed unnecessary functions

Removed unnecessary functions

--- src/scramblyzer/analyzer.clj
+++ src/scramblyzer/analyzer.clj
@@ -61,18 +61,6 @@
     piece
     "@?"))

-(defn- string->pieces
-  [reid-string]
-  (split reid-string #" "))
-
-(defn- reid-edges
-  [reid-string]
-  (take 12 (string->pieces reid-string)))
-
-(defn- reid-corners
-  [reid-string]
-  (drop 12 (string->pieces reid-string)))
-
 (defn- filter-pieces
   ([pred state]
    (filter-pieces pred pred state))


Fix handler not returning state in certain situations

--- src/braid/client/state/handlers.cljs
+++ src/braid/client/state/handlers.cljs
@@ -63,7 +63,7 @@
   (helpers/set-message-failed! state message))

 (defmethod handler :new-message [state [_ data]]
-  (when-not (string/blank? (data :content))
+  (if-not (string/blank? (data :content))
     (let [message (schema/make-message
                     {:user-id (helpers/current-user-id state)
                      :content (identify-mentions (data :content))
@@ -82,7 +82,8 @@
             (dispatch! :set-message-failed message))))
       (-> state
           (helpers/add-message message)
-          (helpers/maybe-reset-new-thread-id (data :thread-id))))))
+          (helpers/maybe-reset-new-thread-id (data :thread-id))))
+    state))

 (defmethod handler :clear-error [state [_ err-key]]
   (helpers/clear-error state err-key))


Only show clojure version when not showing search bar

--- src/clj/clojuredocs/pages/common.clj
+++ src/clj/clojuredocs/pages/common.clj
@@ -54,10 +54,11 @@
       [:button.btn.btn-default.navbar-btn.pull-right.mobile-menu
        [:i.fa.fa-bars]]
       [:ul.navbar-nav.nav.navbar-right.desktop-navbar-nav
-       [:li
-        [:div.navbar-brand.clojure-version
-         [:a {:href (:gh-tag-url search/clojure-lib)}
-          (:version search/clojure-lib)]]]
+       (when hide-search
+         [:li
+          [:div.navbar-brand.clojure-version
+           [:a {:href (:gh-tag-url search/clojure-lib)}
+            (:version search/clojure-lib)]]])
        [:li [:a {:href "/core-library"} "Core Library"]]
        [:li [:a {:href "/quickref"} "Quick Reference"]]
        (if user


WIP - Added alias-sensor to Prismatic schema.

--- src/clj/kixi/hecuba/data/sensors.clj
+++ src/clj/kixi/hecuba/data/sensors.clj
@@ -30,6 +30,7 @@
              (s/optional-key :synthetic)                   (s/maybe s/Bool)
              (s/optional-key :unit)                        (s/maybe s/Str)
              (s/optional-key :user_id)                     (s/maybe s/Str)
+             (s/optional-key :alias-sensor)                (s/maybe {s/Str s/Str})
              s/Any                                         s/Any})

 (defn validate-and-log [sensor]


small fix

small fix

--- src/cljs/salava/profile/ui/edit.cljs
+++ src/cljs/salava/profile/ui/edit.cljs
@@ -98,21 +98,21 @@
                                                                                (as-> (get-in logic [@current :save-and-previous!]) f (f)))}
                                                              [:div {:id "step-button-previous"}
                                                                    (t :core/Previous)]])
-                                         [:button {:class    "btn btn-primary"
-                                                   :on-click #(do
-                                                                (.preventDefault %)
-                                                                (swap! state assoc :spinner true :active-button "btn-1")
-                                                                (js/setTimeout (fn [] (save-profile state (fn [] (swap! state assoc :spinner false)) true)) 2000))}
-                                          (when (and (:spinner @state) (= "btn-1" (:active-button @state))) [:i.fa.fa-spinner.fa-spin.fa-lg {:style {:padding "0 3px"}}])(t :page/Save)]
-                                         [:button.btn.btn-warning {:href "#"
-                                                                   :on-click #(do
-                                                                                (.preventDefault %)
-                                                                                (swap! state assoc :spinner true :active-button "btn-2")
-                                                                                (save-profile state (fn [] (do
-                                                                                (swap! state assoc :spinner false)
-                                                                                (js-navigate-to (str "/profile/"(:user-id @state))))) true))}
-
-                                          (when (and (:spinner @state) (= "btn-2" (:active-button @state))) [:i.fa.fa-spinner.fa-spin.fa-lg {:style {:padding "0 3px"}}]) (t :profile/Saveandclose) #_(t :page/View)]
+                                         [:div {:style {:display "inline-flex"}} [:button {:class    "btn btn-primary"
+                                                                                :on-click #(do
+                                                                                (.preventDefault %)
+                                                                                (swap! state assoc :spinner true :active-button "btn-1")
+                                                                                (js/setTimeout (fn [] (save-profile state (fn [] (swap! state assoc :spinner false)) true)) 2000))}
+                                                                                (when (and (:spinner @state) (= "btn-1" (:active-button @state))) [:i.fa.fa-spinner.fa-spin.fa-lg {:style {:padding "0 3px"}}])(t :page/Save)]
+                                          [:button.btn.btn-warning {:href "#"
+                                                                    :on-click #(do
+                                                                                (.preventDefault %)
+                                                                                (swap! state assoc :spinner true :active-button "btn-2")
+                                                                                (save-profile state (fn [] (do
+                                                                                (swap! state assoc :spinner false)
+                                                                                (js-navigate-to (str "/profile/"(:user-id @state))))) true))}
+
+                                           (when (and (:spinner @state) (= "btn-2" (:active-button @state))) [:i.fa.fa-spinner.fa-spin.fa-lg {:style {:padding "0 3px"}}]) (t :profile/Saveandclose) #_(t :page/View)]]
                                          (when next?  [:a {:href "#"
                                                            :on-click #(do
                                                                        (.preventDefault %)


fix stripe-cents fn for negative numbers

--- src-cljs/frontend/components/plan.cljs
+++ src-cljs/frontend/components/plan.cljs
@@ -126,11 +126,12 @@
    500 -> $5
    489 -> $4.89"
   [cents]
-  (let [pennies (mod cents 100)
-        dollars (/ (- cents pennies) 100)]
+  (let [abs-cents (Math/abs cents)
+        pennies (mod abs-cents 100)
+        dollars (/ (- abs-cents pennies) 100)]
     (if (pos? pennies)
-      (gstring/format "$%d.%02d" dollars pennies)
-      (gstring/format "$%d" (utils/inspect dollars)))))
+      (gstring/format "$%s%d.%02d" (if (neg? cents) "-" "") dollars pennies)
+      (gstring/format "$%s%d" (if (neg? cents) "-" "") dollars))))

 (defn invoice-component [{:keys [invoice-id]} owner]
   (reify


Boostrap ocamlbuild (#5338).

Boostrap ocamlbuild (#5338).

git-svn-id: e7e61699ce1738538ffebb75374fbea0924bc775@11308 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02


Minor cleanup on (interposep)

Minor cleanup on (interposep)

--- src/shared/hyjinks/core.cljc
+++ src/shared/hyjinks/core.cljc
@@ -16,11 +16,10 @@

 (defn- interposep [sep pred coll]
   (cond
-    (empty? coll) (empty coll)
-    (= 1 (count coll)) coll
-    :else (if (pred (first coll) (second coll))
-      (concat [(first coll) sep] (interposep sep pred (rest coll)))
-      (concat [(first coll)] (interposep sep pred (rest coll))))))
+    (empty? coll)                     (empty coll)
+    (= 1 (count coll))                coll
+    (pred (first coll) (second coll)) (concat [(first coll) sep] (interposep sep pred (rest coll)))
+    :else                             (concat [(first coll)] (interposep sep pred (rest coll)))))

 (defn- str-join-extra-spaces [& items]
   (->> items


Hide all except the spinner that shows the loading of namespaces.

--- src/app/cljs/one/sample/animation.cljs
+++ src/app/cljs/one/sample/animation.cljs
@@ -48,8 +48,8 @@
     (set-html! content-fnx ns-nav)
     (append! content-fnx fn-display)
     (append! content-fnx spinner)
-    (set-styles! (by-id "ns-nav") {:display "block"})
-    (set-styles! (by-id "fn-display") {:display "block"})
+    (set-styles! (by-id "ns-nav") {:display "none"})
+    (set-styles! (by-id "fn-display") {:display "none"})
     (set-styles! (by-id "spinner") {:display "block"})))

 ;; ------------- fnx -------------


Add test case for using automorphisms during exploration

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

--- src/conexp/tests/fca/exploration.clj
+++ src/conexp/tests/fca/exploration.clj
@@ -10,7 +10,8 @@
   (:use conexp.base
         conexp.fca.contexts
         conexp.fca.implications
-        conexp.fca.exploration)
+        conexp.fca.exploration
+        conexp.fca.exploration.util)
   (:use clojure.test))

 ;;;
@@ -62,6 +63,23 @@
                                               :background-knowledge (set (canonical-base ctx))
                                               :handler #(is false))))))

+(deftest test-explore-attributes-with-automorphisms
+  (let [result (explore-attributes
+                :context (make-context [] [1 2 3] [])
+                :handler (fn [ctx known impl]
+                           (when-not (or (respects? #{1} impl)
+                                         (respects? #{2} impl))
+                             (examples-by-automorphisms ctx
+                                                        [(gensym) #{1}]
+                                                        #{(fn [x]
+                                                            (case x
+                                                              1 2
+                                                              2 1
+                                                              3 3))}))))]
+    (is (= (:implications result)
+           #{(impl 3 ==> 1 2) (impl 1 2 ==> 3)}))
+    (is (= 2 (count (objects (:context result)))))))
+
 ;;;

 nil


make emitDirect work for spouts

make emitDirect work for spouts

--- src/clj/backtype/storm/daemon/task.clj
+++ src/clj/backtype/storm/daemon/task.clj
@@ -312,7 +312,7 @@
                      )))
         send-spout-msg (fn [out-stream-id values message-id out-task-id]
                          (let [out-tasks (if out-task-id
-                                           (tasks-fn out-stream-id values out-task-id)
+                                           (tasks-fn out-task-id out-stream-id values)
                                            (tasks-fn out-stream-id values))
                                root-id (MessageId/generateId)
                                rooted? (and message-id (> (storm-conf TOPOLOGY-ACKERS) 0))


A typo in aleph component fixed

A typo in aleph component fixed

--- src/clj/hellhound/components/aleph.clj
+++ src/clj/hellhound/components/aleph.clj
@@ -29,7 +29,7 @@
 (defn aleph-stop!
   "Stops the running aleph server"
   [this]
-  (log/info "stopping system")
+  (log/info "stopping aleph component")
   (if (:instance this)
     (do
       (.close (:instance this))
@@ -46,4 +46,4 @@
    (spec/validate ::aleph-config config "Aleph configuration is invalid.")
    {:hellhound.component/name ::aleph
     :hellhound.component/start-fn (aleph-start! routes config)
-    :hellhound.component/stop-nf aleph-stop!}))
+    :hellhound.component/stop-fn aleph-stop!}))


rearrange accounts page/transsaction form

--- src/cljs/clj_money/views/accounts.cljs
+++ src/cljs/clj_money/views/accounts.cljs
@@ -266,15 +266,18 @@
   (with-retry
     (.focus (.getElementById js/document "transaction-date"))))

-(defn- account-header
-  [{:keys [account transaction] :as context}]
-  [:section
-   [:div.pull-right
-    [:button.btn.btn-primary {:type :button
-                              :data-toggle :dropdown
-                              :aria-haspopup true
-                              :aria-expanded false
-                              :disabled (not (nil? @transaction))}
+(defn- account-buttons
+  [{:keys [transaction] :as context}]
+  [:div
+   [:div.btn-group.dropup
+    [:button {:type :button
+              :class ["btn"
+                      "btn-primary"
+                      "dropdown-toggle"]
+              :data-toggle :dropdown
+              :aria-haspopup true
+              :aria-expanded false
+              :disabled (not (nil? @transaction))}
      [:span.glyphicon.glyphicon-plus]
      (util/space)
      "New"
@@ -287,14 +290,13 @@
        "Simple Entry"]
       [:a {:href "#"
            :on-click #(new-transaction context :full)}
-       "Full Entry"]]]
-    (util/space)
-    (util/link-to "Back"
-                  "/accounts"
-                  {:icon :hand-left
-                   :class "btn btn-info"
-                   :title "Click here to return to the account list."})]
-   [:h1 (:name @account)]])
+       "Full Entry"]]]]
+   (util/space)
+   (util/link-to "Back"
+                 "/accounts"
+                 {:icon :hand-left
+                  :class "btn btn-info"
+                  :title "Click here to return to the account list."})])

 (defn- item-row
   [item]
@@ -501,11 +503,15 @@
                     :icon :remove
                     :title "Click here to cancel this transaction"})]]))

+(defn- account-header
+  [{:keys [account]}]
+  [:h1 (:name @account)])
+
 (defn- show-account
   [id]
-  (let [context {:account (r/atom nil)
-                 :transaction (r/atom nil)
-                 :items (r/atom nil)}]
+  (let [{:keys [account] :as context} {:account (r/atom nil)
+                                       :transaction (r/atom nil)
+                                       :items (r/atom nil)}]
     (load-accounts)
     (accounts/get-one id
                       (fn [a]
@@ -519,13 +525,14 @@
          [account-header context]]]
        [:div.row
         [:div.col-md-6
-         [transaction-form context]]
-        [:div.col-md-6
          [:div.panel.panel-default
           [:div.panel-heading
            [:h2.panel-title "Transaction Items"]]
           [:div.panel-body {:style {:height "40em" :overflow "auto"}}
-           [items-table context]]]]]])))
+           [items-table context]]]
+         [account-buttons context]]
+        [:div.col-md-6
+         [transaction-form context]]]])))

 (secretary/defroute new-account-path "/accounts/new" []
   (r/render [new-account] (app-element)))


Add a custom-binder function for creating binders

--- src/cljs/hacker_agent/hacker-base.cljs
+++ src/cljs/hacker_agent/hacker-base.cljs
@@ -173,6 +173,21 @@
 (defn r-cache! [data path id]
   ((r-cache-fn data path) id))

+(defn custom-binder [& {:keys [add-fn change-fn remove-fn value-fn]
+                        :or [add-fn identity
+                             change-fn identity
+                             remove-fn identity
+                             value-fn identity]}]
+  (fn [data path msg]
+    (let [[event key val] msg
+          child-path (conj path key)]
+      (case event
+        :child_added (add-fn data path msg)
+        :child_changed (change-fn data path msg)
+        :child_removed (remove-fn data path msg)
+        :value (value-fn data path msg)
+        (.log js/console (clj->js [event key val]))))))
+
 (defn item-binder [& {:keys [levels]}]
   (fn [data path msg]
     (let [[event key val] msg


rearrange results screen

rearrange results screen

--- src/cljs/ikea_clojure_cup/pack_it.cljs
+++ src/cljs/ikea_clojure_cup/pack_it.cljs
@@ -39,6 +39,18 @@
                                " "
                                [:span.text-muted (:desc product)]] )
                             (:missing result-state))]]])
+         [:h3 "Trolley contents:"]
+
+         [select-items/trolley-list-contents (reagent/cursor all-state [:trolley])]
+
+         [bootstrap/button-toolbar
+          [bootstrap/button {:bs-size :lg
+                             :bs-style :primary
+                             :on-click recalc-progress-fn} "Recalculate"]
+          [bootstrap/button {:title "Start over" :bs-style :danger
+                             :bs-size :lg
+                             :href "/"
+                             :on-click start-over-fn} "Start over"]]
          [:h3 "Flatpacks:"]
          [:ul.list-inside.list-plain
           (let [package-ids-missing (->> result-state :packages-missing (map :pkg-id) set)
@@ -52,20 +64,7 @@
              (mapcat :packages (-> @all-state :trolley :items))))]

          [:h3 "Boot size:"]
-         [:p (str (cs/join "cm x " (-> @all-state :fleet :vehicles first vals)) "cm")]
-
-         [:h3 "Trolley contents:"]
-
-         [select-items/trolley-list-contents (reagent/cursor all-state [:trolley])]
-
-         [bootstrap/button-toolbar
-          [bootstrap/button {:bs-size :lg
-                             :bs-style :primary
-                             :on-click recalc-progress-fn} "Recalculate"]
-          [bootstrap/button {:title "Start over" :bs-style :danger
-                             :bs-size :lg
-                             :href "/"
-                             :on-click start-over-fn} "Start over"]]]
+         [:p (str (cs/join "cm x " (-> @all-state :fleet :vehicles first vals)) "cm")]]

         (when-not (= :no (:result result-state))
           [:div.preview


Fixed bootstrapping thanks to all my great friends!

--- src/cljs/wombats_web_client/views.cljs
+++ src/cljs/wombats_web_client/views.cljs
@@ -55,13 +55,13 @@
             modal @modal
             panel @active-panel]

-        [:div.app-container
+

          ;; If you're bootstrapping show loading
          (if bootstrapping?
            [:div "Loading..."]

-           (do
-             [display-modal modal]
-             [display-navbar panel]
-             [show-panel panel]))]))))
+           [:div.app-container
+            [display-modal modal]
+            [display-navbar panel]
+            [show-panel panel]])))))


priprava na zaverecne lepeni vsech akci dohromady. edeposit/edeposit#635

--- src/edeposit/amqp/kramerius/core.clj
+++ src/edeposit/amqp/kramerius/core.clj
@@ -5,21 +5,20 @@
    [edeposit.amqp.kramerius.systems :refer [prod-system]]
    [reloaded.repl :refer [system init start stop go reset]]
    [edeposit.amqp.kramerius.handlers :as h]
-   [reagi.core :as r]
    )
   (:gen-class :main true)
 )

-(defn obs->obs
+(defn inputs->outputs
   "Takes input observables and transform them into output observables.
   This is main logic of kramerius.

-  It returns 3 Observables
+  It returns 3 channes
   - requests to convert marcxml2mods
   - requests to export result to ssh
   - response messages to send back a results

-  3 input Obs:
+  3 input channels:
   - requests to export
   - marcxml-to-mods responses
   - ssh export responses
@@ -32,21 +31,23 @@
   ## SSH export response
   "
   [request-obs marcxml-to-mods-response-obs ssh-response-obs]
-  (let  [ workdir-obs (->> request-obs
+  (comment
+    (let  [ workdir-obs (->> request-obs
                            (r/map h/request-with-tmpdir)
                            (r/map h/save-request))
          requests-to-marcxml2mods-obs (->> workdir-obs
                                            (r/map h/prepare-marcxml2mods-request))
          mods-files-obs (->> marcxml-to-mods-response-obs
-                                  (r/map h/save-marcxml2mods-response)
-                                  (r/map h/parse-mods-files)
-                                  )
+                             (r/map h/save-marcxml2mods-response)
+                             (r/map h/parse-mods-files)
+                             )
          requests-to-ssh-obs (->> mods-files-obs
                                   (r/map h/mods->oai_dcs)
                                   (r/map h/make-package-with-foxml mods-files-obs) ;; zip two observables mods, oai_dcs
                                   )]
-    { :requests-to-marcxml2mods-obs requests-to-marcxml2mods-obs
-     :requests-to-ssh requests-to-ssh-obs})
+      { :requests-to-marcxml2mods-obs requests-to-marcxml2mods-obs
+       :requests-to-ssh requests-to-ssh-obs})
+    )
   )

 (defn -main [& args]


Use condp instead of cond

Use condp instead of cond

--- src/testdouble/cljs/csv.cljs
+++ src/testdouble/cljs/csv.cljs
@@ -66,8 +66,8 @@
                     str-char (str char)]
                 (case state
                   :in-field
-                  (cond
-                    (= str-char "\"")
+                  (condp = str-char
+                    "\""
                     (if in-quoted-field
                       (if (= (str next-char) "\"")
                         (recur (+ index 2)
@@ -84,7 +84,7 @@
                                rows
                                (conj rows []))))

-                    (= str-char separator)
+                    separator
                     (if in-quoted-field
                       (recur (+ index 1)
                              :in-field
@@ -97,7 +97,7 @@
                              ""
                              (conj-in rows last-row-index field-buffer)))

-                    (= str-char "\r")
+                    "\r"
                     (if (and (= newline :cr+lf) (not in-quoted-field))
                       (recur (+ index 1)
                              :in-field
@@ -110,7 +110,7 @@
                              (str field-buffer char)
                              rows))

-                    (= str-char "\n")
+                    "\n"
                     (if in-quoted-field
                       (recur (+ index 1)
                              :in-field
@@ -123,7 +123,6 @@
                              ""
                              (conj-in rows last-row-index field-buffer)))

-                    :else
                     (recur (+ index 1)
                            :in-field
                            in-quoted-field
@@ -133,14 +132,14 @@
                              (conj rows []))))

                   :end-field
-                  (cond
-                    (= str-char "\"")
+                  (condp = str-char
+                    "\""
                     (recur (+ index 1) :in-field true field-buffer rows)

-                    (= str-char separator)
+                    separator
                     (recur (inc index) :end-field in-quoted-field "" (conj-in rows last-row-index ""))

-                    :else (recur (+ index 1) :in-field in-quoted-field str-char rows))
+                    (recur (+ index 1) :in-field in-quoted-field str-char rows))

                   :end-line
                   (case str-char


Directives will now come through properly

--- src/hphelper/server/live/control.clj
+++ src/hphelper/server/live/control.clj
@@ -14,14 +14,14 @@
 )

 ;; Current games, keyed by uuid
-(def ^:private current-games
+(defonce ^:private current-games
   (atom {}
-        :validator (fn [m] (s/assert (s/map-of string? ::ss/liveScenario) m))
+        :validator (fn [m] (ss/valid? (s/map-of string? ::ss/liveScenario) m))
         )
   )

 ;; Current indicies, keyed by zone string
-(def ^:private current-indicies
+(defonce ^:private current-indicies
   (atom (try (-> "indicies.edn" slurp clojure.edn/read-string)
              (catch Exception e
                (log/trace "Could not read indicies.edn")
@@ -392,6 +392,7 @@
   (-> g
       (assoc-in [:serviceGroups sgIndex :owner] newOwner)
       (assoc-in [:updated :serviceGroups] (current-time))
+      (assoc-in [:updated :directives] (current-time))
       )
   )
 (defn set-sg-owner


Return a single error instead of a list on password change endpoint.

--- src/uxbox/services/users.clj
+++ src/uxbox/services/users.clj
@@ -98,7 +98,7 @@
   [conn {:keys [user old-password] :as params}]
   (let [user (find-full-user-by-id conn user)]
     (when-not (hashers/check old-password (:password user))
-      (let [params {:old-password '("errors.api.form.old-password-not-match")}]
+      (let [params {:old-password "errors.api.form.old-password-not-match"}]
         (throw (ex/ex-info :form/validation params))))
     params))


Add --root-dir

Add --root-dir

--- src/whisper2cyanite/core.clj
+++ src/whisper2cyanite/core.clj
@@ -124,9 +124,9 @@
   (wlog/set-logging! options)
   (try
     (wlog/info "Starting migration")
-    (let [files (get-paths dir)
+    (let [root-dir (get-root-dir dir options)
+          files (get-paths dir)
           files-count (count files)
-          root-dir (get-root-dir dir options)
           from (if from from 0)
           to (if to to utils/epoch-future)
           jobs (:jobs options default-jobs)


Make scrollposition behavior less annoying on format

--- src/lt/plugins/elm_light/format.cljs
+++ src/lt/plugins/elm_light/format.cljs
@@ -65,7 +65,8 @@
                           (if ok?
                             (pool/reload ed)
                             (handle-format-error res))
-                          (editor/move-cursor ed pos)))))
+                          (editor/move-cursor ed pos)
+                          (editor/center-cursor ed)))))

 (defn- strip-module [expr]
   (->> (s/split-lines expr)
@@ -94,9 +95,10 @@
                             [ok? res] (format-input (-> @ed :info :path u/project-path)
                                                     (editor/->val ed))]
                         (if ok?
-                          (editor/set-val ed res)
-                          (handle-format-error res))
-                        (editor/move-cursor ed pos))))
+                          (do
+                            (editor/set-val-and-keep-cursor ed res)
+                            (editor/center-cursor ed))
+                          (handle-format-error res)))))


fourth attempt

fourth attempt

--- src/mafia_votecount/views/player.clj
+++ src/mafia_votecount/views/player.clj
@@ -2,5 +2,5 @@
   (:require [mafia-votecount.models :as models]
             [liberator.core :refer [defresource resource request-method-in]]))

-(defn- delete-player [id]
+(defn delete-player [id]
   (models/delete-player-by-id id))


Revert "Handle end-of-file in object and array readers"

This was meant for a branch.

This reverts commit 2567660682c126adc47da7e1fd17e37201f2d83e.

--- src/main/clojure/clojure/data/json.clj
+++ src/main/clojure/clojure/data/json.clj
@@ -278,7 +278,6 @@
     (codepoint-case c
       \] []
       \, (throw (invalid-array-exception))
-      -1 (throw (Exception. "JSON error (end-of-file inside array)"))
       (do (.unread stream c)
           (read-array* stream options)))))

@@ -289,9 +288,8 @@
         (if (= (codepoint \:) (int (next-token stream)))
           key
           (throw (Exception. "JSON error (missing `:` in object)"))))
-      (codepoint-case c
-        \} nil
-        -1 (throw (Exception. "JSON error (end-of-file inside object)"))
+      (if (= c (codepoint \}))
+        nil
         (throw (Exception. (str "JSON error (non-string key in object), found `" (char c) "`, expected `\"`")))))))

 (defn- read-object [^PushbackReader stream options]
@@ -312,7 +310,6 @@
           (codepoint-case (int (next-token stream))
             \, (recur r)
             \} (persistent! r)
-            -1 (throw (Exception. "JSON error (end-of-file inside object)"))
             (throw (Exception. "JSON error (missing entry in object)"))))
         (let [r (persistent! result)]
           (if (empty? r)
@@ -809,4 +806,4 @@
     :escape-unicode false
         to turn off \\uXXXX escapes of Unicode characters."
   [x & options]
-  (apply pprint x options))
+  (apply pprint x options))


Cleaned up arena.cljs

Cleaned up arena.cljs

--- src/cljs/wombats_web_client/components/arena.cljs
+++ src/cljs/wombats_web_client/components/arena.cljs
@@ -4,67 +4,61 @@

 (defonce spritesheet-png "/images/spritesheet.png")

-(defn- draw-image
-  [canvas-element img-name x y width height]
+(defn subscribe-to-spritesheet
+  [img-name callback]
   (let [spritesheet (re-frame/subscribe [:spritesheet])
         sprite-info (get @spritesheet (keyword img-name))
         frame (:frame sprite-info)]
-    (when-not (nil? frame)
+    (when frame
       (let [img (js/Image.)]
         (set! (.-src img) spritesheet-png)
-        (.requestAnimationFrame js/window
-                                (fn []
-                                  (canvas/draw-image canvas-element
-                                                     img
-                                                     (:x frame)
-                                                     (:y frame)
-                                                     (:w frame)
-                                                     (:h frame)
-                                                     x
-                                                     y
-                                                     width
-                                                     height)))))))
+        (.requestAnimationFrame js/window
+                                (fn []
+                                  (callback img frame)))))))
+
+(defn- draw-image
+  [canvas-element img-name x y width height]
+  (subscribe-to-spritesheet img-name
+                            (fn [img frame]
+                              (canvas/draw-image canvas-element
+                                                 img
+                                                 (:x frame)
+                                                 (:y frame)
+                                                 (:w frame)
+                                                 (:h frame)
+                                                 x
+                                                 y
+                                                 width
+                                                 height))))

 (defn- draw-image-rotated
   [canvas-element img-name x y width height rotation]
-  (let [spritesheet (re-frame/subscribe [:spritesheet])
-        sprite-info (get @spritesheet (keyword img-name))
-        frame (:frame sprite-info)]
-    (when-not (nil? frame)
-      (let [img (js/Image.)]
-        (set! (.-src img) spritesheet-png)
-        (.requestAnimationFrame js/window
-                                (fn []
-                                  (canvas/draw-image-rotated canvas-element
-                                                             img
-                                                             (:x frame)
-                                                             (:y frame)
-                                                             (:w frame)
-                                                             (:h frame)
-                                                             x y
-                                                             width
-                                                             height
-                                                             rotation)))))))
+  (subscribe-to-spritesheet img-name
+                            (fn [img frame]
+                              (canvas/draw-image-rotated canvas-element
+                                                         img
+                                                         (:x frame)
+                                                         (:y frame)
+                                                         (:w frame)
+                                                         (:h frame)
+                                                         x y
+                                                         width
+                                                         height
+                                                         rotation))))

 (defn- draw-image-flipped-horizontally
   [canvas-element img-name x y width height]
-  (let [spritesheet (re-frame/subscribe [:spritesheet])
-        sprite-info (get @spritesheet (keyword img-name))
-        frame (:frame sprite-info)]
-    (when-not (nil? frame)
-      (let [img (js/Image.)]
-        (set! (.-src img) spritesheet-png)
-        (.requestAnimationFrame js/window
-                                (fn []
-                                  (canvas/draw-image-flipped-horizontally canvas-element
-                                                                          img
-                                                                          (:x frame)
-                                                                          (:y frame)
-                                                                          (:w frame)
-                                                                          (:h frame)
-                                                                          x y
-                                                                          width
-                                                                          height)))))))
+  (subscribe-to-spritesheet img-name
+                            (fn [img frame]
+                              (canvas/draw-image-flipped-horizontally canvas-element
+                                                                      img
+                                                                      (:x frame)
+                                                                      (:y frame)
+                                                                      (:w frame)
+                                                                      (:h frame)
+                                                                      x y
+                                                                      width
+                                                                      height))))

 (defn- draw-background
   "This draws the background of a cell (only called for cells that need it)"


Fix formatting in security-group2

Fix formatting in security-group2

--- src/com/palletops/jclouds/ec2/security_group2.clj
+++ src/com/palletops/jclouds/ec2/security_group2.clj
@@ -26,8 +26,7 @@
    org.jclouds.ec2.features.SecurityGroupApi
    org.jclouds.net.domain.IpProtocol))

-(defn ^SecurityGroupApi
-  sg-service
+(defn ^SecurityGroupApi sg-service
   "Returns the SecurityGroup Api associated with the specified compute
   service."
   [compute]
@@ -36,9 +35,12 @@
 (defn create-group
   "Creates a new security group.

-  e.g. (create-group compute \"Database Server\" \"Description for group\" :region :us-west-1)"
+  e.g. (create-group
+         compute \"Database Server\" \"Description for group\"
+         :region :us-west-1)"
   [compute name & {:keys [description region]}]
-  (.createSecurityGroupInRegion (sg-service compute) (get-region region) name (or description name)))
+  (.createSecurityGroupInRegion
+   (sg-service compute) (get-region region) name (or description name)))

 (defn delete-group
   "Deletes a security group.
@@ -52,10 +54,12 @@

    e.g. (groups compute :region :us-east-1)"
   [compute & {:keys [region]}]
-  (into {} (for [^SecurityGroup group (.describeSecurityGroupsInRegion (sg-service compute)
-                                                                       (get-region region)
-                                                                       (into-array String '()))]
-             [(.getName group) group])))
+  (into {}
+        (for [^SecurityGroup group (.describeSecurityGroupsInRegion
+                                    (sg-service compute)
+                                    (get-region region)
+                                    (into-array String '()))]
+          [(.getName group) group])))

 (defn get-protocol [v]
   "Coerce argument to a IP Protocol."
@@ -66,36 +70,45 @@
                                  :icmp IpProtocol/ICMP}
                                 v)]
                   p
-                  (throw (IllegalArgumentException.
-                          (str "Can't obtain IP protocol from " v " (valid :tcp, :udp and :icmp)"))))
+                  (throw
+                   (IllegalArgumentException.
+                    (str "Can't obtain IP protocol from " v
+                         " (valid :tcp, :udp and :icmp)"))))
    (nil? v) IpProtocol/TCP
    :else (throw (IllegalArgumentException.
-                 (str "Can't obtain IP protocol from argument of type " (type v))))))
+                 (str "Can't obtain IP protocol from argument of type "
+                      (type v))))))

 (defn authorize
   "Adds permissions to a security group.

-   e.g. (authorize compute \"jclouds#webserver#us-east-1\" 80 :ip-range \"0.0.0.0/0\")
-        (authorize compute \"jclouds#webserver#us-east-1\" [1000,2000] :protocol :udp)"
+   e.g. (authorize
+         compute \"jclouds#webserver#us-east-1\" 80 :ip-range \"0.0.0.0/0\")
+        (authorize
+         compute \"jclouds#webserver#us-east-1\" [1000,2000] :protocol :udp)"

   [compute group-name port & {:keys [protocol ip-range region]}]
   (let [group ((groups compute :region region) group-name)
         [from-port to-port] (if (number? port) [port port] port)]
     (if group
       (.authorizeSecurityGroupIngressInRegion
-       (sg-service compute) (get-region region) (.getName group) (get-protocol protocol) from-port to-port (or ip-range "0.0.0.0/0"))
+       (sg-service compute) (get-region region) (.getName group)
+       (get-protocol protocol) from-port to-port (or ip-range "0.0.0.0/0"))
       (throw (IllegalArgumentException.
               (str "Can't find security group for name " group-name))))))

 (defn revoke
   "Revokes permissions from a security group.

-   e.g. (revoke compute 80 \"jclouds#webserver#us-east-1\" :protocol :tcp 80 80 :ip-range \"0.0.0.0/0\")"
+   e.g. (revoke
+         compute 80 \"jclouds#webserver#us-east-1\" :protocol :tcp 80 80
+         :ip-range \"0.0.0.0/0\")"
   [compute group-name port & {:keys [protocol ip-range region]}]
   (let [group ((groups compute :region region) group-name)
         [from-port to-port] (if (number? port) [port port] port)]
     (if group
-     (.revokeSecurityGroupIngressInRegion
-      (sg-service compute) (get-region region) (.getName group) (get-protocol protocol) from-port to-port (or ip-range "0.0.0.0/0"))
-     (throw (IllegalArgumentException.
-             (str "Can't find security group for name " group-name))))))
+      (.revokeSecurityGroupIngressInRegion
+       (sg-service compute) (get-region region) (.getName group)
+       (get-protocol protocol) from-port to-port (or ip-range "0.0.0.0/0"))
+      (throw (IllegalArgumentException.
+              (str "Can't find security group for name " group-name))))))


Bound timeline y move with bigger then 0

--- src/teach_by_friends/shared/components/timeline_and_table.cljs
+++ src/teach_by_friends/shared/components/timeline_and_table.cljs
@@ -26,7 +26,8 @@

 (defn update-timeline-position-with-label
   [tPosition table-margin-top fullHeight visibleHeight label show-label? label-top label-height timeline-list event]
-  (let [timeline-y (.. event -nativeEvent -locationY)
+  (let [timeline-y-real (.. event -nativeEvent -locationY)
+        timeline-y (if (> timeline-y-real 0) timeline-y-real 0)
         y-ratio (/ timeline-y @visibleHeight)
         words-list-y-temp (* @fullHeight y-ratio)
         words-list-y (if (> words-list-y-temp (- @fullHeight @visibleHeight))


Fix io/write-raw usage

Fix io/write-raw usage

--- src/clojure_pf.clj
+++ src/clojure_pf.clj
@@ -55,10 +55,11 @@
   "Writes one destructured packet payload through a socket/device.
   Returns the number of bytes written on success."
   [context packet]
-  (let [entries           (:entries context)
+  (let [handle            (:handle context)
+        entries           (:entries context)
         raw-output-packet (binary/serialize packet entries)
         write-buffer-size (get-in context [:options :write-buffer-size])]
-    (io/write-raw raw-output-packet)))
+    (io/write-raw handle raw-output-packet write-buffer-size)))

 (defn close
   "Closes a packet socket/device context."


Small formatting/consistency fix

Small formatting/consistency fix

--- Clojure/seven_lang/src/seven_lang/daythree.clj
+++ Clojure/seven_lang/src/seven_lang/daythree.clj
@@ -6,7 +6,8 @@

 (defn credit-account
   [account amount]
-  (dosync (alter account + amount))
+    (dosync
+      (alter (get accounts account) + amount))
   )

 (defn debit-account


fixed domain

fixed domain

--- main/src/dda/pallet/dda_managed_ide/domain.clj
+++ main/src/dda/pallet/dda_managed_ide/domain.clj
@@ -97,13 +97,14 @@
       {:ide-user (keyword (:name user))}
       (cond
         (= dev-platform :clojure-atom)
-        {:clojure (merge
-                   {:os-user-name user-name
-                    :atom (atom/atom-config vm-type)}
+        {:atom (atom/atom-config vm-type)
+         :clojure (merge
+                   {:os-user-name user-name}
                    (when (contains? domain-config :lein-auth)
                      {:lein-auth lein-auth}))}
         (= dev-platform :clojure-nightlight)
-        {:clojure (merge
+        {:os-user-name user-name
+         :clojure (merge
                     {:os-user-name user-name
                      :settings #{:install-nightlight}}
                     (when (contains? domain-config :lein-auth)


fixed resolved schema for domain fuctions

--- main/src/dda/pallet/dda_managed_ide/domain.clj
+++ main/src/dda/pallet/dda_managed_ide/domain.clj
@@ -54,28 +54,30 @@
  [ide-config :- DdaIdeDomainConfig]
  (git/ide-git-config ide-config))

-(s/defn ^:always-validate ide-serverspec-config
- [ide-config :- DdaIdeDomainConfig]
- (let [{:keys [user dev-platform vm-platform]} ide-config
-       profile-map (assoc {} :path (str "/home/" (:name user) "/.lein/profiles.clj"))
-       profile-list (conj '() profile-map)
-       file-config (concat '({:path "/opt/leiningen/lein"}
-                             {:path "/etc/profile.d/lein.sh"})
-                    profile-list)
-       platform-dep-config (if (and (= vm-platform :aws) (= dev-platform :clojure-atom))
-                             (concat file-config '({:path "/usr/share/atom/libxcb.so.1"}))
-                             file-config)]
-   (merge
-    {:file platform-dep-config}
-    (cond
-      (= dev-platform :clojure-atom) {:package '({:name "atom"}
-                                                 {:name "python"}
-                                                 {:name "gvfs-bin"})}
+(s/defn ^:always-validate
+  ide-serverspec-config
+  [ide-config :- DdaIdeDomainResolvedConfig]
+  (let [{:keys [user dev-platform vm-platform]} ide-config
+        profile-map (assoc {} :path (str "/home/" (:name user) "/.lein/profiles.clj"))
+        profile-list (conj '() profile-map)
+        file-config (concat '({:path "/opt/leiningen/lein"}
+                              {:path "/etc/profile.d/lein.sh"})
+                     profile-list)
+        platform-dep-config (if (and (= vm-platform :aws) (= dev-platform :clojure-atom))
+                              (concat file-config '({:path "/usr/share/atom/libxcb.so.1"}))
+                              file-config)]
+    (merge
+     {:file platform-dep-config}
+     (cond
+       (= dev-platform :clojure-atom) {:package '({:name "atom"}
+                                                  {:name "python"}
+                                                  {:name "gvfs-bin"})}

-      :default {}))))
+       :default {}))))

-(s/defn ^:always-validate dda-vm-domain-configuration
-  [ide-config :- DdaIdeDomainConfig]
+(s/defn ^:always-validate
+  dda-vm-domain-configuration
+  [ide-config :- DdaIdeDomainResolvedConfig]
   (let [{:keys [user bookmarks vm-type]} ide-config]
     (merge
       {:user user}
@@ -85,8 +87,9 @@
                (= vm-type :remote) :remote
                (= vm-type :desktop) :desktop-office)})))

-(s/defn ^:always-validate infra-configuration :- InfraResult
-  [domain-config :- DdaIdeDomainConfig]
+(s/defn ^:always-validate
+  infra-configuration :- InfraResult
+  [domain-config :- DdaIdeDomainResolvedConfig]
   (let [{:keys [user vm-type dev-platform]} domain-config
         user-name (:name user)]
     {infra/facility


Disregard PR games

Disregard PR games

--- src/nhl_score_api/fetchers/mlbam/latest_games.clj
+++ src/nhl_score_api/fetchers/mlbam/latest_games.clj
@@ -18,6 +18,13 @@
 (defn- has-started-games? [date-and-games]
   (let [games (:games date-and-games)]
     (some started-game? games)))
+
+(defn- pr-game? [game]
+  (= "PR" (:game-type game)))
+
+(defn- remove-pr-games [date-and-games]
+  (let [accepted-games (remove pr-game? (:games date-and-games))]
+    (assoc date-and-games :games accepted-games)))

 (defn- get-latest-date-and-games-with-finished-games [dates-and-games]
   (last
@@ -43,6 +50,7 @@
   (->> (json/read-str api-response :key-fn ->kebab-case-keyword)
        :dates
        (map #(select-keys % [:date :games]))
+       (map remove-pr-games)
        get-latest-date-and-games-with-finished-games
        format-date
        sort-games-by-state))


macro fun

macro fun

--- 6clojure/day2.clj
+++ 6clojure/day2.clj
@@ -1,2 +1,33 @@
-(defmacro unless [test body]
-  (if (not test) body))
+(defmacro unless [condmine body]
+  (list 'if (list not condmine) body))
+
+(defmacro unless2 [condmine body]
+  (if (not (eval condmine)) body))
+
+(defmacro unless3 [condmine body]
+  (list 'if (not condmine) body))
+
+(defmacro unless4 [condmine body]
+  '(if (not condmine) body))
+
+(unless2 true (println "bla2"))
+(unless2 false (println "bla3"))
+
+(comment
+(defn unlessfn [test body]
+  (if (not test) (body)))
+
+(unlessfn (> 1 2) (fn [] (println "blah")))
+(if (< 1 2) (println "bla"))
+
+(defn create-colors []
+  (println "Creating colors")
+  ["red", "green", "blue"])
+(defn small-word? [x]
+  (println "Is small word? " x)
+  (< (count x) 4))
+
+(println (for [x (create-colors), :when (small-word? x)]
+  (do (println "In a for body")
+  (str "I like " x))))
+  )


altcrawl.clj: first complete working version

--- src/org/altlaw/jobs/pre/altcrawl.clj
+++ src/org/altlaw/jobs/pre/altcrawl.clj
@@ -5,12 +5,16 @@
             [org.altlaw.util.jruby :as ruby]
             [org.altlaw.util.context :as context]
             [org.altlaw.util.log :as log]
+            [org.altlaw.util.merge-fields :as merge]
             [org.altlaw.db.docids :as ids]
+            [org.altlaw.extract.pdf :as pdf]
             [clojure.contrib.walk :as walk]
-            [clojure.contrib.singleton :as sing])
+            [clojure.contrib.singleton :as sing]
+            [clojure.set :as set])
   (:use clojure.contrib.json.read
         org.altlaw.util.log)
-  (:import (org.apache.commons.codec.binary Base64)
+  (:import (org.altlaw.extract PROHTMLToText)
+           (org.apache.commons.codec.binary Base64)
            (javax.script ScriptContext ScriptEngine ScriptEngineManager)
            (java.io StringReader)))

@@ -39,7 +43,7 @@
 ;;  |                   |                 |
 ;; handle-html         handle-pdf        warn
 ;;  |       |           |      |
-;;  |      warn         |     request Docid
+;;  |      warn         |     warn
 ;;  |                   |
 ;; scraper-dispatch    convert-pdf
 ;;  |
@@ -54,20 +58,50 @@

 ;; Step 3 (for HTML): Run scrapers

+(defn get-primary-url [record]
+  (when-let [links (get record "links")]
+    (get links "application/pdf")))
+
+(defn get-all-urls [record]
+  (when-let [links (get record "links")]
+    (vals links)))
+
+(defn rubyhash-to-map [hash]
+  (reduce (fn [m [k v]]
+            (assoc m (keyword k)
+                   (if (instance? java.util.Map v)
+                     (into {} v)  ;; don't keywordize MIME types
+                     (str v))))
+          {} hash))
+
 (defn handle-scraper-record [record]
-  [101 (pr-str (into {} record))])
+  (let [data (into {} record)]
+    (if (contains? data "exception")
+      (do (h/counter "Scraper errors")
+          [:scraper-error (rubyhash-to-map data)])
+      (if-let [url (get-primary-url data)]
+        (if-let [docid (ids/get-docid "altcrawl" url)]
+          [docid (rubyhash-to-map data)]
+          [:docid-request (ids/make-docid-request "altcrawl" (get-all-urls data))])
+        (do (h/counter "No primary URL")
+            (log/warn "No primary URL among " (pr-str (get-all-urls data)))
+            nil)))))

 (defn run-scrapers [download]
-  (map handle-scraper-record
-       (ruby/eval-jruby "$handler.parse(Download.from_map($dmap))"
-                        {:dmap (walk/stringify-keys download)
-                         :handler (scraper-handler)})))
+  (filter identity
+          (map handle-scraper-record
+               (ruby/eval-jruby "$handler.parse(Download.from_map($dmap))"
+                                {:dmap (walk/stringify-keys download)
+                                 :handler (scraper-handler)}))))

 ;;; Step 4 (for PDFs): convert to HTML

 (defn convert-pdf [docid download]
-  (debug "converting PDF to HTML for " (:request_uri download)))
+  (debug "converting PDF to HTML for " (:request_uri download))
+  (let [html (pdf/pdf-to-html (str docid) (:response_body_bytes download))
+        text (PROHTMLToText/filter html)]
+    [[docid {:html html, :text text}]]))

 ;;; Step 3 (for PDFs): dispatch on presence of Docid

@@ -77,7 +111,8 @@
         (h/counter "PDF files" "with docid")
         (convert-pdf docid download))
     (do (warn "handle-pdf found no docid for " (:request_uri download))
-        (h/counter "PDF files" "no docid"))))
+        (h/counter "PDF files" "no docid")
+        nil)))

 ;;; Step 2: dispatch on MIME type of the download
@@ -117,6 +152,30 @@

+;;; REDUCER IMPLEMENTATION
+
+(defn merge-docs [docid documents]
+  (let [doc (merge/merge-fields documents)]
+    (if (and (:html doc) (:text doc))
+      [[docid doc]]
+      (do (h/counter "No html/text")
+          (log/warn "No html/text; skipping " docid)))))
+
+(defn assign-docids [requests]
+  (doseq [r requests]
+    (ids/handle-docid-request r))
+  (ids/save-docids "altcrawl")
+  (ids/save-next-docid)
+  nil)
+
+(defn my-reduce [key documents]
+  (cond
+    (= key :docid-request) (assign-docids documents)
+    (= key :exception) nil
+    (integer? key) (merge-docs key documents)))
+
+
+
 ;;; MAPPER METHODS

 (defn mapper-configure [this job]
@@ -128,9 +187,11 @@

 ;;; REDUCER METHODS

-(defn reducer-reduce [this wkey values-iter output reporter]
-  (debug "Called reduce with key " wkey " and "
-         (count (iterator-seq values-iter)) " values."))
+(defn reducer-configure [this job]
+  (context/use-hadoop-jobconf job))
+
+(def reducer-reduce (partial h/standard-reduce my-reduce))
+