Close websocket when core.async channel closes.

--- src/tranjlator/user.clj
+++ src/tranjlator/user.clj
@@ -19,12 +19,14 @@

     (go-loop []
       (let [msg (edn/read-string (<! user-read))]
-        (when-not (nil? msg)
-          (chat/send-msg chat-room msg user-write)
-          (recur))))
+        (if-not (nil? msg)
+          (do (chat/send-msg chat-room msg user-write)
+              (recur))
+          (ws/close websocket))))

     (go-loop []
       (let [msg (<! user-write)]
-        (when-not (nil? msg)
-          (ws/send! websocket (pr-str (dissoc msg :sender)))
-          (recur))))))
+        (if-not (nil? msg)
+          (do (ws/send! websocket (pr-str (dissoc msg :sender)))
+              (recur))
+          (ws/close websocket))))))


Move comment.

Move comment.

--- src/open_company/resources/company.clj
+++ src/open_company/resources/company.clj
@@ -234,11 +234,10 @@

 (defn get-companies-by-index
   "Given the name of a secondary index and a value, retrieve all matching companies"
+  ;; e.g.: (get-companies-by-index "org-id" "slack:T06SBMH60")
   [index-key v]
   {:pre [(string? index-key)]}
   (common/read-resources table-name index-key v))
-
-;; (get-companies-by-index "org-id" "slack:T06SBMH60")

 ;; ----- Armageddon -----


Pass custom resolver to all loaders in asset-manager

--- src/play_clj/core_utils.clj
+++ src/play_clj/core_utils.clj
@@ -188,21 +188,23 @@
   `(proxy [~(resolver-class type)] [] ~@options))

 (defn ^:private set-loaders!
-  [^AssetManager am]
-  (->> (loader :tmx-map (resolver :internal-file-handle))
-       (.setLoader am TiledMap))
-  (->> (loader :particle-effect
-               (resolver :internal-file-handle)
-               (load [am file-name fh param]
-                     (doto (ParticleEffect.)
-                       (.load fh (.parent fh)))))
-       (.setLoader am ParticleEffect)))
+  ([am]
+    (set-loaders! am (resolver :internal-file-handle)))
+  ([^AssetManager am res]
+    (->> (loader :tmx-map res)
+         (.setLoader am TiledMap))
+    (->> (loader :particle-effect
+                 res
+                 (load [am file-name fh param]
+                       (doto (ParticleEffect.)
+                         (.load fh (.parent fh)))))
+         (.setLoader am ParticleEffect))))

 (defn asset-manager*
   ([]
     (doto (AssetManager.) set-loaders!))
   ([resolver]
-    (doto (AssetManager. resolver) set-loaders!)))
+    (doto (AssetManager. resolver) (set-loaders! resolver))))

 (defmacro asset-manager
   "Returns an [AssetManager](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/AssetManager.html).


add type metadata to value returned by synthdef-read

--- src/overtone/sc/machinery/synthdef.clj
+++ src/overtone/sc/machinery/synthdef.clj
@@ -140,19 +140,21 @@
                 synth-name
                 ".scsyndef")))

-; TODO: byte array shouldn't really be the default here, but I don't
-; know how to test for one correctly... (byte-array? data) please?
+;; TODO: byte array shouldn't really be the default here, but I don't
+;; know how to test for one correctly... (byte-array? data) please?
 (defn synthdef-read
   "Reads synthdef data from either a file specified using a string path
   a URL, or a byte array."
   [data]
-  (first (:synths
-          (cond
-           (keyword? data) (spec-read-url synthdef-file-spec (java.net.URL. (str "file:" (supercollider-synthdef-path (to-str data)))) )
-           (string? data) (spec-read-url synthdef-file-spec (java.net.URL. (str "file:" (resolve-tilde-path data))))
-           (instance? java.net.URL data) (spec-read-url synthdef-file-spec data)
-           (byte-array? data) (spec-read-bytes synthdef-file-spec data)
-           :default (throw (IllegalArgumentException. (str "synthdef-read expects either a string, a URL, or a byte-array argument.")))))))
+  (with-meta
+    (first (:synths
+            (cond
+             (keyword? data) (spec-read-url synthdef-file-spec (java.net.URL. (str "file:" (supercollider-synthdef-path (to-str data)))) )
+             (string? data) (spec-read-url synthdef-file-spec (java.net.URL. (str "file:" (resolve-tilde-path data))))
+             (instance? java.net.URL data) (spec-read-url synthdef-file-spec data)
+             (byte-array? data) (spec-read-bytes synthdef-file-spec data)
+             :default (throw (IllegalArgumentException. (str "synthdef-read expects either a string, a URL, or a byte-array argument."))))))
+    {:type ::imported-synthdef}))

 (defn synthdef-write
   "Write a synth definition to a new file at the given path, which includes


Add production check to eched message during service startup.

--- src/oc/storage/app.clj
+++ src/oc/storage/app.clj
@@ -48,6 +48,7 @@

 (defn echo-config [port]
   (println (str "\n"
+    "Production? " c/prod? "\n"
     "Running on port: " port "\n"
     "Database: " c/db-name "\n"
     "Database pool: " c/db-pool-size "\n"


fix date format

fix date format

--- src/picsou/ui/http.clj
+++ src/picsou/ui/http.clj
@@ -43,11 +43,13 @@
         context {:reference-time {:start ref-time :grain :second}}
         {:keys [winners stash]} (pic/parse phrase context module
                                            [{:dim :time :label :time}
-                                            {:dim :duration :label :period}])]
+                                            {:dim :duration :label :period}])
+        trimmed (doall (map trim winners))]
     (prn ref-time)
-    (prn "Got" (trim (first winners)))
+    (prn "Got1" (map :dim winners))
+    (prn "Got" (count trimmed))

-    {:body (map trim winners)}))
+    {:body trimmed}))

 (defroutes routes
   (GET "/parse/:module/:reftime/:reftz/:phrase" [] parse-controller)


Using exception helpers.

Using exception helpers.

--- spec/freefrog/governance_circles_spec.clj
+++ spec/freefrog/governance_circles_spec.clj
@@ -303,15 +303,8 @@
         (g/unappoint-from-role sample-anchor-with-assignee tester-role
                                assignee-name)))

-    (it "won't appoint someone to a nonexistent role"
-      (should-throw IllegalArgumentException
-        "Role not found: Nonexistent"
-        (g/appoint-to-role sample-anchor-with-role "Nonexistent" "june")))
-
-    (it "won't appoint someone to a role with an empty name"
-      (should-throw IllegalArgumentException
-        "Role name may not be empty"
-        (g/appoint-to-role sample-anchor-with-role nil "june")))
+    (should-not-update-missing-or-empty-roles g/appoint-to-role
+      "role assignment" sample-anchor-with-role "june")

     (it "won't appoint nil to a role"
       (should-throw IllegalArgumentException


Simulate typical proppant concentration

Simulate typical proppant concentration

--- src/test_utils/sandbox.cljs
+++ src/test_utils/sandbox.cljs
@@ -370,3 +370,12 @@
               mean (/ (+ typical-min typical-max) 2)
               sigma (/ mean 3)]
           (tuc/draw-normal mean sigma))))
+
+(defn typical-proppant-concentration [units]
+   (cond (= units :ppga)
+         (let [typical-min 0.2
+               typical-max 10
+               mean (/ (+ typical-min typical-max) 2)
+               sigma (/ mean 3)]
+           (tuc/draw-normal mean sigma))))
+


extract function

extract function

--- src/zombie_run/quil.clj
+++ src/zombie_run/quil.clj
@@ -49,6 +49,12 @@
        (q/with-fill [204 102 0])
        (q/with-stroke [255 0 0])))

+(defn display-centered-text [game text]
+  (let [[center-x center-y] (z/world-center (:world-size game))]
+    (q/text text
+            (width* center-x)
+            (width* center-y))))
+
 (defn display-game [game]
   (-> (q/load-image "resources/gridpaperlightbluepattern.png")
       (q/background-image))                                 ; background image
@@ -62,15 +68,11 @@
                  (width* 5)
                  (width* 5)))
     (let [[center-x center-y] (z/world-center (:world-size game))]
-      (q/text "You are dead!"
-              (width* center-x)
-              (width* center-y))))
+      (display-centered-text game "You are dead!")))

   (when (empty? (z/zombie-positions game))
     (let [[center-x center-y] (z/world-center (:world-size game))]
-      (q/text "You survived!"
-              (width* center-x)
-              (width* center-y))))
+      (display-centered-text game "You survived!")))

   ; display player
   (when-let [pos (z/player-position game)]


Remove useless code from auth ns in services.

--- src/uxbox/services/auth.clj
+++ src/uxbox/services/auth.clj
@@ -17,22 +17,6 @@
             [uxbox.services.core :as core]
             [uxbox.services.users :as users]
             [uxbox.util.exceptions :as ex]))
-
-(def ^:const +auth-opts+
-  {:alg :a256kw :enc :a256cbc-hs512})
-
-;; --- State
-
-(defn- initialize-auth-secret
-  []
-  (let [main-secret (:secret cfg/config)]
-    (when-not main-secret
-      (ex/raise :code ::missing-secret-key
-                :message "Missing `:secret` key in config."))
-    (hash/blake2b-256 main-secret)))
-
-(defstate secret
-  :start (initialize-auth-secret))

 ;; --- Login


Added automatic de-interlacing

Added automatic de-interlacing

--- src/video_server/ffmpeg.clj
+++ src/video_server/ffmpeg.clj
@@ -24,6 +24,14 @@
     (when (zero? (:exit exec))
       (json/read-str (:out exec) :key-fn keyword))))

+(defn detect-interlace
+  [input]
+  (let [output (:err (exec "ffmpeg" "-y" "-ss" 300 "-i" input "-f" "matroska"
+                           "-t" 120 "-an" "-sn" "-vf" "idet" "/dev/null"))]
+    (when-let [frames (re-find #"Multi frame detection:.*" output)]
+      (let [[top bottom prog und] (parse-ints frames)]
+        #_(> (+ top bottom) (/ (+ top bottom prog und) 10))))))
+
 (defn detect-crop
   "Performs crop detection, returning the filter argument or nil."
   [input]
@@ -32,6 +40,12 @@
                            "-crf" 51 "-preset" "ultrafast" "/dev/null"))]
     (when-let [crop (-> (re-seq #"crop=[0-9:]*" output) distinct sort last)]
       (when-not (.endsWith crop ":0:0") crop))))
+
+(defn deinterlace
+  [spec]
+  (merge spec
+         (when (detect-interlace (:input spec))
+           {:deinterlace "pullup,dejudder,idet,yadif=deint=interlaced:mode=1"})))

 (defn crop
   "Returns an updated spec with crop information."
@@ -56,7 +70,7 @@
 (defn filter-video
   "Returns an updated spec with video filters applied (crop and scale)."
   [spec]
-  (-> spec crop scale))
+  (-> spec deinterlace crop scale))

 (defn encode-video?
   "Returns whether the video stream should be transcoded."
@@ -72,10 +86,11 @@
       ["-map" (str "0:" (:index video-stream)) "-c:v" "libx264" "-crf" quality "-profile:v" "high" "-level" 41]
       ["-map" (str "0:" (:index video-stream)) "-c:v" "copy"])))

-(defn crop-resize-options
-  "Returns the ffmpeg options for cropping and/or resizing the video."
-  [{:keys [crop scale]}]
-  (let [args (str/join "," (remove str/blank? [crop scale]))]
+(defn video-filter-options
+  "Returns the ffmpeg options for the video filter (de-interlace,
+  crop, resize)."
+  [{:keys [deinterlace crop scale]}]
+  (let [args (str/join "," (remove str/blank? [deinterlace crop scale]))]
     (when-not (str/blank? args)
       ["-vf" args])))

@@ -131,7 +146,7 @@
   [spec]
   ["ffmpeg" "-i" (:input spec)
    (video-options spec)
-   (crop-resize-options spec)
+   (video-filter-options spec)
    (audio-options spec)
    (subtitle-options spec)
    "-f" (ffmpeg-format (:format spec))


SER-2225 | 404 should be a valid response

--- src/vignette/storage/s3.clj
+++ src/vignette/storage/s3.clj
@@ -121,7 +121,7 @@
       (not (empty? (s3/list-objects creds bucket {:prefix path :max-keys 1})))
       (catch AmazonS3Exception e
         ; list-objects will throw access denied error on missing paths
-        (if (= (.getErrorCode e) "AccessDenied") false (throw e)))))
+        (if (or (= (.getErrorCode e) "AccessDenied") (= (.getErrorCode e) "NoSuchBucket")) false (throw e)))))
   (list-buckets [this])
   (list-objects [this bucket path]
     (perf/timing :s3-list-objects (s3/list-objects creds bucket {:prefix path}))))


some tweaking

some tweaking

--- src/s7p/slave/core.clj
+++ src/s7p/slave/core.clj
@@ -41,11 +41,11 @@
    (catch JsonParseException e {:status :invalid :reason "invalid JSON"})
    (catch Exception          e {:status :invalid :reason (format "validation process raised unexpected error: %s" e)})))

-(defn log-validated [arg]
+(defn log-validated [test arg]
   (let [{dsp :dsp res :response status :status} arg]
     (if (= status :valid)
-      (bidresponse/log (assoc res :status :valid :dsp_id (:id dsp)))
-      (bidresponse/log (assoc (dissoc arg :dsp)  :dsp_id (:id dsp)))))
+      (bidresponse/log (assoc res :status :valid :dspId (:id dsp) :test test))
+      (bidresponse/log (assoc (dissoc arg :dsp)  :dspId (:id dsp) :test test))))
   arg)

 (defn succeed? [v]
@@ -87,7 +87,7 @@
 (defn log-winnotice-option [data]
   (if data
     (let [{dsp :dsp notice :notice} data]
-      (winnotice/log (assoc notice :status "auction" :dsp_id (:id dsp))))
+      (winnotice/log (assoc notice :status "auction" :dspId (:id dsp))))
     (winnotice/log {:status "no auction"})))

 (defn winnotice [{dsp :dsp notice :notice}]
@@ -99,7 +99,7 @@
                   (map (fn [dsp] {:dsp dsp :response (http/post (:url dsp) (json-request-option req))}))
                   (map destruct)
                   (map validate)
-                  (map log-validated)
+                  (map #(log-validated false %))
                   (filter succeed?)
                   (map (fn [{dsp :dsp res :response}] {:dsp dsp :response res}))
                   (filter #(over-floor? (:floorPrice req) %))))
@@ -114,7 +114,7 @@
               (map (fn [dsp] {:dsp dsp :response (http/post (:url dsp) (json-request-option req))}))
               (map destruct)
               (map validate)
-              (map log-validated)))))
+              (map #(log-validated true %))))))

 (defn worker [c]
   (thread


Fix emoji check

Fix emoji check

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

--- src/status_im/chat/models/message.cljs
+++ src/status_im/chat/models/message.cljs
@@ -25,15 +25,15 @@
                                                                         contacts)]
     (:ref (get available-commands-responses response-name))))

-(defn- emoji-only-string?
-  [text]
-  (re-matches constants/regx-emoji text))
+(defn- emoji-only-content?
+  [content]
+  (and (string? content) (re-matches constants/regx-emoji content)))

 (defn- prepare-message
-  [message chat-id current-chat?]
+  [{:keys [content] :as message} chat-id current-chat?]
   (cond-> (assoc message :appearing? true)
     (not current-chat?) (assoc :appearing? false)
-    (emoji-only-string? (:content message)) (assoc :content-type constants/content-type-emoji)))
+    (emoji-only-content? content) (assoc :content-type constants/content-type-emoji)))

 (defn- add-message
   [chat-id {:keys [message-id clock-value content] :as message} current-chat? {:keys [db]}]
@@ -118,7 +118,7 @@
   [{:keys [db get-stored-message]} {:keys [chat-id from message-id] :as message}]
   (let [{:keys [chats deleted-chats current-public-key]} db
         {:keys [messages not-loaded-message-ids]}        (get chats chat-id)]
-    (when (not= from current-public-key)
+    (when (not= from current-public-key)
       (not (or (get messages message-id)
                (get not-loaded-message-ids message-id)
                (and (get deleted-chats chat-id)


fixed broken link for !bible

fixed broken link for !bible

--- src/xebang/models/bangs.clj
+++ src/xebang/models/bangs.clj
@@ -1,7 +1,7 @@
 (ns xebang.models.bangs)

 (def catalog
-  {'!bible      "http://www.bible.com/search?q={{{s}}}"
+  {'!bible      "http://www.bible.com/search/bible?q={{{s}}}"
    '!kidsinmind "http://www.kids-in-mind.com/cgi-bin/search/search.pl?q={{{s}}}"
    '!movies     "http://www.google.com/movies?hl=en&near={{{s}}}"
    '!weather    "http://weatherspark.com/#!dashboard;q={{{s}}}"


remove old comment

remove old comment

--- src-cljs/frontend/components/overlay.cljs
+++ src-cljs/frontend/components/overlay.cljs
@@ -246,7 +246,6 @@
             access-grants (ds/touch-all '[:find ?t :in $ ?doc-id :where [?t :access-grant/document ?doc-id]] @db doc-id)
             access-requests (ds/touch-all '[:find ?t :in $ ?doc-id :where [?t :access-request/document ?doc-id]] @db doc-id)]
         (html
-         [:div ; TODO make this a list, or at least get rid of div somehow
           [:article
            [:h2.make
             "This document is private."]
@@ -270,7 +269,7 @@
               :data-placeholder-nil "What's your teammate's email?"
               :data-placeholder-forgot "Don't forget to submit!"}]]
            (for [access-entity (sort-by (comp - :db/id) (concat permissions access-grants access-requests))]
-             (render-access-entity access-entity cast!))]])))))
+             (render-access-entity access-entity cast!))])))))

 (defn public-sharing [app owner]
   (reify


:sparkles: Reduce the persist debounce window.

--- frontend/src/uxbox/main/data/workspace.cljs
+++ frontend/src/uxbox/main/data/workspace.cljs
@@ -255,7 +255,7 @@
                               stream)]
         (->> stream
              (rx/filter #(satisfies? IBatchedChange %))
-             (rx/debounce 500)
+             (rx/debounce 200)
              (rx/map (constantly diff-and-commit-changes))
              (rx/take-until stoper))))))


Wrapping cheshire encode and decode

Wrapping cheshire encode and decode

--- src/wishlistd/json.clj
+++ src/wishlistd/json.clj
@@ -1,8 +1,16 @@
 (ns wishlistd.json
-  (:use [cheshire.core]))
+  (:require [cheshire.core :as cheshire]))

 (defn json
   "Wraps the response in the json content type and generates JSON from the content. Uses Chesire for date support."
   [content]
   {:headers {"Content-Type" "application/json"}
-   :body (generate-string content)})+   :body (cheshire/generate-string content)})
+
+(defn encode [v]
+  "Cheshire encode."
+  (cheshire/encode v))
+
+(defn decode [v]
+  "Cheshire decode with symbol option set to true."
+  (cheshire/decode v true))


updated linkification test cases

updated linkification test cases

still failing though

--- test/linkification.clj
+++ test/linkification.clj
@@ -2,7 +2,8 @@
   (:use clojure.test
         [statuses.views.common :only [linkify]]))

-(defn compare [actual expected]
+
+(defn dcompare [actual expected]
   (cond (not= actual expected)
     (str ; XXX: unecessary hack
         (println actual)
@@ -40,9 +41,12 @@
       "lipsum #hashtag")))

 (deftest linkify-uris-with-fragment-identifier []
-  (compare
+  (dcompare
       (linkify "lorem http://example.org#anchor ipsum")
-      "lorem http://example.org#anchor ipsum")
-  (compare
-      (linkify "lorem ipsum http://example.org#anchor-name #hashtag")
-      "lorem http://example.org#anchor-name ipsum #hashtag"))
+      "lorem http://example.org#anchor ipsum"))
+  (dcompare
+      (linkify "#hashtag lipsum http://example.org#anchor-name")
+      "#hashtag lipsum http://example.org#anchor-name")
+  (dcompare
+      (linkify "lipsum http://example.org#anchor-name #hashtag")
+      "lipsum http://example.org#anchor-name #hashtag"))


Add some extra pipeline logging

Add some extra pipeline logging

--- src/vip/data_processor/db/postgres.clj
+++ src/vip/data_processor/db/postgres.clj
@@ -181,15 +181,18 @@

 (defn generate-public-id [ctx]
   (let [{:keys [date election-type state import-id]} (get-public-id-data ctx)]
+    (log/info "Building public id")
     (build-public-id date election-type state import-id)))

 (defn generate-election-id [ctx]
+  (log/info "Building election id")
   (let [{:keys [date election-type state]} (get-public-id-data ctx)]
     (build-election-id date election-type state)))

 (defn store-public-id [ctx]
   (let [id (:import-id ctx)
         public-id (generate-public-id ctx)]
+    (log/info "Storing public id")
     (korma/update results
                   (korma/set-fields {:public_id public-id})
                   (korma/where {:id id}))
@@ -206,6 +209,7 @@
 (defn store-election-id [ctx]
   (if-let [election-id (generate-election-id ctx)]
     (let [id (:import-id ctx)]
+      (log/info "Storing election id")
       (save-election-id! election-id)
       (korma/update results
                     (korma/set-fields {:election_id election-id})
@@ -215,6 +219,7 @@

 (defn store-spec-version [{:keys [spec-version import-id] :as ctx}]
   (when @spec-version
+    (log/info "Storing spec-verion," @spec-version)
     (korma/update results
       (korma/set-fields {:spec_version @spec-version})
       (korma/where {:id import-id})))


Render list with stubbed posts

Render list with stubbed posts

--- src/zooborns/core.cljs
+++ src/zooborns/core.cljs
@@ -3,6 +3,14 @@

 (ns zooborns.core
   (:require [om.next :as om :refer-macros [defui]]))
+
+(def styles
+  {:container {:flex 1 :flexDirection "row" :justifyContent "center" :alignItems "center" :backgroundColor "#F5FCFF"}
+   :list-view {:paddingTop 20 :backgroundColor "#F5FCFF"}
+   :rightContainer {:flex 1}
+   :thumbnail {:backgroundColor "#3b3b39" :height 81 :width 53}
+   :title {:fontSize 20 :marginBottom 8 :textAlign "center"}
+   :year {:textAlign "center"}})

 ;; Reset js/React back as the form above loads in an different React
 (set! js/React (js/require "react-native/Libraries/react-native/react-native.js"))
@@ -15,19 +23,52 @@
 (defn text [opts & children]
   (apply js/React.createElement js/React.Text (clj->js opts) children))

+(defn navigator-ios [opts]
+  (js/React.createElement js/React.NavigatorIOS (clj->js opts)))
+
+(defn list-view [opts & children]
+  (js/React.createElement js/React.ListView (clj->js opts) children))
+
+(defn row-has-changed [x y]
+  (let [row-1 (js->clj x :keywordize-keys true) row-2 (js->clj y :keywordize-keys true)]
+       (not= row-1 row-2)))
+

 ;; Set up our Om UI
-(defonce app-state (atom {:app/msg "Welcome to zooborns"}))
+(defonce app-state (atom {:app/msg "Welcome to zooborns"
+                          :dataSource (js/React.ListView.DataSource. (clj->js {:rowHasChanged row-has-changed}))
+                          :posts [{:title "First post"}
+                                  {:title "Second post"}
+                                  {:title "Third post"}
+                                  {:title "Fourth post"}
+                                  {:title "Fifth post"}]}))
+
+(defn render-post [p]
+  (let [post (js->clj p :keywordize-keys true)]
+    (view {:style {:flexDirection "row" :paddingTop 10}}
+          (text nil (:title post)))))
+
+(def posts
+  (:posts @app-state))
+
+(defui RecentPostsComponent
+  Object
+  (render
+   [this]
+   (list-view {:dataSource (.cloneWithRows (:dataSource @app-state) (clj->js posts))
+               :renderRow render-post
+               :style (:list-view styles)})))

 (defui WidgetComponent
   static om/IQuery
-  (query [this]
-         '[:app/msg])
+  (query
+   [this]
+   '[:app/msg])
   Object
-  (render [this]
-          (let [{:keys [app/msg]} (om/props this)]
-            (view {:style {:flexDirection "column" :margin 40}}
-                  (text nil msg)))))
+  (render
+   [this]
+   (navigator-ios {:style {:flex 1}
+                   :initialRoute {:component RecentPostsComponent :title "ZooBorns"}})))

 ;; om.next parser
 (defmulti read om/dispatch)


Update tense for iOS plan message.

Update tense for iOS plan message.

Some pedantry is also included. Sorry!

--- src-cljs/frontend/components/opt_in.cljs
+++ src-cljs/frontend/components/opt_in.cljs
@@ -43,7 +43,7 @@
        [:div.ui-v2-opt-in {}
         [:div.ui-v2-opt-in-wrapper
          [:div
-          "As a reminder, the iOS beta is ending as of Monday, November 30th. If you have not already, please confirm a plan to lock-in pricing and ensure a smooth transition to the limited-release "
+          "As a reminder, the iOS beta has ended as of Monday, November 30th. If you have not done so already, please confirm a plan to lock pricing in and ensure a smooth transition to the limited release "
           [:a {:href "http://circleci.com/pricing"} "here"]
           ". Reach out to "
           [:a {:href "mailto:sayhi@circleci.com"} "sayhi@circleci.com"]


improve readability of models/transactions

--- src/clj/clj_money/models/transactions.clj
+++ src/clj/clj_money/models/transactions.clj
@@ -7,7 +7,7 @@
             [environ.core :refer [env]]
             [stowaway.core :refer [tag]]
             [stowaway.implicit :as storage :refer [with-storage with-transacted-storage]]
-            [clj-money.validation :as validation]
+            [clj-money.validation :as v]
             [clj-money.models :as models]
             [clj-money.models.settings :as settings]
             [clj-money.models.accounts :as accounts]
@@ -26,7 +26,7 @@

 (s/def ::account-id integer?)
 (s/def ::action #{:debit :credit})
-(s/def ::quantity validation/big-dec-not-less-than-zero?)
+(s/def ::quantity v/big-dec-not-less-than-zero?)
 ; Balance is the running total of quantities for the account to which
 ; the item belongs
 (s/def ::balance (partial instance? BigDecimal))
@@ -34,8 +34,8 @@
 ; default commodity. For most transactions, this will be the same
 ; as the quantity. For transactions involving foreign currencies
 ; and commodity purchases (like stock trades) it will be different.
-(s/def ::value validation/positive-big-dec?)
-(s/def ::description validation/non-empty-string?)
+(s/def ::value v/positive-big-dec?)
+(s/def ::description v/non-empty-string?)
 (s/def ::memo #(or (nil? %) (string? %)))
 (s/def ::transaction-date (partial instance? LocalDate))
 (s/def ::id uuid?)
@@ -115,16 +115,16 @@
                     (filter #(= action (:action %)))
                     (map :value))))

-(defn- ^{:clj-money.validation/message "The total debits does not match the total credits"
-         :clj-money.validation/path [:items]}
+(defn- ^{::v/message "The total debits does not match the total credits"
+         ::v/path [:items]}
   sum-of-credits-must-equal-sum-of-debits
   [transaction]
   (->> [:debit :credit]
        (map #(item-value-sum transaction %))
        (apply =)))

-(defn- ^{:clj-money.validation/message "Each item must have the same transaction-date as the transaction"
-         :clj-money.validation/path [:items]}
+(defn- ^{::v/message "Each item must have the same transaction-date as the transaction"
+         ::v/path [:items]}
   transaction-dates-must-match
   [{:keys [transaction-date items]}]
   (->> items
@@ -335,7 +335,7 @@
 (def ^:private validation-rules
   [#'sum-of-credits-must-equal-sum-of-debits
    #'transaction-dates-must-match
-   (validation/create-rule no-reconciled-items-changed?
+   (v/create-rule no-reconciled-items-changed?
                            [:items]
                            "A reconciled transaction item cannot be changed")])

@@ -343,7 +343,7 @@
   [transaction spec]
   (-> transaction
       before-validation
-      (validation/validate spec validation-rules)
+      (v/validate spec validation-rules)
       after-validation))

 (defn search
@@ -386,12 +386,13 @@
        after-item-read))

 (defn- link-lots
-  [{:keys [id transaction-date]} lot-items]
+  [{:keys [id transaction-date] :as trans} lot-items]
   (mapv (comp l-t/create
               #(assoc %
                       :transaction-id id
                       :transaction-date transaction-date))
-        lot-items))
+        lot-items)
+  trans)

 (defn- find-base-item
   "Given an account ID and a date, finds the transaction item for that
@@ -540,40 +541,52 @@
        (into #{})))

 (defn- save-delayed-info
-  [settings entity-id account-ids transaction-date]
-  (-> settings
+  [m entity-id account-ids transaction-date]
+  (-> m
       (update-in [entity-id :delayed-account-ids]
                  into
                  account-ids)
       (update-in [entity-id :earliest-date] earliest transaction-date)))

+(defn- post-create
+  [{:keys [entity-id transaction-date] :as transaction}]
+  (let [account-ids (extract-account-ids transaction)]
+    (if (delay-balances? entity-id)
+      (swap! ambient-settings
+             save-delayed-info
+             entity-id
+             account-ids
+             transaction-date)
+      (doseq [account-id account-ids]
+        (recalculate-account account-id transaction-date))))
+  transaction)
+
+(defn- process-item-creation
+  [trans items]
+  (assoc trans :items (mapv
+                        #(-> %
+                             (assoc
+                               :transaction-id (:id trans)
+                               :transaction-date (:transaction-date trans)
+                               :index -1)
+                             before-save-item
+                             create-transaction-item*)
+                        items)))
+
 (defn create
   "Creates a new transaction"
   [transaction]
   (with-transacted-storage (env :db)
     (let [validated (validate transaction ::new-transaction)]
-      (if (validation/has-error? validated)
+      (if (v/has-error? validated)
         validated
-        (let [created (storage/create (before-save validated))
-              _  (link-lots created (:lot-items validated))
-              account-ids (extract-account-ids validated)]
-          (doseq [item (:items validated)]
-            (-> item
-                (assoc
-                  :transaction-id (:id created)
-                  :transaction-date (:transaction-date created)
-                  :index -1)
-                before-save-item
-                create-transaction-item*))
-          (if (delay-balances? (:entity-id validated))
-            (swap! ambient-settings
-                   save-delayed-info
-                   (:entity-id validated)
-                   account-ids
-                   (:transaction-date validated))
-            (doseq [account-id account-ids]
-              (recalculate-account account-id (:transaction-date validated))))
-          (reload created))))))
+        (-> validated
+            before-save
+            storage/create
+            (link-lots (:lot-items validated))
+            (process-item-creation (:items validated))
+            post-create
+            reload)))))

 (defn find
   "Returns the specified transaction"
@@ -670,7 +683,7 @@
   [transaction]
   (with-transacted-storage (env :db)
     (let [validated (validate transaction ::existing-transaction)]
-      (if (validation/has-error? validated)
+      (if (v/has-error? validated)
         validated
         (let [existing (find-existing-transaction transaction)
               dereferenced-items (->> (:items existing)


Convert lesson 10 to function-first-api

Convert lesson 10 to function-first-api

--- src/cljs/gampg/learn_gamma/lesson_10.cljs
+++ src/cljs/gampg/learn_gamma/lesson_10.cljs
@@ -1,14 +1,10 @@
 (ns gampg.learn-gamma.lesson-10
-  (:require [clojure.string :as s]
-            [gamma.api :as g]
+  (:require [gamma.api :as g]
             [gamma.program :as p]
-            [gamma.tools :as gt]
+            [gamma-driver.api :as gd]
             [gamma-driver.drivers.basic :as driver]
-            [gamma-driver.protocols :as dp]
-            [goog.webgl :as ggl]
             [thi.ng.geom.core :as geom]
-            [thi.ng.geom.core.matrix :as mat :refer [M44]]
-            [thi.ng.geom.webgl.arrays :as arrays]))
+            [thi.ng.geom.core.matrix :as mat :refer [M44]]))

 ;; With some better architecture,
 ;; this could easily go away
@@ -376,9 +372,9 @@
                    (geom/translate [(- (:x camera))
                                     (- (:y camera))
                                     (- (:z camera))]))]
-        (driver/draw-arrays driver program
-                             (get-data p mv vertices texture texture-coords)
-                             {:draw-mode :triangles})))))
+        (gd/draw-arrays driver (gd/bind driver program
+                                        (get-data p mv vertices texture texture-coords))
+                        {:draw-mode :triangles})))))

 (defn animate [draw-fn step-fn current-value]
   (js/requestAnimationFrame
@@ -407,30 +403,26 @@
                        (update-in [:scene :camera :z] (fn [z] (- z (* (js/Math.cos (:yaw camera)) walk-speed elapsed))))
                        (update-in [:scene :camera :yaw] + (* turn-speed elapsed))
                        (assoc-in [:last-rendered] time-now))]
-    (println (get-in ns [:scene :camera]))
     ns))

 (defn main [gl node]
   (let [width   (.-clientWidth node)
         height  (.-clientHeight node)
         driver  (driver/basic-driver gl)
-        program (dp/program driver program-source)
+        program program-source
         state   (atom (make-app-state width height))]
     (def app-state state)
     (reset-gl-canvas! node)
-    ;; Set the blending function
-    ;;(.blendFunc gl (.-SRC_ALPHA gl) (.-ONE gl))
-    ;;(.enable gl (.-BLEND gl))
     (.enable gl (.-DEPTH_TEST gl))
     (.clearColor gl 0 0 0 1)
     (.clear gl (bit-or (.-COLOR_BUFFER_BIT gl) (.-DEPTH_BUFFER_BIT gl)))
     (let [image (js/Image.)]
       (aset image "onload"
-            (fn [] (let [texture {:data {:data       image
-                                        :filter     {:min :linear
-                                                     :mag :nearest}
-                                        :flip-y     true
-                                        :texture-id 0}}]
+            (fn [] (let [texture {:data       image
+                                 :filter     {:min :linear
+                                              :mag :nearest}
+                                 :flip-y     true
+                                 :texture-id 0}]
                     (swap! state assoc-in [:scene :texture] texture)
                     (set! (.-debugRedrawScene js/window)
                           (fn []


CMR-183: Updated funciton name

CMR-183: Updated funciton name

--- src/cmr/indexer/data/concepts/granule.clj
+++ src/cmr/indexer/data/concepts/granule.clj
@@ -30,7 +30,7 @@
 (defn- fetch-parent-collection
   "Retrieve the parent collection umm from the db"
   [context parent-collection-id]
-  (let [parent-collection-cache (cache/cache-from-context context parent-collection-cache-key)
+  (let [parent-collection-cache (cache/cache->context context parent-collection-cache-key)
         concept (mdb/get-latest-concept context parent-collection-id)]
     (assoc (umm/parse-concept concept) :concept-id parent-collection-id)))


clojuresript-test-friendlier karma interop.

--- test-cljs/circle/karma.cljs
+++ test-cljs/circle/karma.cljs
@@ -1,31 +1,54 @@
 (ns circle.karma
   (:require [clojure.string :as string]
-            [cemerick.cljs.test :as test]))
+            [cemerick.cljs.test :as test])
+  (:require-macros [cemerick.cljs.test :as test]))

 (defn get-total-test-count []
   (reduce + (map count (vals @test/registered-tests))))

-(defn run-karma-test! [test-name test]
-  (let [log-output (atom '())
-        start (.getTime (js/Date.))]
-    (test/set-print-fn! (fn [x] (swap! log-output conj x)))
-    (let
-        ;; [{:result result :time time} (run-test-with-time test)]
-        [result (test/test-function test)]
-      (.result js/__karma__
-               (clj->js
-                { "id" ""
-                  "description" (-> test-name name)
-                  "suite" [(-> test-name namespace str)]
-                  "success" (and (zero? (:error result))
-                                 (zero? (:fail result)))
-                  "skipped" nil
-                  "time" (- (.getTime (js/Date.)) start)
-                  "log" [(string/join "\n" (reverse @log-output))]})))))
+;; A report function to override the default cljs-test one.
+(defmulti report :type)
+
+(defmethod report :begin-test-var [{:keys [test-env]}]
+  ;; Set the current timer.
+  (swap! test-env assoc ::test-start (.getTime (js/Date.)))
+  ;; Collect the output.
+  (swap! test-env assoc ::test-output [])
+  (swap! test-env assoc ::old-print-fn *print-fn*)
+  (test/set-print-fn! (fn [output] (swap! test-env update-in [::test-output] #(conj %1 output)))))
+
+(defmethod report :end-test-var [{:keys [test-env] :as report}]
+  (let [;; Get the start time from the test env, and the end time is now.
+        start (-> @test-env ::test-start )
+        end (.getTime (js/Date.))
+        ;; Collect the output from the test env.
+        output (->> @test-env ::test-output (string/join "\n"))]
+    (test/set-print-fn! (-> @test-env ::old-print-fn))
+    ;; Clean up the test env.
+    (swap! test-env dissoc ::test-start ::test-output ::old-print-fn)
+    ;; Report results to karma.
+    (.result js/__karma__
+             (clj->js { "id" ""
+                        "description" (-> report :test-name str)
+                        "suite" [(-> report :test-name namespace str)]
+                        "success" (and (zero? (:error @test-env))
+                                       (zero? (:fail @test-env)))
+                        "skipped" nil
+                        "time" (- end start)
+                        "log" [output]}))))
+
+;; Make beginning a namespace's tests less noisy.
+(defmethod report :begin-test-ns [_])
+
+;; Fall back to the default report function so that e.g. errors are logged correctly.
+(let [cljs-test-report test/report]
+  (defmethod report :default [data]
+    (cljs-test-report data)))
+

 (defn ^:export run-tests-for-karma []
-  (do (.info js/__karma__ (clj->js {:total (get-total-test-count)}))
-      (doseq [[ns ns-tests] @test/registered-tests ]
-        (doseq [[test-name test] ns-tests]
-          (run-karma-test! test-name test)))
-      (.complete js/__karma__ (clj->js {}))))
+  (.info js/__karma__ (clj->js {:total (get-total-test-count)}))
+  (doseq [[ns ns-tests] @test/registered-tests]
+    (with-redefs [test/report report]
+      (test/test-ns ns)))
+  (.complete js/__karma__ (clj->js {})))


also confirm that the total count matches

--- test/bzzz/sharding_test.clj
+++ test/bzzz/sharding_test.clj
@@ -17,20 +17,24 @@
     (dotimes [x 100]
       (let [doc-generator (fn [n]
                             {:name "jack"
-                             :id (str "id-" (* 100 n))})
+                             :id (str n)})
             list-generator (fn [n]
                              (into []
                                    (for [i (range n)]
                                      (doc-generator i))))
             docs (list-generator 1000)]
+        (delete-all test-index-name)
         (let [r (store {:index test-index-name
-                        :must-refresh true
                         :documents docs
                         :number-of-shards 3})
               r1 (store {:index test-index-name
+                         :force-merge 1
+                         :documents docs
+                         :number-of-shards 3})
+              q (search {:index test-index-name
                          :must-refresh true
-                         :documents docs
-                         :number-of-shards 3})]
+                         :query {:term {:field "name", :value "jack"}}})]
+          (is (= 1000 (:total q)))
           (is (= 3 (count r)))
           (let [rc0 (into [] (for [item r]
                                (for [[k v] item]


Fixed socket timeout test that wasn't necessarily testing anything. Removed connection timeout test because I couldn't get it to fail, even with a timeout of 1ms.

--- test/clj_http/core_test.clj
+++ test/clj_http/core_test.clj
@@ -20,7 +20,11 @@
     [:post "/post"]
       {:status 200 :body (slurp (:body req))}
     [:get "/error"]
-      {:status 500 :body "o noes"}))
+      {:status 500 :body "o noes"}
+    [:get "/timeout"]
+      (do
+        (Thread/sleep 10)
+        {:status 200 :body "timeout"})))

 (defn run-server
   []
@@ -88,14 +92,8 @@
 (deftest ^{:integration true} sets-socket-timeout
   (run-server)
   (try
-    (request {:request-method :get :uri "/get" :socket-timeout 1})
+    (request {:request-method :get :uri "/timeout" :socket-timeout 1})
+    (throw (Exception. "Shouldn't get here."))
     (catch Exception e
       (is (= java.net.SocketTimeoutException (class e))))))

-(deftest ^{:integration true} sets-connection-timeout
-  (run-server)
-  (try
-    (request {:request-method :get :uri "/get" :conn-timeout 1})
-    (catch Exception e
-      (is (= java.net.SocketTimeoutException (class e))))))
-


shutdown peer group in test

shutdown peer group in test

--- test/onyx/log/full_test.clj
+++ test/onyx/log/full_test.clj
@@ -15,9 +15,6 @@
 (def env-config (assoc (:env-config config) :onyx/id onyx-id))

 (def peer-config (assoc (:peer-config config) :onyx/id onyx-id))
-
-(def messaging
-  (component/start (aeron/aeron {:opts peer-config})))

 (def n-peers 20)

@@ -43,6 +40,7 @@
            (finally
              (doseq [v-peer v-peers]
                (onyx.api/shutdown-peer v-peer))
+             (onyx.api/shutdown-peer-group peer-group)
              (onyx.api/shutdown-env env)))))


reproduce TCLJS-22

reproduce TCLJS-22

--- test/transit/test/core.cljs
+++ test/transit/test/core.cljs
@@ -170,4 +170,15 @@
 (deftest test-integer
   (is (= (t/integer "30") 30)))

+;; TCLJS-22
+
+(def pathological
+  [{:any-value {["this vector makes this a cmap"] "any value"
+                "any string" :victim}}
+   {:victim :any-other-value}])
+
+(comment
+  (t/write (t/writer :json) pathological)
+  )
+
 (set! *main-cli-fn* -main)


cljfmt fix

cljfmt fix

--- test/caesium/crypto/secretbox_test.clj
+++ test/caesium/crypto/secretbox_test.clj
@@ -24,9 +24,9 @@
     n0 (v/hex-resource "vectors/secretbox/ciphertext0")
     n1 (v/hex-resource "vectors/secretbox/ciphertext1"))
   (are [nonce ciphertext]
-      (thrown-with-msg?
-       RuntimeException #"Ciphertext verification failed"
-       (s/decrypt secret-key nonce ciphertext))
+       (thrown-with-msg?
+        RuntimeException #"Ciphertext verification failed"
+        (s/decrypt secret-key nonce ciphertext))
     n1 (v/hex-resource "vectors/secretbox/forgery1")))

 (deftest int->nonce-test


working on replacing (generate) with (generate2)

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -172,7 +172,7 @@
                                  truncate?
                                  take-n))))))))
 (defn generate2
-  "Return all expressions matching spec _spec_ given the model _model_."
+  "Return one (by default) or _n_ (using :take _n_) expressions matching spec _spec_ given the model _model_."
   [spec language-model
    & {:keys [max-total-depth truncate-children lexicon take]
       :or {max-total-depth max-total-depth
@@ -181,17 +181,30 @@
            take 1}}]
   (log/debug (str "generate2: spec: " spec))
   (let [depth 0
-        spec (if (fail? (unify spec {:synsem {:subcat []}}))
-               spec
-               (unify spec {:synsem {:subcat []}}))
+        spec
+        (->
+         (if (fail? (unify spec {:synsem {:subcat []}}))
+           spec
+           (unify spec {:synsem {:subcat []}}))
+         ;; remove metadata (if any) that's not relevant to generation:
+         (dissoc :dag_unify.core/serialized))
         max-depth max-total-depth]
-    (first (flatten
-            (mapfn #(do
-                      (log/debug (str "top-level add-bolt-at: " ((:morph-ps language-model) %)))
-                      (add-bolt-at % % [] % language-model depth max-depth truncate-children take))
-                   (lightning-bolts language-model spec 0 max-total-depth))))))
+    (->
+     (clojure.core/take
+      take
+      (flatten
+       (mapfn #(do
+                 (log/debug (str "top-level add-bolt-at: " ((:morph-ps language-model) %)))
+                 (add-bolt-at % % [] % language-model depth max-depth truncate-children take))
+              (lightning-bolts language-model spec 0 max-total-depth))))
+     ((fn [seq]
+        (if (= take 1)
+          (first seq)
+          seq))))))

 (defn generate-n
+  ;; TODO: docs don't match: looks like this was copied from
+  ;; generate-all.
   "Returns all possible expressions generated by the given language model, constrained by the given spec.
    Depending on the grammar in the language model, could be an infinite number of expressions."
   [n spec language-model total-depth


s/info/debug/

s/info/debug/

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -233,7 +233,7 @@
 there is only one child for each parent, and that single child is the
 head of its parent. generate (above) 'decorates' each returned lightning bolt
 of this function with complements."
-  (log/info (str "lightning-bolts(depth=" depth
+  (log/debug (str "lightning-bolts(depth=" depth
                  "; total-depth=" total-depth
                  "; max-total-depth=" max-total-depth
                  "; spec info:" (spec-info spec) ")"))
@@ -263,7 +263,7 @@
                                                         :max-total-depth max-total-depth)))
                          parents)
             (do
-              (log/info (str "hit max-total-depth: " max-total-depth ": will not generate phrasal head children."))
+              (log/debug (str "hit max-total-depth: " max-total-depth ": will not generate phrasal head children."))
               nil))]
       (if (lexemes-before-phrases total-depth)
         (lazy-cat lexical phrasal)


(TK-331) Tighten lifecycle task schema

(TK-331) Tighten lifecycle task schema

Previously, not all lifecycle task messages included a function
to execute, so the schema tolerated a nil for that field.  In
a recent commit, we added a function to the message for 'shutdown',
and thus there are no longer any messages that don't contain a
function.  This allows us to make the schema more restrictive, so
this commit removes the `maybe`.

--- src/puppetlabs/trapperkeeper/internal.clj
+++ src/puppetlabs/trapperkeeper/internal.clj
@@ -18,7 +18,7 @@

 (def LifeCycleTask
   {:type (schema/enum :restart :shutdown :boot)
-   :task-function (schema/maybe IFn)})
+   :task-function IFn})

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Private


(MAINT) whitespace changes

(MAINT) whitespace changes

--- src/puppetlabs/trapperkeeper/services.clj
+++ src/puppetlabs/trapperkeeper/services.clj
@@ -63,39 +63,39 @@
        ;; service map for prismatic graph
        (service-map [this]
          {~service-id
-           ;; the main service fnk for the app graph.  we add metadata to the fnk
-           ;; arguments list to specify an explicit output schema for the fnk
-           (fnk service-fnk# :- ~output-schema
-                ~(conj dependencies 'tk-app-context 'tk-service-refs)
-                (let [svc# (reify
-                             Service
-                             (service-id [this#] ~service-id)
-                             (service-context [this#] (get ~'@tk-app-context ~service-id {}))
-                             (get-service [this# service-id#]
-                               (or (get-in ~'@tk-app-context [:services-by-id service-id#])
-                                   (throw (IllegalArgumentException.
-                                            (format
-                                              "Call to 'get-service' failed; service '%s' does not exist."
-                                              service-id#)))))
-                             (maybe-get-service [this# service-id#]
-                               (get-in ~'@tk-app-context [:services-by-id service-id#] nil))
-                             (get-services [this#]
-                               (-> ~'@tk-app-context
-                                   :services-by-id
-                                   (dissoc :ConfigService :ShutdownService)
-                                   vals))
-                             (service-symbol [this#] '~service-sym)
-                             (service-included? [this# service-id#]
-                               (not (nil? (get-in ~'@tk-app-context [:services-by-id service-id#] nil))))
+          ;; the main service fnk for the app graph.  we add metadata to the fnk
+          ;; arguments list to specify an explicit output schema for the fnk
+          (fnk service-fnk# :- ~output-schema
+            ~(conj dependencies 'tk-app-context 'tk-service-refs)
+            (let [svc# (reify
+                         Service
+                         (service-id [this#] ~service-id)
+                         (service-context [this#] (get ~'@tk-app-context ~service-id {}))
+                         (get-service [this# service-id#]
+                           (or (get-in ~'@tk-app-context [:services-by-id service-id#])
+                               (throw (IllegalArgumentException.
+                                       (format
+                                        "Call to 'get-service' failed; service '%s' does not exist."
+                                        service-id#)))))
+                         (maybe-get-service [this# service-id#]
+                           (get-in ~'@tk-app-context [:services-by-id service-id#] nil))
+                         (get-services [this#]
+                           (-> ~'@tk-app-context
+                               :services-by-id
+                               (dissoc :ConfigService :ShutdownService)
+                               vals))
+                         (service-symbol [this#] '~service-sym)
+                         (service-included? [this# service-id#]
+                           (not (nil? (get-in ~'@tk-app-context [:services-by-id service-id#] nil))))

-                             Lifecycle
-                             ~@(si/fn-defs fns-map lifecycle-fn-names)
+                         Lifecycle
+                         ~@(si/fn-defs fns-map lifecycle-fn-names)

-                             ~@(if service-protocol-sym
-                                 `(~service-protocol-sym
-                                   ~@(si/fn-defs fns-map (vals service-fn-map)))))]
-                  (swap! ~'tk-service-refs assoc ~service-id svc#)
-                  (si/build-service-map ~service-fn-map svc#)))}))))
+                         ~@(if service-protocol-sym
+                             `(~service-protocol-sym
+                               ~@(si/fn-defs fns-map (vals service-fn-map)))))]
+              (swap! ~'tk-service-refs assoc ~service-id svc#)
+              (si/build-service-map ~service-fn-map svc#)))}))))

 (defmacro defservice
   [svc-name & forms]


refactoring

refactoring

--- src/bitcoinrpc/core.clj
+++ src/bitcoinrpc/core.clj
@@ -183,6 +183,24 @@

 (def-rpcs)

+
+
+;; java interface
+;;TODO
+
+(defn method-args-of [m]
+  `~(:arglists m))
+
+(defn method-of [m]
+  `(~(:name m) ~@(method-args-of m))
+  )
+
+(defmacro def-java-api []
+  `(definterface IBtcRpc
+     ~(map method-of (btc-meta))
+     )
+  )
+
 ;;---------------socket repl-------------------------------

 (defn repl-init []


Create new test wrapper

Create new test wrapper

--- test/discuss/test.cljs
+++ test/discuss/test.cljs
@@ -1,10 +0,0 @@
-(ns ^:figwheel-always discuss.test
-  (:require [cljs.test :refer-macros [deftest is run-all-tests]]
-            [discuss.auth-test]))
-
-(enable-console-print!)
-
-(defn ^:export run []
-  (print "\n\n##### Starting tests at:" (.toLocaleString (js/Date.)) "######")
-  (time (run-all-tests #"discuss.*-test"))
-  (println "##### End Running tests ######\n\n"))


Add test dependencies

Add test dependencies

--- build/datomic-tester/jepsen.datomic/project.clj
+++ build/datomic-tester/jepsen.datomic/project.clj
@@ -4,4 +4,6 @@
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
   :dependencies [[org.clojure/clojure "1.7.0"]
+                 [org.clojure/tools.nrepl "0.2.10"]
+                 [clojure-complete/clojure-complete "0.2.3"]
                  [jepsen "0.0.9"]])


playing around with index thoughts

playing around with index thoughts

--- sample/src/sample/core.clj
+++ sample/src/sample/core.clj
@@ -117,50 +117,164 @@

 (defn etest []
-  (cldb/db-rel instance x)
-  (cldb/db-rel person p)
-  (cldb/db-rel address a)
-  (cldb/db-rel person->address p a)
-
-  (let [facts1 [[instance {:type :foo :a 1 :b 2}]
-                [instance {:type :bar :a 2 :b 3}]
-                [address {:id 100
-                          :type :address
-                          :street "street 1"}]
-                [address {:id 101
-                          :type :address
-                          :street "street 2"}]
-                [person {:id 200
-                         :type :person
-                         :name "hans 1"
-                         :address_id 100}]
-                [person {:id 201
-                         :type :person
-                         :name "hans 2"
-                         :address_id 101}]]
-        ldb (apply cldb/db facts1)]
-    (cldb/with-db ldb
-      (cl/run* [q]
-        #_(foo q 22)
-        (cl/fresh [p o a b]
-          (instance q)
-          (cl/featurec q {:type :foo})
-
-          #_(person p)
-          #_(cl/featurec p {:type :person})
-          #_(cl/featurec p {:name "hans 1"})
-          #_(cl/featurec p {:id q})
-
-          #_(cl/== q p)
-          #_(foo q b)
-          #_(cl/== q [a b])
-          #_(cl/matcha [] ([(person {:id 200 :name q})]))
-          #_(cl/== p {:a 1 :b 2 :c 3})
-          #_(cl/matcha [p]
-                     ([{:a 1 :b 2 :c q}])
-                     #_([[_ . o]] (cl/== q ["second" o]))))))))
+  (cldb/db-rel fact ^:index e ^:index a ^:index v ^:index t)
+
+  #_(cldb/db-rel entity x)
+  (cldb/db-rel person ^:index id ^:index name data)
+  (cldb/db-rel address ^:index id ^:index street data)
+  (cldb/db-rel person<->address ^:index id ^:index personid ^:index addressid data)
+
+  (letfn [(entity->ldb [{:keys [:db/id :db/type] :as entity} & {:keys [index-defs]}]
+            (let [index-def (get index-defs type)
+                  index-vals (map #(get entity %) index-def)
+                  rel (some-> (ns-resolve *ns* (-> type name symbol)) deref)]
+              (vec (concat [rel id]
+                           index-vals
+                           [entity]))))
+
+          (entities->ldb [entities & args]
+            (map #(apply entity->ldb % args) entities))]
+
+    (let [facts [[100 :db/type    :address          1]
+                 [100 :street     "street 1"        1]
+                 [101 :db/type    :address          2]
+                 [101 :street     "street 2"        2]
+                 [200 :db/type    :person           3]
+                 [200 :name       "hans 1"          3]
+                 [201 :db/type    :person           4]
+                 [201 :name       "hans 2"          4]
+                 [300 :db/type    :person<->address 5]
+                 [300 :person_id  200               5]
+                 [300 :address_id 100               5]
+                 [301 :db/type    :person<->address 6]
+                 [301 :person_id  200               6]
+                 [301 :address_id 101               6]
+                 [302 :db/type    :person<->address 7]
+                 [302 :person_id  201               7]
+                 [302 :address_id 101               7]]
+
+          index-defs {:person           [:name]
+                      :address          [:street]
+                      :person<->address [:person_id :address_id]}
+          #_index-defs #_(->> index-defs
+                          (map (fn [[type v]]
+                                 [type (->> (map (fn [e i]
+                                                   [e i])
+                                                 v
+                                                 (range))
+                                            (into {}))]))
+                          (into {}))
+
+          entities [{:db/id 100
+                     :db/type :address
+                     :street "street 1"}
+                    {:db/id 101
+                     :db/type :address
+                     :street "street 2"}
+                    {:db/id 200
+                     :db/type :person
+                     :name "hans 1"}
+                    {:db/id 201
+                     :db/type :person
+                     :name "hans 2"}
+                    {:db/id 300
+                     :db/type :person<->address
+                     :person_id 200
+                     :address_id 100}
+                    {:db/id 301
+                     :db/type :person<->address
+                     :person_id 200
+                     :address_id 101}
+                    {:db/id 302
+                     :db/type :person<->address
+                     :person_id 201
+                     :address_id 101}]
+
+          entities-ldb (entities->ldb entities :index-defs index-defs)]
+
+      #_(println entities-ldb)
+
+      (cldb/with-db (apply cldb/db entities-ldb)
+        (cl/run* [q]
+          #_(foo q 22)
+          (cl/fresh [p pid pn aid]
+            (person pid "hans 2" p)
+            (person<->address (cl/lvar) pid aid (cl/lvar))
+            (address aid (cl/lvar) q)
+
+            #_(instance q)
+            #_(cl/featurec q {:type :foo})
+
+            #_(person p)
+            #_(cl/featurec p {:type :person})
+            #_(cl/featurec p {:name "hans 1"})
+            #_(cl/featurec p {:id q})
+
+            #_(cl/== q p)
+            #_(foo q b)
+            #_(cl/== q [a b])
+            #_(cl/matcha [] ([(person {:id 200 :name q})]))
+            #_(cl/== p {:a 1 :b 2 :c 3})
+            #_(cl/matcha [p]
+                         ([{:a 1 :b 2 :c q}])
+                         #_([[_ . o]] (cl/== q ["second" o])))))))))

 ;;; (etest)
+
+
+
+(defn idxtest []
+  (letfn [(order-datom [datom order]
+            (mapv #(get datom %) order))
+
+          (build-index [datoms order]
+            (let [idx* (volatile! {})]
+              (doseq [d datoms]
+                (vswap! idx* #(assoc-in % (order-datom d order) d)))
+              {:order order
+               :index @idx*}))
+
+          (leafs [index]
+            (let [leafs* (transient [])]
+              (loop [[node & nodes] (list index)]
+                (cond
+                  (map? node)       (recur (concat (vals node) nodes))
+                  (not (nil? node)) (do (conj! leafs* node)
+                                        (recur nodes))
+                  true              (persistent! leafs*)))))
+
+          (lookup-index [{:keys [order index] :as idx} ks]
+            (loop [node index
+                   [k & ks] ks]
+              (cond
+                (nil? k)          node
+                (not (nil? node)) (recur (get node k) ks))))]
+
+    (let [datoms [[100 :db/type    :address          1]
+                  [100 :street     "street 1"        1]
+                  [101 :db/type    :address          2]
+                  [101 :street     "street 2"        2]
+                  [200 :db/type    :person           3]
+                  [200 :name       "hans 1"          3]
+                  [201 :db/type    :person           4]
+                  [201 :name       "hans 2"          4]
+                  [302 :db/type    :person<->address 7]
+                  [302 :person_id  201               7]
+                  [302 :address_id 101               7]
+                  [301 :db/type    :person<->address 6]
+                  [301 :person_id  200               6]
+                  [301 :address_id 101               6]
+                  [300 :db/type    :person<->address 5]
+                  [300 :person_id  200               5]
+                  [300 :address_id 100               5]]]
+
+      #_(build-index datoms [0 1 2 3])
+      #_(build-index datoms [1 0 2 3])
+      (-> (build-index datoms [1 2 0 3])
+          (lookup-index [:name "hans 2"])
+          (leafs)))))
+
+;;; (idxtest)


remove temporary tests

remove temporary tests

--- test/babel/test/en.cljc
+++ test/babel/test/en.cljc
@@ -389,40 +389,6 @@

     (is (not (empty? (babel.generate/lightning-bolts med (get-in good-lb [:head :comp]) 0 0))))
     (is (not (empty? (babel.generate/lightning-bolts med (get-in good-lb [:comp]) 0 0))))))
-
-(deftest nugent-testing
-  (let [med (medium)
-        spec {:synsem {:cat :verb
-                       :sem {:pred :read
-                             :subj {:pred :woman}}
-                       :subcat '()}}
-        bolts-and-comps (bolts-with-comps spec med 0 6)
-        ; (def
-        bolts-with-phrasal-head (filter #(and (not (nil? (get % [:head :comp])))
-                                              (not (empty? (get % [:head :comp])))
-                                              (not (empty? (get % [:comp]))))
-                                        bolts-and-comps)
-                                        ; )
-
-;        (def
-        fb (first bolts-with-phrasal-head)
-        ; )
-        ]
-    (is (not (empty? bolts-and-comps)))))
-
-(defn bolts-with-comps-is-slow []
-  (let [med (medium)
-        spec {:synsem {:cat :verb
-                       :sem {:pred :read
-                             :subj {:pred :woman}}
-                       :subcat '()}}]
-    (repeatedly (fn [] (time (type (first (filter #(and (not (empty? (get % [:head :comp])))
-                                                        (not (empty? (get % [:comp]))))
-                                                  (bolts-with-comps spec med 0 6)))))))))
-
-;; lein test :only babel.test.en/bwc-slow
-(deftest bwc-slow
-  (is (= 1 (count (take 1 (bolts-with-comps-is-slow))))))

 (deftest take-advantage-present
   (let [result (generate {:synsem {:sem {:pred :take-advantage-of
@@ -586,25 +552,6 @@
     ;; explicitly set to progressive present:
     (is (= "I am eating" (morph (generate progressive))))))

-
-(deftest lb1
-  (let [comp-paths (babel.generate/find-comp-paths good-lb)
-        paths-to-specs (zipmap
-                        comp-paths
-                        (map #(get-in good-lb %)
-                             comp-paths))
-        paths-to-lbs
-        (zipmap
-         comp-paths
-         (map #(babel.generate/lightning-bolts
-                med
-                (get-in good-lb %)
-                0 0)
-              comp-paths))]
-
-    (is (not (empty? (get paths-to-lbs [:head :comp]))))
-    (is (not (empty? (get paths-to-lbs [:comp]))))))
-
 (deftest benchmark-test []
   (let [med (medium)
         to-run #(time (println (fo (generate
@@ -632,11 +579,6 @@
                          (keys bolt-to-comps))})
        bolts-with-comps))

-(defn benchmark [spec & [n]]
-  (let [n (or n 5)]
-    (doall (take n (repeatedly #(time (doall (do-counts (bolts-with-comps spec (medium) 0 6)))))))
-    nil))
-
 (defn benchmark1 []
   (benchmark spec1 5))


rename and change test to use generate-all

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -1,6 +1,6 @@
 (ns babel.test.it
   (:refer-clojure :exclude [get-in])
-  (:require [babel.engine :refer [generate]]
+  (:require [babel.engine :refer [generate generate-all]]
             [babel.italiano.grammar :refer [small medium np-grammar]]
             [babel.italiano.lexicon :refer [lexicon]]
             [babel.italiano.morphology :refer [fo]]
@@ -85,22 +85,27 @@
                  :expr (get-in expr [:synsem :sem])
                  :sem (get-in (first (parse (fo expr) np-grammar))
                               [:synsem :sem])})))))
+(deftest roundtrip-all
+  (let [do-this-many 100] ;; doing them all takes minutes rather than seconds.
+    (is (empty?
+         (filter #(not (nil? %))
+                 (let [expressions
+                       (generate-all {:synsem {:sem {:spec {:def :top}
+                                                     :mod {:pred :top}
+                                                     :number :top
+                                                     :pred :top}}}
+                                     np-grammar)]
+                   (pmap (fn [expr]
+                           (if (empty? (parse (fo expr) np-grammar))
+                             (do
+                               (log/error (str "failed to parse: " (fo expr)))
+                             {:fo (fo expr)
+                              :expr (get-in expr [:synsem :sem])
+                              :sem (get-in (first (parse (fo expr) np-grammar))
+                                           [:synsem :sem])})
+                             (log/info (str "parse OK:" (fo expr)))))
+                         (if (= do-this-many :all)
+                           expressions
+                           (take do-this-many expressions)))))))))

-(deftest roundtrip-many
-  (is (empty?
-       (filter #(not (nil? %))
-               (take 10
-                     (repeatedly #(let [expr
-                                        (generate {:synsem {:sem {:spec {:def :top}
-                                                                  :mod {:pred :top}
-                                                                  :number :top
-                                                                  :pred :top}}}
-                                                  np-grammar)]
-                                    (if (empty? (parse (fo expr) np-grammar))
-                                      (do
-                                        (log/error (str "failed to parse: " (fo expr)))
-                                        {:fo (fo expr)
-                                         :expr (get-in expr [:synsem :sem])
-                                         :sem (get-in (first (parse (fo expr) np-grammar))
-                                                      [:synsem :sem])})
-                                      (log/info (str "parse OK:" (fo expr)))))))))))
+


+(deftest passato-prossimo-ditransitive)

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -75,6 +75,16 @@
                          :model small)]
     (is (not (nil? result)))
     (is (= "io mi sono alzata" (fo result)))))
+
+(deftest passato-prossimo-ditransitive
+  (let [result (generate {:synsem {:subcat '()
+                                   :infl :present
+                                   :sem {:pred :be-called
+                                         :subj {:pred :I}
+                                         :iobj {:pred :luisa}}}}
+                         :model small)]
+    (is (not (nil? result)))
+    (is (= "io mi chiamo Luisa" (fo result)))))

 (deftest parse-io-parlo
   (let [result (:parses (first (parse "io parlo")))]


fix typo

fix typo

--- test/babel/test/la.cljc
+++ test/babel/test/la.cljc
@@ -19,7 +19,7 @@

 ;; function to render target expression as text. show-notes=false because
 ;; we are translating from Latin which (at least for the purposes of this
-;; implemetation) lacks the same kind of gender differences that Italian, for
+;; implementation) lacks the same kind of gender differences that Italian, for
 ;; example, has.
 (def source-format-fn #((-> models source-language deref :morph) % :show-notes false))


Playing with atan2.

Playing with atan2.

--- src/cbfg/world-net.cljs
+++ src/cbfg/world-net.cljs
@@ -83,40 +83,45 @@
     (let [coords @coords
           addr-width 50
           addr-gap 200
-          addr-left (fn [addr] (* addr-width
+          calc-x (fn [addr] (* addr-width
                                (/ (+ addr-width addr-gap)
                                   addr-width)
                                (get coords addr)))
           h ["
"
              (mapv (fn [[addr addr-v]]
-                     ["
"
-                      "" addr ""
-                      (mapv (fn [[[accept-addr accept-port] accept-addr-port-v]]
-                              ["
"
-                               " " accept-addr ""
-                               " " accept-port ""
-                               (when (and (= accept-addr addr)
-                                          (get (:listens addr-v) accept-port))
-                                 ["
" accept-port "
"])
-                               (mapv (fn [[[from-port to-addr to-port] msgs]]
-                                       (let [rad (- (/ Math/PI 2))]
-                                         ["
" from-port " --> " to-addr to-port "= "
-                                          "
"
-                                          (mapv (fn [[deliver-at msg]]
-                                                  ["
X
"])
-                                                msgs)
-                                          "
"
-                                          "
"]))
-                                     (sort-by first accept-addr-port-v))
-                               "
"])
-                            (sort-by first (:outs addr-v)))
-                      "
"])
+                     (let [addr-x (calc-x addr)]
+                       ["
"
+                        "" addr ""
+                        (mapv (fn [[[accept-addr accept-port] accept-addr-port-v]]
+                                ["
"
+                                 " " accept-addr ""
+                                 " " accept-port ""
+                                 (when (and (= accept-addr addr)
+                                            (get (:listens addr-v) accept-port))
+                                   ["
" accept-port "
"])
+                                 (mapv (fn [[[from-port to-addr to-port] msgs]]
+                                         (let [from-x addr-x
+                                               from-y (get coords [addr from-port])
+                                               to-x (calc-x to-addr)
+                                               to-y (get coords [to-addr to-port])
+                                               rad (Math/atan2 (- from-x to-x) (- from-y to-y))]
+                                           ["
" from-port " --> " to-addr to-port "= "
+                                            " <div class='msgs' style='"
+                                            " transform-origin:top left;"
+                                            " -ms-transform-origin:top left;"
+                                            " -webkit-transform-origin:top left;"
+                                            " transform:rotate(" rad "rad);"
+                                            " -ms-transform:rotate(" rad "rad);"
+                                            " -webkit-transform:rotate(" rad "rad);'>"
+                                            (mapv (fn [[deliver-at msg]]
+                                                    ["
X
"])
+                                                  msgs)
+                                            "
"
+                                            "
"]))
+                                       (sort-by first accept-addr-port-v))
+                                 "
"])
+                              (sort-by first (:outs addr-v)))
+                        "
"]))
                   (sort-by first @addrs))
              "
"]]
       (set-el-innerHTML output-el-id


Fix asplan hierarchy.

Fix asplan hierarchy.

--- src/angelic/search/action_set/asplan.clj
+++ src/angelic/search/action_set/asplan.clj
@@ -1,4 +1,4 @@
-(ns angelic.asplan
+(ns angelic.search.action-set.asplan
   (:require [edu.berkeley.ai.util :as util]
             [edu.berkeley.ai.util.graphs :as graphs]
             [angelic.env :as env]
@@ -297,7 +297,7 @@

 ; (use '[angelic env hierarchy taxi-infinite ucs asplan #_ hierarchical-incremental-search sas-problems] 'edu.berkeley.ai.util)

-;; (use '[angelic env hierarchy] '[angelic.domains taxi-infinite] '[angelic.search ucs] asplan #_ sas-problems] 'edu.berkeley.ai.util)
+;; (use 'angelic.search.uniform-cost 'angelic.domains.taxi-infinite 'angelic.search.action-set.asplan  'angelic.domains.sas-problems 'edu.berkeley.ai.util)

 ;; (let [e (make-random-infinite-taxi-sas2 4 4 4 2)] (println (time (run-counted #(uniform-cost-search e)))) (println (time (run-counted #(asplan-solution-pair-name (uniform-cost-search (make-asplan-env e)))))))

@@ -417,7 +417,9 @@
 (defn make-achieve-precondition-hla [hierarchy var dst-val]
   (let [name [:achieve-precondition var dst-val]
         av   (action-var var)
-        pc   (util/safe-get-in hierarchy [:precondition-context-map var])]
+        pc   (util/safe-get-in hierarchy [:precondition-context-map var])
+        pc   (:full-context hierarchy)
+        ]
     (reify
       env/Action
        (action-name [a] name)
@@ -458,12 +460,10 @@
         ancestor-vars (util/safe-get-in hierarchy [:ancestor-var-map effect-var])
         child-var-map (:child-var-map hierarchy)
         pc            (into #{(action-var effect-var)}
-                        (apply concat
-                          (for [p (keys reduced-pm)]
-                            (cons (free-var p)
-                                  (cons (parent-var p effect-var)
-                                        (get-in hierarchy [:precondition-context-map p]))))))]
-;    (println "FA" name)
+                        (apply concat (map (:fire-action-pc-map hierarchy) (keys reduced-pm))))
+;        pc (:full-context hierarchy)
+        ]
+;    (println "FA" name pc "\n" (clojure.set/difference (:full-context hierarchy) pc))
   (reify
     env/Action
       (action-name [a] name)
@@ -533,6 +533,11 @@
               (when-not (= effect-var sas/goal-var-name) [[]])))))
        (cycle-level-           [a s] nil))))

+(comment ; old, broken PC
+  (for [p (keys reduced-pm)]
+                             (cons (free-var p)
+                                   (cons (parent-var p effect-var)
+                                         (util/safe-get-in hierarchy [:fire-action-pc-map p])))))
 ;(def *bs* nil)

  ; include ancestor vars, action vars, free vars, in-pointing 'rents
@@ -548,7 +553,17 @@
                      (concat
                       (for [v as] (free-var v))
                       (for [v as] (action-var v))
-                      (for [v as, c (cvm v), :when (as c)] (parent-var v c))))]))]
+                      (for [v as, c (cvm v), :when (as c)] (parent-var v c))))]))
+        fa-map (into {}
+                 (for [[k as] av-map]
+                   [k
+                    (into as
+                     (concat
+                      (for [v as] (free-var v))
+                      (for [v as] (action-var v))
+                      (for [v as, c (cvm v)] (parent-var v c))))]))
+        ]
+ ;    (println "\n" av-map "\n\n" pc-map)
     (hierarchy-util/make-simple-hierarchical-env
      env
      [(make-fire-action-hla
@@ -558,7 +573,8 @@
         :child-var-map            cvm
         :ancestor-var-map         av-map
         :acyclic-succ-fn          (:acyclic-succ-fn env)
-        :precondition-context-map pc-map}
+        :precondition-context-map pc-map
+        :fire-action-pc-map       fa-map}
        sas/goal-var-name
        (state/get-var (env/initial-state env) (action-var sas/goal-var-name)))])))

@@ -575,8 +591,14 @@
 ;; TODO: detect "out-of-context" deadlock, fail immediately.
 ;; TODO: precond ordering when we activate (handled by activation-actions?)

-
-;  (let [e (make-random-infinite-taxi-sas2 1 2 1 2)] (println (time (run-counted #(uniform-cost-search e)))) (println (time (run-counted #(asplan-solution-pair-name (uniform-cost-search (make-asplan-env e))))))  (println (debug 0 (time (run-counted #(asplan-solution-pair-name (dsh-ucs-inverted (make-asplan-skip-henv e))))))))
+;; (use 'angelic.search.explicit.hierarchical)
+
+;; TODO: (let [e (make-random-infinite-taxi-sas2 3 2 5 2)] (println (time (run-counted #(uniform-cost-search e)))) (println (time (run-counted #(asplan-solution-pair-name (uniform-cost-search (make-asplan-env e))))))  (println (debug 0 (time (run-counted #(asplan-skip-solution-pair-name (dsh-ucs-inverted (make-asplan-skip-henv e)))))))) gives bad results; replacing inverted iwht regular fixes it ... ?
+
+;; minimal exmaple:
+;; (let [i 25] (let [e (make-random-infinite-taxi-sas2 3 1 2 i)] #_ (println (time (run-counted #(uniform-cost-search e)))) (println (time (run-counted #(asplan-solution-pair-name (uniform-cost-search (make-asplan-env e))))))  (println (debug 0 (time (run-counted #(asplan-skip-solution-pair-name (dsh-ucs-inverted (make-asplan-skip-henv e)))))))))
+
+;  (let [e (make-random-infinite-taxi-sas2 1 2 1 2)] (println (time (run-counted #(uniform-cost-search e)))) (println (time (run-counted #(asplan-solution-pair-name (uniform-cost-search (make-asplan-env e))))))  (println (debug 0 (time (run-counted #(asplan-skip-solution-pair-name (dsh-ucs-inverted (make-asplan-skip-henv e))))))))

 ; (let [e (make-random-infinite-taxi-sas2 1 2 1 2)] (interactive-hierarchical-search (make-asplan-skip-henv e)))


s/past/passato/

s/past/passato/

--- src/babel/italiano/morphology/verbs.cljc
+++ src/babel/italiano/morphology/verbs.cljc
@@ -93,10 +93,10 @@

 ;; <passato>
 (let [source
-      (-> (clojure.java.io/resource "babel/italiano/morphology/verbs/past.edn")
+      (-> (clojure.java.io/resource "babel/italiano/morphology/verbs/passato.edn")
           slurp
           read-string)]
-  (def patterns-past
+  (def patterns-passato
     (compile-patterns
      {:synsem {:infl :past}}
      source)))
@@ -135,14 +135,14 @@
         patterns-future
         patterns-gerund
         patterns-imperfect
-        patterns-past
+        patterns-passato
         patterns-present
         patterns-subjunctive)))

 (defonce exceptions-rules
-  [;; 1. past-tense exceptions
+  [;; 1. passato exceptions
    {:path [:italiano :passato]
-    :label "past-tense exception"
+    :label "passato exception"
     :merge-fn
     (fn [val]
       {:italiano {:infl :past


Fremtidig konfetti

Fremtidig konfetti

--- src/clj/mokkameister/resources/slack.clj
+++ src/clj/mokkameister/resources/slack.clj
@@ -61,13 +61,18 @@
     (slack/notify msg :channel channel)))

 (defmethod handle-slack-coffee :regular [{:keys [channel time-ms] :as event}]
-  (let [today-count (get-in (brew-stats) [:regular :today])
+  (let [stats       (brew-stats)
+        today-count (get-in stats [:regular :today])
+        total-count (get-in stats [:regular :total])
         now-msg     (coffee-message-starting event today-count)
         later-msg   (coffee-message-finished)]
     (persist-brew! event)
     (pusher/push! "coffee" "coffee" now-msg)
     (slack/notify (str now-msg " - " mokkameister-link) :channel channel)
-    (slack/delayed-notify time-ms later-msg :channel channel)))
+    (slack/delayed-notify time-ms later-msg :channel channel)
+    (if (= total-count 999)
+      (slack/delayed-notify (+ time-ms 1000) "http://gph.is/2cTHbu3" :channel channel)
+      (slack/delayed-notify (+ time-ms 1500) "Dette var brygg nr 1000! :tada::confetti_ball::coffee:" :channel channel))))

 (defn parse-slack-coffee-event [{:keys [channel_id text user_name]}]
   (let [event {:channel    channel_id


Refactor existing nav-items to use a common component

--- src/cljs/my_money/components/navbar.cljs
+++ src/cljs/my_money/components/navbar.cljs
@@ -5,6 +5,10 @@
             [my-money.views.login :as login]
             [my-money.views.registration :as registration]
             [my-money.routes :as routes]))
+
+(defn nav-item [child]
+  [:li.nav-item
+   child])

 (defn user-menu [e!]
   [:ul.flex.pl-0.mb-0.list-none.ml-auto
@@ -16,8 +20,8 @@
          :on-click #(e! (ac/->Logout))}
         [:i.fa.fa-user " " user " | log out"]]]]
      [:<>
-      [:li.nav-item [login/login-button]]
-      [:li.nav-item [registration/registration-button]]])])
+      [nav-item [login/login-button]]
+      [nav-item [registration/registration-button]]])])

 (defn navbar [e!]
   (r/with-let [collapsed? (r/atom true)]


adding action bar with images for example

--- src/clojure/my/company/superapp/main.clj
+++ src/clojure/my/company/superapp/main.clj
@@ -6,6 +6,8 @@
               [neko.find-view :refer [find-view]]
               [neko.threading :refer [on-ui]]
               [neko.log :as log]
+              [neko.ui :as ui]
+              [neko.action-bar :as action-bar :refer [setup-action-bar tab-listener]]
               ;; [clojure.core.async
                ;; :as a
                ;; :refer [>! <! >!! <!! go chan go-loop put! tap mult close! thread
@@ -112,11 +114,18 @@

   (start-servers
       [this]
-
-    (log/i (str "starting HTTPD server: " bind-address ":" httpd-port))
-    (.start httpd)
-    (log/i (str "starting WSD server: " bind-address ":" wsd-port))
-    (.start wsd -1)
+    (if (.isAlive httpd)
+      (do
+        (toast "starting HTTPD server")
+        (log/i (str "starting HTTPD server: " bind-address ":" httpd-port))
+        (.start httpd))
+      (log/i "HTTPD server is already running..."))
+    (if (.isAlive wsd)
+      (do
+        (toast "starting wsd server")
+        (log/i (str "starting WSD server: " bind-address ":" wsd-port))
+        (.start wsd -1))
+      (log/i "WSD server is already running"))
     )
 )

@@ -151,8 +160,27 @@

   (onCreate [this bundle]
     (.superOnCreate this bundle)
+    (setup-action-bar this
+                      {:title "Custom title"
+                       :icon R$drawable/ic_launcher
+                       :display-options [:show-home :show-title :home-as-up]
+                       :subtitle "Custom subtitle"
+                       :navigation-mode :tabs
+                       :tabs [
+                              [:tab
+                               {:text "Player"
+                                :icon R$drawable/ic_launcher
+                                :tab-listener (tab-listener
+                                               :on-tab-selected (fn [tab ft]
+                                                                  (toast "Player was presed")))}]
+                              [:tab {:text "Settings"
+                                     :icon R$drawable/ic_launcher
+                                     :tab-listener (tab-listener
+                                                    :on-tab-selected (fn [tab ft]
+                                                                       (toast "Settings was presed")))}]]})
+
     ;; starting servers
-    (toast "starting HTTPD-WSD servers" :long)
+    ;; (toast "starting HTTPD-WSD servers" :long)
     (start-servers httpd-wsd)
     (neko.debug/keep-screen-on this)
     (on-ui


bug fix

bug fix

--- src/clojure/zensols/dataset/elsearch.clj
+++ src/clojure/zensols/dataset/elsearch.clj
@@ -69,8 +69,7 @@
   (let [{:keys [properties index-name mapping-type-defs settings]} (context)]
     (log/infof "mapping '%s': <%s>" index-name mapping-type-defs)
     (-> (apply esi/create (concat [(connection) index-name :mappings mapping-type-defs]
-                                   (if settings [:settings settings])))
-        assert-success)))
+                                   (if settings [:settings settings]))))))

 (defn delete-mapping
   "Delete an Elasticsearch mapping."


Added utility to streamline allowing collections of mutation rates etc.

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -4,6 +4,18 @@
         [clojure.math.numeric-tower])
   (:import (org.apache.commons.math3.stat.inference TTest))
   (:require [clojure.string :as string]))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; local utilities
+
+(defn number
+  "If given a number, returns it. If given a collection, returns a member of the collection.
+  Intended for allowing arguments to genetic operators, such as mutation rates, to take
+  collections in addition to single values"
+  [number-or-numbers]
+  (if (number? number-or-numbers)
+    number-or-numbers
+    (lrand-nth number-or-numbers)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; reproduction
@@ -840,3 +852,4 @@

+


Rename progressive half-progressive, ultra-progressive progressive.

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -47,30 +47,30 @@
                                     (inc (:age p1)))))))))
     :first (fn [p1 p2 g]
              (inc (:age p1)))
+    :half-progressive (fn [p1 p2 g]
+                        (if (= (:age p1) (:age p2))
+                          (inc (:age p1))
+                          (if (= (:genome p1) (:genome p2))
+                            (/ (+ (inc (:age p1)) (inc (:age p2))) 2)
+                            (if (> (:age p2) (:age p1))
+                              (inc (:age p1))
+                              (let [p1-dist (levenshtein-distance g (:genome p1))
+                                    p2-dist (levenshtein-distance g (:genome p2))]
+                                (+ (inc (:age p1))
+                                   (* (/ p1-dist (+ p1-dist p2-dist))
+                                      (- (inc (:age p2))
+                                         (inc (:age p1))))))))))
     :progressive (fn [p1 p2 g]
                    (if (= (:age p1) (:age p2))
                      (inc (:age p1))
                      (if (= (:genome p1) (:genome p2))
                        (/ (+ (inc (:age p1)) (inc (:age p2))) 2)
-                       (if (> (:age p2) (:age p1))
-                         (inc (:age p1))
-                         (let [p1-dist (levenshtein-distance g (:genome p1))
-                               p2-dist (levenshtein-distance g (:genome p2))]
-                           (+ (inc (:age p1))
-                              (* (/ p1-dist (+ p1-dist p2-dist))
-                                 (- (inc (:age p2))
-                                    (inc (:age p1))))))))))
-    :ultra-progressive (fn [p1 p2 g]
-                         (if (= (:age p1) (:age p2))
-                           (inc (:age p1))
-                           (if (= (:genome p1) (:genome p2))
-                             (/ (+ (inc (:age p1)) (inc (:age p2))) 2)
-                             (let [p1-dist (levenshtein-distance g (:genome p1))
-                                   p2-dist (levenshtein-distance g (:genome p2))]
-                               (+ (inc (min (:age p1) (:age p2)))
-                                  (* (Math/abs (float (- (:age p1) (:age p2))))
-                                     (/ (Math/abs (float (- p1-dist p2-dist)))
-                                        (+ p1-dist p2-dist))))))))))
+                       (let [p1-dist (levenshtein-distance g (:genome p1))
+                             p2-dist (levenshtein-distance g (:genome p2))]
+                         (+ (inc (min (:age p1) (:age p2)))
+                            (* (Math/abs (float (- (:age p1) (:age p2))))
+                            	         (/ (Math/abs (float (- p1-dist p2-dist)))
+                                            (+ p1-dist p2-dist))))))))))

 ;; test effects of :proportionate with expressions like this:
 ;(float ((age-combining-function {:age-combining-function :proportionate})


testing "ordering"

testing "ordering"

--- test/java_time_test.clj
+++ test/java_time_test.clj
@@ -878,13 +878,33 @@
       (is (nil? (j/gap (j/interval 0 1000) (j/interval 500 1500))))))

   (testing "ordering"
-    (is (j/before? (j/interval 1000 2000) (j/instant 5000)))
-    (is (not (j/before? (j/interval 1000 5000) (j/instant 5000))))
-    (is (j/before? (j/interval 1000 5000) (j/interval 5001 6000)))
-
-    (is (j/after? (j/interval 1000 5000) (j/instant 100)))
-    (is (not (j/after? (j/interval 1000 5000) (j/instant 2000))))
-    (is (j/after? (j/interval 1000 5000) (j/interval 100 999)))))
+    (let [interval-1-2 (j/interval 1 2)
+          interval-3-4 (j/interval 3 4)
+          instant-1 (j/instant 1)
+          instant-3 (j/instant 3)]
+      (is (j/before? interval-1-2 interval-3-4))
+      (is (not (j/before? interval-3-4 interval-1-2)))
+      (is (j/before? interval-1-2 instant-3))
+      (is (not (j/before? interval-3-4 instant-1)))
+
+      (is (j/after? interval-3-4 interval-1-2))
+      (is (not (j/after? interval-1-2 interval-3-4)))
+      (is (j/after? interval-3-4 instant-1))
+      (is (not (j/after? interval-1-2 instant-3)))
+
+      (is (j/not-before? interval-3-4 interval-3-4))
+      (is (j/not-before? interval-1-2 interval-3-4))
+      (is (not (j/not-before? interval-1-2 interval-3-4)))
+      (is (j/not-before? interval-3-4 instant-3))
+      (is (j/not-before? interval-3-4 instant-1))
+      (is (not (j/not-before? interval-1-2 instant-3)))
+
+      (is (j/not-after? interval-1-2 interval-1-2))
+      (is (j/not-after? interval-1-2 interval-3-4))
+      (is (not (j/not-after? interval-3-4 interval-1-2)))
+      (is (j/not-after? interval-1-2 instant-1))
+      (is (j/not-after? interval-1-2 instant-3))
+      (is (not (j/not-after? interval-3-4 instant-1)))))

 (jt.u/when-joda-time-loaded


fix #1118

fix #1118

--- src/status_im/components/permissions.cljs
+++ src/status_im/components/permissions.cljs
@@ -1,5 +1,6 @@
 (ns status-im.components.permissions
-  (:require [taoensso.timbre :as log]))
+  (:require [status-im.utils.platform :as platform]
+            [taoensso.timbre :as log]))

 (def permissions-class (.-PermissionsAndroid js/ReactNative))

@@ -16,9 +17,11 @@
          (not= (first permission-vals) "denied"))))

 (defn request-permissions [permissions then else]
-  (let [permissions (mapv #(get permissions-map %) permissions)
-        result      (.requestMultiple permissions-class (clj->js permissions))
-        result      (.then result #(if (all-granted? (js->clj %))
-                                     (then)
-                                     (when else (else))))
-        result      (.catch result #(else))]))+  (if platform/android?
+    (let [permissions (mapv #(get permissions-map %) permissions)
+          result      (.requestMultiple permissions-class (clj->js permissions))
+          result      (.then result #(if (all-granted? (js->clj %))
+                                       (then)
+                                       (when else (else))))
+          result      (.catch result #(else))])
+    (then)))


Extend tests for split-at-string

Extend tests for split-at-string

--- src/test/discuss/references/lib_test.cljs
+++ src/test/discuss/references/lib_test.cljs
@@ -17,10 +17,13 @@
   (testing "Split the input string in two parts at the replacement-string."
     (tlib/check' (stest/check `discuss.references.lib/split-at-string))
     (are [x y] (= x y)
-      [""] (rlib/split-at-string "" "")
-      [""] (rlib/split-at-string "" "abc")
-      ["abc"] (rlib/split-at-string "abc" "")
-      ["abc"] (rlib/split-at-string "abc" "def")
-
-      )
-    ))
+      [""]          (rlib/split-at-string "" "")
+      [""]          (rlib/split-at-string "" "abc")
+      ["abc"]       (rlib/split-at-string "abc" "")
+      []            (rlib/split-at-string "1" "1")
+      ["abc"]       (rlib/split-at-string "abc" "def")
+      ["" "bar"]    (rlib/split-at-string "foobar" "foo")
+      ["" "foo"]    (rlib/split-at-string "foofoo" "foo")
+      ["foo" ""]    (rlib/split-at-string "foobar" "bar")
+      ["a" "c"]     (rlib/split-at-string "abc" "b")
+      ["bar" "baz"] (rlib/split-at-string "barfoo?baz" "foo?"))))


(PDB-2858) rm-r: report removal errors

(PDB-2858) rm-r: report removal errors

If something goes wrong during rm-r, throw an exception that includes
:out, :err, :exit, etc.

--- test/stockpile_test.clj
+++ test/stockpile_test.clj
@@ -21,9 +21,13 @@
       s
       (recur (RandomStringUtils/random n)))))

-(defn rm-r [pathstr]
-  ;; Life's too short...
-  (assert (zero? (:exit (shell/sh "rm" "-r" pathstr)))))
+ (defn rm-r [pathstr]
+   ;; Life's too short...
+   (let [rm (shell/sh "rm" "-r" pathstr)]
+     (when-not (zero? (:exit rm))
+       (throw (-> "'rm -r %s' failed: %s"
+                  (format (pr-str pathstr) (pr-str rm))
+                  Exception.)))))

 (defn call-with-temp-dir-path
   [f]


Add test for `of-micros`

Add test for `of-micros`

--- test/tick/api_test.cljc
+++ test/tick/api_test.cljc
@@ -348,7 +348,9 @@
 ;; Durations. Convenience functions to create durations of specific
 ;; units.
 (deftest duration-functions-test
-  (is (= (t/of-nanos 10) (t/new-duration 10 :nanos))))
+  (is (= (t/of-nanos 10) (t/new-duration 10 :nanos)))
+  (is (= (t/of-micros 10) (t/new-duration 10 :micros))))
+

 (deftest predicates-test


CMR-3551: Fixed the require indentation in jobs.clj

--- ingest-app/src/cmr/ingest/services/jobs.clj
+++ ingest-app/src/cmr/ingest/services/jobs.clj
@@ -1,14 +1,15 @@
 (ns cmr.ingest.services.jobs
   "This contains the scheduled jobs for the ingest application."
-  (:require [cmr.common.jobs :as jobs :refer [def-stateful-job defjob]]
-            [cmr.transmit.metadata-db :as mdb]
-            [cmr.transmit.echo.acls :as echo-acls]
-            [cmr.acl.acl-fetcher :as acl-fetcher]
-            [cmr.ingest.services.humanizer-alias-cache :as humanizer-alias-cache]
-            [cmr.ingest.data.provider-acl-hash :as pah]
-            [cmr.ingest.data.ingest-events :as ingest-events]
-            [cmr.common.config :as cfg :refer [defconfig]]
-            [cmr.common.log :refer (debug info warn error)]))
+  (:require
+    [cmr.acl.acl-fetcher :as acl-fetcher]
+    [cmr.common.config :as cfg :refer [defconfig]]
+    [cmr.common.jobs :as jobs :refer [def-stateful-job defjob]]
+    [cmr.common.log :refer (debug info warn error)]
+    [cmr.ingest.data.ingest-events :as ingest-events]
+    [cmr.ingest.data.provider-acl-hash :as pah]
+    [cmr.ingest.services.humanizer-alias-cache :as humanizer-alias-cache]
+    [cmr.transmit.echo.acls :as echo-acls]
+    [cmr.transmit.metadata-db :as mdb]))

 (def REINDEX_COLLECTION_PERMITTED_GROUPS_INTERVAL
   "The number of seconds between jobs to check for ACL changes and reindex collections."


checking for missing serial device adapters in mac

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

--- buildscripts/buildcheck/src/buildcheck/core.clj
+++ buildscripts/buildcheck/src/buildcheck/core.clj
@@ -98,15 +98,6 @@
   (let [ending (str "." suffix)]
     (filter #(.. % getName (endsWith ending))
             (mapcat file-seq parent-dirs))))
-
-(defn uses-serial-port [file]
-  (.contains (slurp file) "g_Keyword_Port"))
-
-(defn devices-using-serial-port []
-       (seq
-         (into (sorted-set)
-               (map #(first (.split (.getName %) "\\."))
-                    (filter uses-serial-port (files-of-type device-adapter-parent-dirs "cpp"))))))

 (defn missing-vcproj []
   (let [device-adapter-dirs (device-adapter-dirs)
@@ -234,4 +225,27 @@
   (make-full-report (get {"inc" :inc "full" :full} mode) true))

- +;;;; checking mac stuff (manual)
+
+(defn uses-serial-port [file]
+  (.contains (slurp file) "g_Keyword_Port"))
+
+(defn devices-using-serial-port []
+         (into (sorted-set)
+               (map #(.getName (.getParentFile %))
+                    (filter uses-serial-port (files-of-type device-adapter-parent-dirs "cpp")))))
+
+(defn unix-built-devices []
+  (into (sorted-set)
+        (map #(nth (.split % "_") 2)
+             (filter #(.startsWith % "libmmgr")
+                     (map #(.getName %)
+                          (file-seq (File. "/Users/arthur/Programs/ImageJ")))))))
+
+
+(defn missing-unix-adapters []
+  (into (sorted-set)
+        (clojure.set/difference (set (map #(.toLowerCase %) (devices-using-serial-port)))
+                                (set (map #(.toLowerCase %) (unix-built-devices)))
+                                #{"pi_gcs" "pi_gcs_2" "xcite120pc_exacte" "skeleton" "crystal"
+                                  "imic2000" "polychrome5000"})))


Fix `put-boolean` not writing first byte

--- src/main/cljc/mikron/runtime/buffer.cljc
+++ src/main/cljc/mikron/runtime/buffer.cljc
@@ -393,7 +393,8 @@
   (let [bit-index (get-bit-index buffer)]
     (when (== 0 bit-index)
       (let [bit-position (get-bit-position buffer)]
-        (when (pos? bit-position)
+        (if (neg? bit-position)
+          (set-bit-position buffer 0)
           (put-byte-at buffer bit-position (get-bit-value buffer))))
       (let [position (get-position buffer)]
         (set-bit-position buffer position)


CMR-2118 Adds docstring.

CMR-2118 Adds docstring.

--- ingest-app/src/cmr/ingest/services/umm.clj
+++ ingest-app/src/cmr/ingest/services/umm.clj
@@ -12,6 +12,8 @@
     (umm/parse-concept (assoc concept-map :format mt/echo10 :metadata echo10-metadata))))

 (defn parse-concept
+  "Returns UMM record from an ingest concept map. Handles additional formats implemented by umm-spec
+  that cmr.umm.core/parse-concept does not support."
   [concept-map]
   (if (= mt/umm-json (:format concept-map))
     (parse-umm-json-concept concept-map)


sort repositories lexicographically by default

--- src/otto/repositories.clj
+++ src/otto/repositories.clj
@@ -36,5 +36,5 @@

 (defn make-repositories
   []
-  (let [repos (ref {})]
+  (let [repos (ref (sorted-map))]
     (->RepositoryList repos)))


Made requirement for at least one vote more explicit (must be a non pass vote; repness)

--- src/polismath/repness.clj
+++ src/polismath/repness.clj
@@ -105,10 +105,10 @@
   "Like beats-best-by-test?, but only considers agrees. Additionally, doesn't focus solely on repness,
   but also on raw probability of agreement, so as to ensure that there is some representation of what
   people in the group agree on. Also, note that this takes the current-best, instead of just current-best-z."
-  [{:keys [ra rat pa pat ns] :as comment-conv-stats} current-best]
+  [{:keys [na nd ra rat pa pat ns] :as comment-conv-stats} current-best]
   (cond
    ; Explicitly don't let something that hasn't been voted on at all come into repness
-    (= ns 0)
+    (= 0 na nd)
         false
     ; If we have a current-best by repness estimate, use the more robust measurement
     (and current-best (> (:ra current-best) 1.0))


More test cases for test-list-of-all-jobs-no-data and test-list-of-all-jobs-null

--- test/clj_jenkins_api/jenkins_api_test.clj
+++ test/clj_jenkins_api/jenkins_api_test.clj
@@ -339,12 +339,18 @@
     (testing "the clj-jenkins-api.jenkins-api/list-of-all-jobs"
         (with-redefs [http-client/get (fn [url mapa] {:body "{\"something\": [\"first\", \"second\", \"third\"]}"})]
             (are [x y] (= x y)
-                nil (read-list-of-all-jobs "" "")))))
+                nil (read-list-of-all-jobs "" "")
+                nil (read-list-of-all-jobs "jenkins-url" "")
+                nil (read-list-of-all-jobs "" "job-name")
+                nil (read-list-of-all-jobs "jenkins-url" "job-name")))))

 (deftest test-list-of-all-jobs-null
     "Check the clj-jenkins-api.jenkins-api/list-of-all-jobs"
     (testing "the clj-jenkins-api.jenkins-api/list-of-all-jobs"
         (with-redefs [http-client/get (fn [url mapa] {:body "null"})]
             (are [x y] (= x y)
-                nil (read-list-of-all-jobs "" "")))))
-
+                nil (read-list-of-all-jobs "" "")
+                nil (read-list-of-all-jobs "jenkins-url" "")
+                nil (read-list-of-all-jobs "" "job-name")
+                nil (read-list-of-all-jobs "jenkins-url" "job-name")))))
+