(maint) Refactor get-* functions into one function

Previously several functions were present to get a value from ezbake
configs, one for each key in the config. This led to a lot of repetition
and new code being needed to get new keys when they were added. This
commit refactors those functions into one single function that takes a
keyword to lookup as an extra parameter. It also updates the calls to
use the new function and removes the now unneeded old functions.

--- src/puppetlabs/ezbake/core.clj
+++ src/puppetlabs/ezbake/core.clj
@@ -250,32 +250,15 @@
   ;; with it as well.
   (stencil/render-string s ezbake-vars))

-(defn get-deps
-  [upstream-ezbake-configs build-target os]
-  {:pre [(map? upstream-ezbake-configs)
-         (string? build-target)
-         (contains? #{:redhat :debian} os)]}
-  (set (mapcat #(get-in % [:ezbake (keyword build-target) os :dependencies])
-               (vals upstream-ezbake-configs))))
-
-(defn get-preinst
-  [ezbake-vars upstream-ezbake-configs build-target os]
+(defn get-ezbake-value
+  [ezbake-vars upstream-ezbake-configs build-target os ezbake-keyword]
   {:pre [(map? ezbake-vars)
          (map? upstream-ezbake-configs)
          (string? build-target)
-         (contains? #{:redhat :debian} os)]}
+         (contains? #{:redhat :debian} os)
+         (keyword? ezbake-keyword)]}
   (map (partial interpolate-ezbake-config ezbake-vars)
-       (mapcat #(get-in % [:ezbake (keyword build-target) os :preinst])
-               (vals upstream-ezbake-configs))))
-
-(defn get-extra-install
-  [ezbake-vars upstream-ezbake-configs build-target os]
-  {:pre [(map? ezbake-vars)
-         (map? upstream-ezbake-configs)
-         (string? build-target)
-         (contains? #{:redhat :debian} os)]}
-  (map (partial interpolate-ezbake-config ezbake-vars)
-       (mapcat #(get-in % [:ezbake (keyword build-target) os :install])
+       (mapcat #(get-in % [:ezbake (keyword build-target) os ezbake-keyword])
                (vals upstream-ezbake-configs))))

 (defn add-ezbake-config-to-map
@@ -377,25 +360,25 @@
       (fs/file staging-dir "ezbake.rb")
       (stencil/render-string
         (slurp "./staging-templates/ezbake.rb.mustache")
-        {:project         (:name lein-project)
-         :real-name       (str/replace-first (:name lein-project) #"^pe-" "")
-         :user            (get-local-ezbake-var lein-project :user
-                                                (:name lein-project))
-         :group           (get-local-ezbake-var lein-project :group
-                                                (:name lein-project))
-         :uberjar-name    (:uberjar-name lein-project)
-         :config-files    (quoted-list config-files)
-         :cli-app-files   (quoted-list (map remove-erb-extension cli-app-files))
-         :debian-deps     (quoted-list (get-deps upstream-ezbake-configs build-target :debian))
-         :debian-preinst  (quoted-list (get-preinst ezbake-vars upstream-ezbake-configs build-target :debian))
-         :debian-install  (quoted-list (get-extra-install ezbake-vars upstream-ezbake-configs build-target :debian))
-         :redhat-deps     (quoted-list (get-deps upstream-ezbake-configs build-target :redhat))
-         :redhat-preinst  (quoted-list (get-preinst ezbake-vars upstream-ezbake-configs build-target :redhat))
-         :redhat-install  (quoted-list (get-extra-install ezbake-vars upstream-ezbake-configs build-target :redhat))
-         :terminus-map    termini
-         :replaces-pkgs   (get-local-ezbake-var lein-project :replaces-pkgs [])
-         :java-args       (get-local-ezbake-var lein-project :java-args
-                                                "-Xmx192m")}))))
+        {:project                   (:name lein-project)
+         :real-name                 (str/replace-first (:name lein-project) #"^pe-" "")
+         :user                      (get-local-ezbake-var lein-project :user
+                                                          (:name lein-project))
+         :group                     (get-local-ezbake-var lein-project :group
+                                                          (:name lein-project))
+         :uberjar-name              (:uberjar-name lein-project)
+         :config-files              (quoted-list config-files)
+         :cli-app-files             (quoted-list (map remove-erb-extension cli-app-files))
+         :debian-deps               (quoted-list (get-ezbake-value ezbake-vars upstream-ezbake-configs build-target :debian :dependencies))
+         :debian-preinst            (quoted-list (get-ezbake-value ezbake-vars upstream-ezbake-configs build-target :debian :preinst))
+         :debian-install            (quoted-list (get-ezbake-value ezbake-vars upstream-ezbake-configs build-target :debian :install))
+         :redhat-deps               (quoted-list (get-ezbake-value ezbake-vars upstream-ezbake-configs build-target :redhat :dependencies))
+         :redhat-preinst            (quoted-list (get-ezbake-value ezbake-vars upstream-ezbake-configs build-target :redhat :preinst))
+         :redhat-install            (quoted-list (get-ezbake-value ezbake-vars upstream-ezbake-configs build-target :redhat :install))
+         :terminus-map              termini
+         :replaces-pkgs             (get-local-ezbake-var lein-project :replaces-pkgs [])
+         :java-args                 (get-local-ezbake-var lein-project :java-args
+                                                          "-Xmx192m")}))))

 (defn generate-project-data-yaml
   [lein-project build-target]


undo bug/#1057 fix

undo bug/#1057 fix

--- src/status_im/chat/screen.cljs
+++ src/status_im/chat/screen.cljs
@@ -168,6 +168,7 @@
                 :renderScrollComponent     #(invertible-scroll-view (js->clj %))
                 :onEndReached              (when-not loaded? #(dispatch [:load-more-messages]))
                 :enableEmptySections       true
+                :keyboardShouldPersistTaps true
                 :dataSource                (to-datasource-inverted messages)}]))

 (defview chat []


Fix JWE example.

Fix JWE example.

--- examples/jwe/src/authexample/web.clj
+++ examples/jwe/src/authexample/web.clj
@@ -9,7 +9,7 @@
             [ring.middleware.json :refer [wrap-json-response wrap-json-body]]
             [ring.adapter.jetty :as jetty]
             [clj-time.core :as time]
-            [buddy.sign.jwe :as jwe]
+            [buddy.sign.jwt :as jwt]
             [buddy.core.nonce :as nonce]
             [buddy.auth :refer [authenticated? throw-unauthorized]]
             [buddy.auth.backends.token :refer [jwe-backend]]
@@ -61,7 +61,7 @@
     (if valid?
       (let [claims {:user (keyword username)
                     :exp (time/plus (time/now) (time/seconds 3600))}
-            token (jwe/encrypt claims secret {:alg :a256kw :enc :a128gcm})]
+            token (jwt/encrypt claims secret {:alg :a256kw :enc :a128gcm})]
         (ok {:token token}))
       (bad-request {:message "wrong auth data"}))))


Removed newline.

Removed newline.

--- src/dragon/components/config.clj
+++ src/dragon/components/config.clj
@@ -20,4 +20,3 @@
   ""
   []
   (->Config))
-


Clean up

Clean up

--- src/datemo/routes.clj
+++ src/datemo/routes.clj
@@ -65,7 +65,6 @@
               (into {:arb/doctype (keyword "doctype" doctype)})
               (into {:arb/id id}) (edn->clj))
        [tx-result tx-error] (db/transact-or-error [tx])]
-   (pprint {:tx-result tx-result :tx-error tx-error})
    (if (nil? tx-error)
      (let [db-after (:db-after tx-result)
            new-doc (d/pull db-after '[*] [:arb/id id])


server.clj -main stops server if already active

--- src/elliot/server.clj
+++ src/elliot/server.clj
@@ -41,5 +41,6 @@
   ;; The #' is useful when you want to hot-reload code
   ;; You may want to take a look: https://github.com/clojure/tools.namespace
   ;; and http://http-kit.org/migration.html#reload
+  (if (not (nil? @server))
+    (stop-server))
   (reset! server (run-server #'app {:port 8080})))
-


Move code around in players.clj

Move code around in players.clj

--- src/glory_of_empires/players.clj
+++ src/glory_of_empires/players.clj
@@ -27,54 +27,53 @@
          (map (fn [ [id pwd] ] { :id id :password pwd :ac [] :pc [] } ))
          (index-by-id))))

+(defn ids [ game-state ] (keys (game-state :players)))
+
 (defn- fighter-image [ race-id ] [ :img { :src (ships/ship-image-url :fi race-id) } ] )

 (defn- player-flag [ race-id ] [ :img {:src (str html/resources-url "FlagWavy/Flag-Wavy-" (name race-id) ".png")} ] )

+(defn- player-row-data [ { map :map planets :planets units :units } { race-id :id tg :tg ac :ac pc :pc } ]
+  (let [ player-controls (fn [object] (= (:controller object) race-id))
+        player-systems (->> map vals (filter player-controls))
+        player-planets (->> planets vals (filter player-controls)) ]
+    [ (name race-id)
+     (fighter-image race-id)
+     (player-flag race-id)
+     "VP"
+     (count player-systems)
+     (count player-planets)
+     "Res"
+     "Inf"
+     (or tg 0)
+     "Army Res"
+     "Techs"
+     (count ac)
+     (count pc)   ]))
+
+(defn players-table [ game ]
+  (let [ header [ "Race" "Color" "Symbol" "VP" "Systems" "Planets" "Res (available-units" "Inf" "TG" "Army Res" "Tech" "AC" "PC" ]
+        rows (map #(player-row-data game %) (players game))
+        pars `[ { :class "data" } ~header ~@rows ] ]
+    (apply html/table pars) ))
+
 (defn- ac-to-html [ id ]
   (let [ { descr :description play :play set :set } (ac/all-ac-types id) ]
     [:span (name id)
-          (html/color-span "#909090" (str ": " descr " Play: " play))]  ))
+     (html/color-span "#909090" (str ": " descr " Play: " play))]  ))

 (defn- player-html [ role { race-id :id acs :ac } ]
   { :pre [ (not (nil? race-id)) ] }
   (let [ show-all (or (= role :game-master) (= role race-id))
         race (races/all-races race-id) ]
     [ :div
-      [ :h3
-        [ :span {} (str (name race-id) " - " (race :name)) ]
-       (fighter-image race-id) ]
-     (if show-all
-       [:div
-        [:p " Action Cards"]
-        (html/ol (map ac-to-html acs))]
-       [ :p "(hidden)" ]   ) ] ))
-
-(defn- player-row-data [ { map :map planets :planets units :units } { race-id :id tg :tg ac :ac pc :pc } ]
-  (let [ player-controls (fn [object] (= (:controller object) race-id))
-        player-systems (->> map vals (filter player-controls))
-        player-planets (->> planets vals (filter player-controls)) ]
-    [ (name race-id)
-      (fighter-image race-id)
-      (player-flag race-id)
-      "VP"
-      (count player-systems)
-      (count player-planets)
-      "Res"
-      "Inf"
-      "Army Res"
-      (or tg 0)
-      "Techs"
-      (count ac)
-      (count pc)   ]))
-
-(defn ids [ game-state ] (keys (game-state :players)))
-
-(defn players-table [ game ]
-  (let [ header [ "Race" "Color" "Symbol" "VP" "Systems" "Planets" "Res" "Inf" "Army Res" "TG" "Tech" "AC" "PC" ]
-         rows (map #(player-row-data game %) (players game))
-         pars `[ { :class "data" } ~header ~@rows ] ]
-    (apply html/table pars) ))
+      [ :h3 [ :span (str (race :name) " - " (name race-id)) ]
+          (fighter-image race-id) (player-flag race-id) ]
+      (if show-all
+         [ :div { :style "margin-left: 1cm;" }
+            [:p " Action Cards"]
+            (html/ol (map ac-to-html acs))]
+         [ :p "(hidden)" ]   ) ] ))

 (defn players-html [ game role ]
   `[ :div


Fix Reagent-related bug in bindings.

Fix Reagent-related bug in bindings.

--- src/reforms/binding/core.cljs
+++ src/reforms/binding/core.cljs
@@ -19,14 +19,18 @@
   ([x v]
    (-reset! x v))
   ([x ks v]
+   (js/console.log "reset!" (prn-str x) (prn-str ks) (prn-str v))
    (if (not-empty ks)
      (-reset! x ks v)
      (-reset! x v))))

 (defn get-in [x ks]
-  (if (not-empty ks)
-    (-get-in x ks)
-    x))
+
+  (let [result (if (not-empty ks)
+                 (-get-in x ks)
+                 (-deref x))]
+    (js/console.log "get-in" (prn-str x) (prn-str ks) (prn-str result))
+    result))

 (defn path [x]
   (-path x))


Fix `split-ext` implementation.

Fix `split-ext` implementation.

--- src/datoteka/core.clj
+++ src/datoteka/core.clj
@@ -187,13 +187,15 @@
   (str (.getFileName ^Path (pt/-path path))))

 (defn split-ext
-  "Returns a vector of `[name extension]`."
-  [path]
-  (let [base (name path)
-        i (.lastIndexOf base ".")]
+  "Returns a vector of `[^String name ^String extension]`."
+  [path]
+  (let [^Path path (pt/-path path)
+        ^String path-str (.toString path)
+        i (.lastIndexOf path-str ".")]
     (if (pos? i)
-      [(subs base 0 i) (subs base i)]
-      [base nil])))
+      [(subs path-str 0 i)
+       (subs path-str i)]
+      [path-str nil])))

 (defn extension
   "Return the extension part of a file."


Add new database-fields

Add new database-fields

--- src/demogorgon/nh.clj
+++ src/demogorgon/nh.clj
@@ -539,7 +539,12 @@
       [:region "TEXT"]
       [:event "TEXT"]
       [:carried "TEXT"]
-      [:elbereths "INT"])
+      [:elbereths "INT"]
+      [:xplevel "INT"]
+      [:exp "INT"]
+      [:mode "TEXT"]
+      [:gold "INT"])
+     (.info logger "table created")
      (let [lines (read-lines (str (:un-dir config) "xlogfile"))]
        (doseq [line lines]
          (insert-xlogfile-line-db "eu" line)))


Remove unchecked-divide, seems to be obsolete

--- src/demogorgon/nh.clj
+++ src/demogorgon/nh.clj
@@ -124,9 +124,9 @@
                    player (aget tokens 0)
                    date (aget tokens 1)
                    ttyrec (File. (str "/opt/nethack.nu/dgldir/ttyrec/" player "/" date))
-                   idle (unchecked-divide
-                         (int (- (System/currentTimeMillis) (.lastModified ttyrec)))
-                         1000)
+                   idle (int (/
+                              (int (- (System/currentTimeMillis) (.lastModified ttyrec)))
+                              1000))
                    whereis (File. (str "/opt/nethack.nu/var/unnethack/" player ".whereis"))]
                (with-open [rdr (reader whereis)]
                  (let [data (parse-line (first (line-seq rdr)))]


Disable auto-load in dev mode

Disable auto-load in dev mode

--- src/discuss/core.cljs
+++ src/discuss/core.cljs
@@ -17,7 +17,7 @@
 ;; Initialization
 (defn main []
   (com/init-with-references!))
-(main)
+;(main)

 ;; Register
 (om/root views/main-view lib/app-state


Set MININT and MAXINT

Set MININT and MAXINT

--- src/evalback/core.clj
+++ src/evalback/core.clj
@@ -203,7 +203,7 @@
         tn (.getAbsolutePath tf)
         ]
     (.deleteOnExit tf)
-    (spit tf "MACHINE empty \n END")
+    (spit tf "MACHINE empty \n DEFINITIONS \n SET_PREF_MAXINT == 127;\b SET_PREF_MININT == -128;\n END")
     tn))

 (defn init []


Formatting changes

Formatting changes

--- src/io/aviso/rook/dispatcher.clj
+++ src/io/aviso/rook/dispatcher.clj
@@ -5,20 +5,18 @@
   The main function is [[construct-namespace-handler]], but this is normally only invoked
   by [[namespace-handler]]."
   {:added "0.1.10"}
-  (:import
-    [java.net URLDecoder])
-  (:require
-    [clojure.core.async :refer [chan close!]]
-    [clojure.string :as string]
-    [io.aviso.tracker :as t]
-    [io.aviso.toolchest.macros :refer [consume cond-let]]
-    [io.aviso.toolchest.collections :refer [pretty-print]]
-    [io.aviso.toolchest.exceptions :refer [to-message]]
-    [io.aviso.rook.internals :as internals]
-    [clojure.string :as str]
-    [clojure.tools.logging :as l]
-    [io.aviso.rook.utils :as utils]
-    [medley.core :as medley]))
+  (:require [clojure.core.async :refer [chan close!]]
+            [clojure.string :as string]
+            [io.aviso.tracker :as t]
+            [io.aviso.toolchest.macros :refer [consume cond-let]]
+            [io.aviso.toolchest.collections :refer [pretty-print]]
+            [io.aviso.toolchest.exceptions :refer [to-message]]
+            [io.aviso.rook.internals :as internals]
+            [clojure.string :as str]
+            [clojure.tools.logging :as l]
+            [io.aviso.rook.utils :as utils]
+            [medley.core :as medley])
+  (:import [java.net URLDecoder]))

 (def ^:private supported-methods
   "The supported methods, used to \"split\" a route with method :all."


remove template provided repl.clj (for dev-launching app from repl)

--- src/foosball/repl.clj
+++ src/foosball/repl.clj
@@ -1,34 +0,0 @@
-(ns foosball.repl
-  (:use foosball.handler
-        ring.server.standalone
-        [ring.middleware file-info file]))
-
-(defonce server (atom nil))
-
-(defn get-handler []
-  ;; #'app expands to (var app) so that when we reload our code,
-  ;; the server is forced to re-resolve the symbol in the var
-  ;; rather than having its own copy. When the root binding
-  ;; changes, the server picks it up without having to restart.
-  (-> #'app
-    ; Makes static assets in $PROJECT_DIR/resources/public/ available.
-    (wrap-file "resources")
-    ; Content-Type, Content-Length, and Last Modified headers for files in body
-    (wrap-file-info)))
-
-(defn start-server
-  "used for starting the server in development mode from REPL"
-  [& [port]]
-  (let [port (if port (Integer/parseInt port) 8080)]
-    (reset! server
-            (serve (get-handler)
-                   {:port port
-                    :init init
-                    :auto-reload? true
-                    :destroy destroy
-                    :join true}))
-    (println (str "You can view the site at http://localhost:" port))))
-
-(defn stop-server []
-  (.stop @server)
-  (reset! server nil))


:admin-email is not used anymore

:admin-email is not used anymore

--- src/freecoin/core.clj
+++ src/freecoin/core.clj
@@ -187,8 +187,7 @@
                                  (select-keys stores-m [:account-store :password-recovery-store])
                                  account-activator password-recoverer
                                  {:hash-fn buddy.hashers/derive :hash-check-fn buddy.hashers/check})
-            server             (-> (create-app (assoc config-m
-                                                      :admin-email "aspra@dyne.org") stores-m blockchain email-authenticator)
+            server             (-> (create-app config-m stores-m blockchain email-authenticator)
                                    (server/run-server {:port (config/port config-m)
                                                        :host (config/host config-m)}))]
         (assoc app-state


Make web/-main more repl friendly.

Make web/-main more repl friendly.

--- src/demo/web.clj
+++ src/demo/web.clj
@@ -21,10 +21,11 @@
   [& {:as args}]

   ;; this uses an Undertow handler by default, which is faster than a servlet
-  (web/run echo-request args)
+  (web/run echo-request)

   ;; using a servlet allows the session to be shared in a WildFly
   ;; cluster and allow access to the session from websockets
   (web/run
     (javax/create-servlet #'counter)
-    :path "/counter"))
+    :path "/counter")
+  )


Fix broken codes

Fix broken codes

--- src/googlica/core.clj
+++ src/googlica/core.clj
@@ -58,7 +58,7 @@
 (defn replace-path-vars [path-template]
   path-template)

-(defn generate-request [method]
+(defn generate-request [base-url method]
   {:method (-> method :httpMethod s/lower-case keyword)
    :url (str base-url (replace-path-vars (:path method)))})

@@ -67,4 +67,6 @@
   `(defn ~(generate-function-name method)
      ~(generate-docs method)
      ~(generate-args method)
-     (http/request ~(generate-request base-url method))))
+     (http/request ~(generate-request base-url method))))
+
+(generate-function-from-method base-url storage-object-get)


fix scrolling with wheel

fix scrolling with wheel

--- frontend/components/build_steps.cljs
+++ frontend/components/build_steps.cljs
@@ -186,7 +186,8 @@
           [:div#container_parent {:on-wheel (fn [e]
                                               (when (not= 0 (aget e "deltaX"))
                                                 (.preventDefault e)
-                                                (aset js/document.body "scrollTop" (+ (aget js/document.body "scrollTop") (aget e "deltaY")))))
+                                                (let [main (sel1 "main.app-main")]
+                                                  (set! (.-scrollTop main) (+ (.-scrollTop main) (.-deltaY e))))))
                                   :on-scroll (fn [e]
                                                ;; prevent handling scrolling if we're animating the
                                                ;; transition to a new selected container


Fixes per review.

Fixes per review.

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -33,8 +33,7 @@
           run-queued-secs (/ (build-model/run-queued-time build))]
       ;; more than 10 seconds waiting for other builds, and
       ;; less than 10 seconds waiting for additional containers (our fault)
-      (and (> usage-queued-secs 10)
-           (< run-queued-secs 10)))))
+      (< run-queued-secs 10 usage-queued-secs))))

 (defn additional-containers-offer [plan build]
   [:p#additional_containers_offer
@@ -51,7 +50,7 @@
      [:p (str "This build " run-phrase " under " (:org_name plan) "'s plan which provides " (plan-model/usable-containers plan)
               " containers, plus 3 additional containers available for free and open source projects.")]
      [:p [:a {:href (routes/v1-org-settings-subpage {:org (:org_name plan)
-                                                              :subpage "containers"})}
+                                                     :subpage "containers"})}
           [:button "Add Containers"]] "to run more builds concurrently."]]))

 (defn build-queue [data owner]


Fix assoc for TransientHashMap and added conj!

--- src/main/cljs/lean_map/core.cljs
+++ src/main/cljs/lean_map/core.cljs
@@ -263,7 +263,7 @@
                            ^:mutable root
                            ^:mutable count]
   Object
-  #_(conj! [tcoll o]
+  (conj! [tcoll o]
     (if edit
       (if (satisfies? IMapEntry o)
         (.assoc! tcoll (key o) (val o))
@@ -280,7 +280,7 @@
             node        (-> (if (nil? root)
                               (.-EMPTY BitmapIndexedNode)
                               root)
-                            (.inode-assoc nil edit 0 (hash k) k v changed?))]
+                            (.inode-assoc edit 0 (hash k) k v changed?))]
         (if (identical? node root)
           nil
           (set! root node))
@@ -302,7 +302,7 @@
       (throw (js/Error. "count after persistent!"))))

   ITransientCollection
-  (-conj! [tcoll val] #_(.conj! tcoll val))
+  (-conj! [tcoll val] (.conj! tcoll val))

   (-persistent! [tcoll] (.persistent! tcoll))


fix generating docs against cljs master (close #133)

--- src/main/cljs_api_gen/result.clj
+++ src/main/cljs_api_gen/result.clj
@@ -16,6 +16,7 @@
                                     *treader-tag*
                                     *gclosure-lib*
                                     cljs-version->num
+                                    cljs-tag->num
                                     ]]
     ))

@@ -207,13 +208,16 @@
 (def version->num
   (memoize cljs-version->num))

+(def tag->num
+  (memoize cljs-tag->num))
+
 (defn add-cljsdoc
   "Merge the given item with its compiled cljsdoc, containing extra doc info."
-  [item curr-version]
+  [item curr-tag]
   (let [cljsdoc (and cljsdoc-map (@cljsdoc-map (:full-name item)))
         doc-version (last (filter #(or (nil? %)
                                        (<= (version->num %)
-                                           (version->num curr-version)))
+                                           (tag->num curr-tag)))
                                   (:versions cljsdoc)))
         doc (get-in cljsdoc [:docs doc-version])]
     (cond-> item
@@ -224,6 +228,6 @@

 (defn add-cljsdoc-to-result
   [result]
-  (let [version (-> result :release :cljs-version)
-        update-symbols (fn [symbols] (mapmap #(add-cljsdoc % version) symbols))]
+  (let [tag (-> result :release :cljs-tag)
+        update-symbols (fn [symbols] (mapmap #(add-cljsdoc % tag) symbols))]
     (update-in result [:symbols] update-symbols)))


validate-plan

validate-plan

--- src/icecap/schema.clj
+++ src/icecap/schema.clj
@@ -46,3 +46,7 @@
      map? Step
      vector? (with-two-or-more [Plan])
      set? (with-two-or-more #{Plan}))))
+
+(defn validate-plan
+  [maybe-plan]
+  (s/validate Plan maybe-plan))


add misaki.config doc

add misaki.config doc

--- src/misaki/config.clj
+++ src/misaki/config.clj
@@ -83,7 +83,7 @@
 ; =config-file?
 (defn config-file?
   "Check whether file is config file or not."
-  [file]
+  [#^File file]
   (= *config-file* (.getName file)))

 ; =layout-file?
@@ -106,14 +106,14 @@

       File<aa/bb/cc/template/index.clj>
       ;=> template/index.clj"
-  [file]
+  [#^File file]
   (last (str/split (.getAbsolutePath file)
                    (re-pattern *template-dir*))))

 ; =template-name->file
 (defn template-name->file
   "Convert template name to java.io.File"
-  [tmpl-name]
+  [#^String tmpl-name]
   (io/file (str *template-dir* tmpl-name)))

 ;; ## Filename Date Utility
@@ -139,7 +139,7 @@
 ; =remove-date-from-name
 (defn remove-date-from-name
   "Remove date string from filename"
-  [filename]
+  [#^String filename]
   (last (first (re-seq *post-filename-regexp* filename))))

 ;; ## Filename and URL generater
@@ -147,13 +147,13 @@
 ; =make-tag-output-filename
 (defn make-tag-output-filename
   "Make tag output filename from tag name"
-  [tag-name]
+  [#^String tag-name]
   (str *tag-out-dir* tag-name ".html"))

 ; =make-template-outpu-filename
 (defn make-template-output-filename
   "Make template output filename from template name"
-  [tmpl-name]
+  [#^String tmpl-name]
   (let [file (template-name->file tmpl-name)
         date (get-date-from-file file)
         filename (-?> tmpl-name remove-date-from-name delete-extension)]
@@ -173,6 +173,7 @@

 ; =make-layout-filename
 (defn make-layout-filename
-  [layout-name]
+  "Make layout filename from layout name(String)"
+  [#^String layout-name]
   (str *layout-dir* layout-name ".clj"))


Added a fn push-pixels that pushes pixel vectors to the FadeCandy server

--- src/sparkle/fadecandy_opc.clj
+++ src/sparkle/fadecandy_opc.clj
@@ -32,6 +32,13 @@
     :length :short-be
     :pixels (b/repeated color)))

-(def put-pixels [pixels]
-  )
+(defn push-pixels [pixels]
+  "Takes a vector of pixels, packages them into a set-color
+   packet, and pushes them to the FadeCandy device."
+  (let [pixel-byte-count (* 3 (count pixels))]
+    (b/encode set-color-packet @fc-conn
+      {:channel-num 0
+       :command 0
+       :length pixel-byte-count
+       :pixels pixels})))


CMR-5195 updates default variable version.

--- src/cmr/metadata/proxy/concepts/variable.clj
+++ src/cmr/metadata/proxy/concepts/variable.clj
@@ -16,7 +16,7 @@
 ;; XXX We can pull this from configuration once async-get-metadata function
 ;;     signatures get updated to accept the system data structure as an arg.
 (def variables-api-path "/variables")
-(def pinned-variable-schema-version "1.2")
+(def pinned-variable-schema-version "1.3")
 (def results-content-type "application/vnd.nasa.cmr.umm_results+json")
 (def charset "charset=utf-8")
 (def accept-format "%s; version=%s; %s")


make optional keys nilable

make optional keys nilable

--- src/ostatus/types.clj
+++ src/ostatus/types.clj
@@ -24,7 +24,6 @@

 (defn- gen-expand-impl
   [argname typename gen-map ks]
-  (prn gen-map)
   `(~(symbol (format "->%s" (name typename)))
     ~@(for [k ks]
         (let [k (keyword (name k))]
@@ -51,13 +50,15 @@
                   xp-keys)]
     `(do
       ~@(map (fn [k v] `(def ~k ~v)) genkeys genvals)
+      ;; HACK: make optional keys nilable
+      ~@(for [k (get specmap :opt [])]
+        `(sp/def ~k (sp/nilable (sp/get-spec ~k))))
       (sp/def ~specname (sp/keys ~@spec-spec))
       (defrecord ~(symbol (name nom)) ~(vec (map #(symbol (name %)) specvals))
         Expand
         (expand [~argsym]
-          (prn ~argsym)
           (let [~argsym ~(gen-expand-impl argsym nom (zipmap (map strip-ns xp-keys) genkeys) specvals)]
-            ;;(sp/assert ~specname ~argsym)
+            (sp/assert ~specname ~argsym)
             ~argsym))))))


Make notes bigger and move faster

Make notes bigger and move faster

--- src/playmary/one.cljs
+++ src/playmary/one.cljs
@@ -110,7 +110,7 @@
   {:piano-keys (into (sorted-map) (map-indexed (fn [i freq] [freq {:n i}])
                                                scale))
    :notes [] :w 0 :h 0 :sound-ready false
-   :px-per-ms 0.01
+   :px-per-ms 0.04
    :start (.getTime (js/Date.))
    :playhead (.getTime (js/Date.))})


Show notes that have been played

Show notes that have been played

--- src/playmary/one.cljs
+++ src/playmary/one.cljs
@@ -8,16 +8,16 @@

 (def timbre js/T)

-(def colors [{:light "#6DA0CB" :dark "#000000"}
-             {:light "#A76AB9" :dark "#2E2E2E"}
-             {:light "#BB67A2" :dark "#525252"}
-             {:light "#C55D83" :dark "#818181"}
-             {:light "#D35E4C" :dark "#AAAAAA"}
-             {:light "#E18C43" :dark "#D7D7D7"}
-             {:light "#E1B040" :dark "#FFFFFF"}])
+(def colors [{:note "#676767" :light "#6DA0CB" :dark "#000000"}
+             {:note "#929292" :light "#A76AB9" :dark "#1E1E1E"}
+             {:note "#B9B9B9" :light "#BB67A2" :dark "#3D3D3D"}
+             {:note "#DCDCDC" :light "#C55D83" :dark "#5C5C5C"}
+             {:note "#FFFFFF" :light "#D35E4C" :dark "#7A7A7A"}
+             {:note "#000000" :light "#E18C43" :dark "#999999"}
+             {:note "#393939" :light "#E1B040" :dark "#B9B9B9"}])

 (defn piano-key-width
-  [piano-keys w]
+  [{piano-keys :piano-keys w :w}]
   (.round js/Math (/ w (count piano-keys))))

 (defn latest-note
@@ -25,23 +25,85 @@
   (util/find-first (fn [note] (= freq (-> note :freq)))
                    (-> instrument :notes)))

-(defn draw-instrument [draw-ctx instrument]
-  (let [{w :w h :h} instrument
-        freqs (-> instrument :piano-keys keys)
-        piano-key-w (piano-key-width (:piano-keys instrument) w)]
-    (.clearRect draw-ctx 0 0 w h)
+(defn t->px
+  [{start :start px-per-ms :px-per-ms} t]
+  (* px-per-ms (- t start)))
+
+(defn note-rect
+  [{on :on off :off freq :freq :as note}
+   {px-per-ms :px-per-ms playhead :playhead :as instrument}]
+  (let [piano-key-w (piano-key-width instrument)
+        note-w 4
+        note-left (* piano-key-w (util/index-of (-> instrument :piano-keys keys) freq))]
+    {:x (- (+ note-left (/ piano-key-w 2))
+           (/ note-w 2))
+     :y (+ (t->px instrument on)
+           (/ (-> instrument :h) 2))
+     :w note-w
+     :h (- (t->px instrument (or off playhead))
+           (t->px instrument on))}))
+
+(defn screen-rect
+  [{w :w h :h playhead :playhead :as instrument}]
+  {:x 0 :y (t->px instrument playhead) :w w :h h})
+
+(defn color-set
+  [instrument freq]
+  (nth colors (mod (util/index-of (-> instrument :piano-keys keys) freq)
+                   (count colors))))
+
+(defn draw-note
+  [draw-ctx instrument note]
+  (let [{x :x y :y w :w h :h} (note-rect note instrument)]
+    (set! (.-fillStyle draw-ctx) "white")
+    (.fillRect draw-ctx x y w h)))
+
+(defn colliding?
+  [r1 r2]
+  (not (or (< (+ (:x r1) (:w r1)) (:x r2))
+           (< (+ (:y r1) (:h r1)) (:y r2))
+           (> (:x r1) (+ (:x r2) (:w r2)))
+           (> (:y r1) (+ (:y r2) (:h r2))))))
+
+(defn on-screen?
+  [instrument note]
+  (colliding? (note-rect note instrument)
+              (screen-rect instrument)))
+
+(defn draw-notes
+  [draw-ctx instrument]
+  (dorun (map (partial draw-note draw-ctx instrument)
+              (filter (partial on-screen? instrument)
+                      (-> instrument :notes)))))
+
+(defn draw-piano-keys
+  [draw-ctx {w :w h :h playhead :playhead :as instrument}]
+  (let [freqs (-> instrument :piano-keys keys)
+        piano-key-w (piano-key-width instrument)]
     (dotimes [n (count freqs)]
-      (let [note (latest-note instrument (nth freqs n))
+      (let [freq (nth freqs n)
+            note (latest-note instrument freq)
             piano-key-on (and note (-> note :off nil?))]
         (set! (.-fillStyle draw-ctx)
-              ((if piano-key-on :light :dark)
-               (nth colors (mod n (count colors)))))
-        (.fillRect draw-ctx (* n piano-key-w) 0 piano-key-w h)))))
+              ((if piano-key-on :light :dark) (color-set instrument freq)))
+        (.fillRect draw-ctx
+                   (* n piano-key-w)
+                   (t->px instrument playhead)
+                   piano-key-w h)))))
+
+(defn draw-instrument
+  [draw-ctx {w :w h :h playhead :playhead :as instrument}]
+  (.save draw-ctx)
+  (.translate draw-ctx 0 (-> (t->px instrument playhead) -))
+  (.clearRect draw-ctx 0 0 w h)
+  (draw-piano-keys draw-ctx instrument)
+  (draw-notes draw-ctx instrument)
+  (.restore draw-ctx))

 (defn touch->note
-  [x w scale]
-  (let [note-index (.floor js/Math (/ x (piano-key-width scale w)))]
-    (nth scale note-index)))
+  [x instrument]
+  (let [note-index (.floor js/Math (/ x (piano-key-width instrument)))]
+    (nth (-> instrument :piano-keys keys) note-index)))

 (defn create-note-synth
   [freq]
@@ -53,7 +115,10 @@
   [scale]
   {:piano-keys (into (sorted-map) (map (fn [freq] [freq {}])
                                        scale))
-   :notes [] :w 0 :h 0 :sound-ready false})
+   :notes [] :w 0 :h 0 :sound-ready false
+   :px-per-ms 0.01
+   :start (.getTime (js/Date.))
+   :playhead (.getTime (js/Date.))})

 (defn add-synths-to-instrument
   [instrument]
@@ -61,9 +126,6 @@
                  instrument
                  (-> instrument :piano-keys keys))
     :sound-ready true))
-
-(defn audio-time []
-  (.-currentTime js/audioCtx))

 (defn touch-data->touches [touch-data]
   (let [event (.-event_ touch-data)
@@ -77,8 +139,7 @@
 (defn touch->freq
   [instrument touch]
   (touch->note (get touch :clientX)
-               (:w instrument)
-               (keys (:piano-keys instrument))))
+               instrument))

 (def instrument-fns
   {"touchstart" (fn
@@ -138,7 +199,7 @@
    (let [draw-ctx (util/get-ctx canvas-id)]
      (util/set-canvas-size! canvas-id (util/get-window-size))
      (loop [instrument nil]
-       (let [[data c] (alts! [c-instrument (timeout 30)])]
+       (let [[data c] (alts! [c-instrument (timeout 16)])]
          (condp = c
            c-instrument (recur data)
            (do (draw-instrument draw-ctx instrument)
@@ -147,8 +208,9 @@
   (go
    (loop [instrument (update-size (create-instrument (scales/c-minor)) canvas-id)]
      (>! c-instrument instrument)
-     (let [[data c] (alts! [c-touch c-orientation-change])]
+     (let [[data c] (alts! [c-touch c-orientation-change (timeout 16)])]
        (condp = c
          c-orientation-change (recur (update-size instrument canvas-id))
-         c-touch (recur (fire-touch-data-on-instrument instrument data))))))
+         c-touch (recur (fire-touch-data-on-instrument instrument data))
+         (recur (assoc instrument :playhead (.getTime (js/Date.))))))))
   )


Rename non-rebinding vars.

Rename non-rebinding vars.

--- src/postal/stress.clj
+++ src/postal/stress.clj
@@ -7,15 +7,12 @@

 (def DATEFORMAT (SimpleDateFormat. "yyyy-MM-dd.HH:mm:ss"))

-(def *from* "foo@lolz.dom")
-(def *to* "bar@lolz.dom")
-
-(defonce *counter* (atom 0))
+(defonce counter (atom 0))

 (defn reset-counter! []
-  (reset! *counter* 0))
+  (reset! counter 0))

-(def *logger* (agent nil))
+(def logger (agent nil))

 (defn log* [x s]
   (let [s* (format "%s %s"
@@ -26,7 +23,7 @@
     s*))

 (defn log [& s]
-  (send-off *logger* log* s))
+  (send-off logger log* s))

 (defn partition-work
   "Break up total number of messages evenly over desired number of threads."
@@ -51,7 +48,7 @@
      (let [date (.format DATEFORMAT (Date.))]
        (dotimes [x n]
          (smtp-send host port (make-fixture from to))
-         (swap! *counter* inc)
+         (swap! counter inc)
          (Thread/sleep delay))
        n))
   ([host port from to n delay threads]
@@ -63,4 +60,4 @@
                          ct))
                      (partition-work n threads)))]
        (.await latch)
-       (reduce #(+ %1 (deref %2)) 0 res))))+       (reduce #(+ %1 (deref %2)) 0 res))))


Pass children to lifecycle method functions

--- src/re_view/core.cljs
+++ src/re_view/core.cljs
@@ -21,13 +21,6 @@
   "Return camelCased string, eg. hello-there to helloThere. Does not modify existing case."
   [s]
   (clojure.string/replace s #"-(.)" (fn [[_ match]] (clojure.string/upper-case match))))
-
-(defn ref
-  "[deprecated - no longer supported by React]
-  Returns the component associated with a component's React ref."
-  [component name]
-  (.warn js/console "Should not be calling 'ref'" name)
-  #_(some-> (aget component "refs") (aget name)))

 (defn dom-node
   "Return DOM node for component"
@@ -107,10 +100,19 @@
     (:initial-state
       :key
       :constructor) f
-    (:will-mount :will-unmount :will-receive-state :will-receive-props :will-update)
-    (fn [& args]
+    :will-receive-props
+    (fn [props]
       (binding [*trigger-state-render* false]
-        (this-as this (apply f this args))))
+        (this-as this (f this props))))
+    (:will-mount :will-unmount :will-receive-state :will-update)
+    (fn []
+      (binding [*trigger-state-render* false]
+        (this-as this
+          (apply f this (get this :view/children)))))
+    (:did-mount :did-update)
+    (fn []
+      (this-as this
+        (apply f this (get this :view/children))))
     (if (fn? f)
       (fn [& args]
         (this-as this
@@ -195,17 +197,7 @@
                                  (= "view" (namespace k))
                                  (camelCase (name k)))]
          (aget this "re$view" re-view-var)
-         (get (aget this "re$view" "props") k not-found))))
-
-    ISwap
-    (-swap!
-      ([this f] (.error js/console "[deprecated calling swap! directly on component - use :view/state atom]"))
-      ([this f a] (.error js/console "[deprecated calling swap! directly on component - use :view/state atom]"))
-      ([this f a b] (.error js/console "[deprecated calling swap! directly on component - use :view/state atom]"))
-      ([this f a b xs] (.error js/console "[deprecated calling swap! directly on component - use :view/state atom]")))
-
-    IReset
-    (-reset! [this v] (.error js/console "[deprecated reset! of component - use :view/state atom]"))))
+         (get (aget this "re$view" "props") k not-found))))))

 (defn swap-silently!
   "Swap state without causing component to re-render"


Move some type declaration vars on from bottom to top of dsl namespace.

--- src/suricatta/dsl.clj
+++ src/suricatta/dsl.clj
@@ -35,507 +35,6 @@
            org.jooq.util.mariadb.MariaDBDataType
            org.jooq.util.mysql.MySQLDataType
            suricatta.types.Context))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Protocols for constructors
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defprotocol IField
-  (field* [_] "Field constructor"))
-
-(defprotocol ISortField
-  (sort-field* [_] "Sort field constructor"))
-
-(defprotocol ITable
-  (table* [_] "Table constructor."))
-
-(defprotocol IName
-  (name* [_] "Name constructor (mainly used with CTE)"))
-
-(defprotocol ITableCoerce
-  (as-table* [_ params] "Table alias constructor"))
-
-(defprotocol IFieldCoerce
-  (as-field* [_ params] "Field alias constructor"))
-
-(defprotocol ICondition
-  (condition* [_] "Condition constructor"))
-
-(defprotocol IVal
-  (val* [_] "Val constructor"))
-
-(defprotocol IDeferred
-  "Protocol mainly defined for uniform unwrapping
-  deferred queries."
-  (unwrap* [_] "Unwrap the object"))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Protocol Implementations
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(extend-protocol IField
-  java.lang.String
-  (field* ^org.jooq.Field [^String s]
-    (DSL/field s))
-
-  clojure.lang.Keyword
-  (field* ^org.jooq.Field [kw]
-    (field* (clojure.core/name kw)))
-
-  org.jooq.Field
-  (field* ^org.jooq.Field [f] f)
-
-  org.jooq.impl.Val
-  (field* ^org.jooq.Field [v] v))
-
-(extend-protocol ISortField
-  java.lang.String
-  (sort-field* ^org.jooq.SortField [s]
-    (-> (DSL/field s)
-        (.asc)))
-
-  clojure.lang.Keyword
-  (sort-field* ^org.jooq.SortField [kw]
-    (sort-field* (clojure.core/name kw)))
-
-  org.jooq.Field
-  (sort-field* ^org.jooq.SortField [f] (.asc f))
-
-  org.jooq.SortField
-  (sort-field* ^org.jooq.SortField [v] v)
-
-  clojure.lang.PersistentVector
-  (sort-field* ^org.jooq.SortField [v]
-    (let [^org.jooq.Field field (field* (first v))
-          ^org.jooq.SortField field (case (second v)
-                                      :asc (.asc field)
-                                      :desc (.desc field))]
-      (if (= (count v) 3)
-        (case (first (drop 2 v))
-          :nulls-last (.nullsLast field)
-          :nulls-first (.nullsFirst field))
-        field))))
-
-(extend-protocol ITable
-  java.lang.String
-  (table* [s] (DSL/table s))
-
-  clojure.lang.Keyword
-  (table* [kw] (table* (clojure.core/name kw)))
-
-  org.jooq.Table
-  (table* [t] t)
-
-  org.jooq.TableLike
-  (table* [t] (.asTable t))
-
-  suricatta.types.Deferred
-  (table* [t] @t))
-
-(extend-protocol IName
-  java.lang.String
-  (name* [s]
-    (-> (into-array String [s])
-        (DSL/name)))
-
-  clojure.lang.Keyword
-  (name* [kw] (name* (clojure.core/name kw))))
-
-(extend-protocol ICondition
-  java.lang.String
-  (condition* [s] (DSL/condition s))
-
-  org.jooq.Condition
-  (condition* [c] c)
-
-  clojure.lang.PersistentVector
-  (condition* [v]
-    (let [sql    (first v)
-          params (rest v)]
-      (->> (map unwrap* params)
-           (into-array Object)
-           (DSL/condition sql)))))
-
-(extend-protocol IVal
-  Object
-  (val* [v] (DSL/val v)))
-
-(extend-protocol IFieldCoerce
-  org.jooq.FieldLike
-  (as-field* [n args]
-    (let [^String alias (first args)]
-      (.asField n alias)))
-
-  suricatta.types.Deferred
-  (as-field* [n args] (as-field* @n args)))
-
-(extend-protocol ITableCoerce
-  org.jooq.Name
-  (as-table* [^org.jooq.Name n args]
-    (.as n ^String (first args)))
-
-  org.jooq.DerivedColumnList
-  (as-table* [n args]
-    (.as n (first args)))
-
-  org.jooq.TableLike
-  (as-table* [n args]
-    (let [^String alias (first args)]
-      (->> (into-array String (rest args))
-           (.asTable n alias))))
-
-  suricatta.types.Deferred
-  (as-table* [t args]
-    (as-table* @t args)))
-
-(extend-protocol IDeferred
-  Object
-  (unwrap* [self]
-    (impl/wrap-if-need self))
-
-  suricatta.types.Deferred
-  (unwrap* [self]
-    (unwrap* @self)))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Common DSL functions
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defn as-table
-  "Coerce querypart to table expression."
-  [o & args]
-  (defer
-    (->> (map unwrap* args)
-         (as-table* o))))
-
-(defn as-field
-  "Coerce querypart to field expression."
-  [o & args]
-  (defer
-    (->> (map unwrap* args)
-         (as-field* o))))
-
-(defn field
-  "Create a field instance."
-  [data & [{:keys [alias] :as opts}]]
-  (defer
-    (let [f (field* data)]
-      (if alias
-        (.as f (clojure.core/name alias))
-        f))))
-
-(defn val
-  [v]
-  (val* v))
-
-(defn table
-  "Create a table instance."
-  [data & [{:keys [alias] :as opts}]]
-  (defer
-    (let [f (table* data)]
-      (if alias
-        (.as f (clojure.core/name alias))
-        f))))
-
-(defn select
-  "Start select statement."
-  [& fields]
-  (defer
-    (let [fields (map unwrap* fields)]
-      (cond
-       (instance? org.jooq.WithStep (first fields))
-       (.select (first fields)
-                (->> (map field* (rest fields))
-                     (into-array org.jooq.Field)))
-       :else
-       (->> (map field* fields)
-            (into-array org.jooq.Field)
-            (DSL/select))))))
-
-(defn select-distinct
-  "Start select statement."
-  [& fields]
-  (defer
-    (->> (map (comp field unwrap*) fields)
-         (into-array org.jooq.Field)
-         (DSL/selectDistinct))))
-
-(defn select-from
-  "Helper for create select * from

-  statement directly (without specify fields)"
-  [t]
-  (-> (table* t)
-      (DSL/selectFrom)))
-
-(defn select-count
-  []
-  (DSL/selectCount))
-
-(defn select-one
-  []
-  (defer (DSL/selectOne)))
-
-(defn select-zero
-  []
-  (DSL/selectZero))
-
-(defn from
-  "Creates from clause."
-  [f & tables]
-  (defer
-    (->> (map table* tables)
-         (into-array org.jooq.TableLike)
-         (.from @f))))
-
-(defn join
-  "Create join clause."
-  [q t]
-  (defer
-    (.join @q t)))
-
-(defn cross-join
-  [step tlike]
-  (defer
-    (let [t (table* (unwrap* tlike))
-          step (unwrap* step)]
-      (.crossJoin step t))))
-
-(defn full-outer-join
-  [step tlike]
-  (defer
-    (let [t (table* (unwrap* tlike))
-          step (unwrap* step)]
-      (.fullOuterJoin step t))))
-
-(defn left-outer-join
-  [step tlike]
-  (defer
-    (let [t (table* (unwrap* tlike))
-          step (unwrap* step)]
-      (.leftOuterJoin step t))))
-
-(defn right-outer-join
-  [step tlike]
-  (defer
-    (let [t (table* (unwrap* tlike))
-          step (unwrap* step)]
-      (.rightOuterJoin step t))))
-
-(defmulti on (comp class unwrap* first vector))
-
-(defmethod on org.jooq.SelectOnStep
-  [step & clauses]
-  (defer
-    (->> (map condition* clauses)
-         (into-array org.jooq.Condition)
-         (.on (unwrap* step)))))
-
-(defmethod on org.jooq.TableOnStep
-  [step & clauses]
-  (defer
-    (->> (map condition* clauses)
-         (into-array org.jooq.Condition)
-         (.on (unwrap* step)))))
-
-(defn where
-  "Create where clause with variable number
-  of conditions (that are implicitly combined
-  with `and` logical operator)."
-  [q & clauses]
-  (defer
-    (->> (map condition* clauses)
-         (into-array org.jooq.Condition)
-         (.where @q))))
-
-(defn exists
-  "Create an exists condition."
-  [select']
-  (defer
-    (DSL/exists select')))
-
-(defn group-by
-  [q & fields]
-  (defer
-    (->> (map (comp field* unwrap*) fields)
-         (into-array org.jooq.GroupField)
-         (.groupBy @q))))
-
-(defn having
-  "Create having clause with variable number
-  of conditions (that are implicitly combined
-  with `and` logical operator)."
-  [q & clauses]
-  (defer
-    (->> (map condition* clauses)
-         (into-array org.jooq.Condition)
-         (.having @q))))
-
-(defn order-by
-  [q & clauses]
-  (defer
-    (->> (map sort-field* clauses)
-         (into-array org.jooq.SortField)
-         (.orderBy @q))))
-
-(defn for-update
-  [q & fields]
-  (defer
-    (let [q (.forUpdate @q)]
-      (if (seq fields)
-        (->> (map field* fields)
-             (into-array org.jooq.Field)
-             (.of q))
-        q))))
-
-(defn limit
-  "Creates limit clause."
-  [q num]
-  (defer
-    (.limit @q num)))
-
-(defn offset
-  "Creates offset clause."
-  [q num]
-  (defer
-    (.offset @q num)))
-
-(defn union
-  [& clauses]
-  (defer
-    (reduce (fn [acc v] (.union acc @v))
-            (-> clauses first deref)
-            (-> clauses rest))))
-
-(defn union-all
-  [& clauses]
-  (defer
-    (reduce (fn [acc v] (.unionAll acc @v))
-            (-> clauses first deref)
-            (-> clauses rest))))
-
-(defn returning
-  [t & fields]
-  (defer
-    (if (= (count fields) 0)
-      (.returning @t)
-      (.returning @t (->> (map field* fields)
-                          (into-array org.jooq.Field))))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Logical operators (for conditions)
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defn and
-  "Logican operator `and`."
-  [& conditions]
-  (let [conditions (map condition* conditions)]
-    (reduce (fn [acc v] (.and acc v))
-            (first conditions)
-            (rest conditions))))
-
-(defn or
-  "Logican operator `or`."
-  [& conditions]
-  (let [conditions (map condition* conditions)]
-    (reduce (fn [acc v] (.or acc v))
-            (first conditions)
-            (rest conditions))))
-
-(defn not
-  "Negate a condition."
-  [c]
-  (DSL/not c))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Common Table Expresions
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defn name
-  [v]
-  (defer
-    (name* v)))
-
-(defn with
-  "Create a WITH clause"
-  [& tables]
-  (defer
-    (->> (map table* tables)
-         (into-array org.jooq.CommonTableExpression)
-         (DSL/with))))
-
-(defn with-fields
-  "Add a list of fields to this name to make this name a DerivedColumnList."
-  [n & fields]
-  (defer
-    (let [fields (->> (map clojure.core/name fields)
-                      (into-array String))]
-      (.fields @n fields))))
-
-(defmacro row
-  [& values]
-  `(DSL/row ~@(map (fn [x#] `(unwrap* ~x#)) values)))
-
-(defn values
-  [& rows]
-  (defer
-    (->> (into-array org.jooq.RowN rows)
-         (DSL/values))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Insert statement
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defn insert-into
-  [t]
-  (defer
-    (DSL/insertInto (table* t))))
-
-(defn insert-values
-  [t values]
-  (defer
-    (-> (fn [acc [k v]]
-          (.set acc (field* k) (unwrap* v)))
-        (reduce (unwrap* t) values)
-        (.newRecord))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Update statement
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defn update
-  "Returns empty UPDATE statement."
-  [t]
-  (defer
-    (DSL/update (table* t))))
-
-(defn set
-  "Attach values to the UPDATE statement."
-  ([t kv]
-   (defer
-     (let [t (unwrap* t)]
-       (reduce (fn [acc [k v]]
-                 (.set t (field* k) v))
-               t kv))))
-  ([t k v]
-   (defer
-     (let [v (unwrap* v)
-           t (unwrap* t)]
-       (if (instance? org.jooq.Row k)
-         (.set t k v)
-         (.set t (field* k) v))))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Delete statement
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defn delete
-  [t]
-  (defer
-    (DSL/delete (table* t))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; DDL
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (def ^{:doc "Datatypes translation map" :dynamic true}
   *datatypes*
@@ -612,34 +111,6 @@
    :mysql/timestamp MySQLDataType/TIMESTAMP
    :mysql/varchar MySQLDataType/VARCHAR})

-(defn truncate
-  [t]
-  (defer
-    (DSL/truncate (table* t))))
-
-(defn alter-table
-  "Creates new and empty alter table expression."
-  [name]
-  (defer
-    (-> (unwrap* name)
-        (table*)
-        (DSL/alterTable))))
-
-(defn create-table
-  [name]
-  (defer
-    (-> (unwrap* name)
-        (table*)
-        (DSL/createTable))))
-
-(defn drop-table
-  "Drop table statement constructor."
-  [t]
-  (defer
-    (DSL/dropTable (table* t))))
-
-;; Columns functions
-
 (defn- make-datatype
   [{:keys [type] :as opts}]
   (reduce (fn [dt [attname attvalue]]
@@ -651,6 +122,534 @@
           (get *datatypes* type)
           (into [] opts)))

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Protocols for constructors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defprotocol IField
+  (field* [_] "Field constructor"))
+
+(defprotocol ISortField
+  (sort-field* [_] "Sort field constructor"))
+
+(defprotocol ITable
+  (table* [_] "Table constructor."))
+
+(defprotocol IName
+  (name* [_] "Name constructor (mainly used with CTE)"))
+
+(defprotocol ITableCoerce
+  (as-table* [_ params] "Table alias constructor"))
+
+(defprotocol IFieldCoerce
+  (as-field* [_ params] "Field alias constructor"))
+
+(defprotocol ICondition
+  (condition* [_] "Condition constructor"))
+
+(defprotocol IVal
+  (val* [_] "Val constructor"))
+
+(defprotocol IDeferred
+  "Protocol mainly defined for uniform unwrapping
+  deferred queries."
+  (unwrap* [_] "Unwrap the object"))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Protocol Implementations
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(extend-protocol IField
+  java.lang.String
+  (field* ^org.jooq.Field [^String s]
+    (DSL/field s))
+
+  clojure.lang.Keyword
+  (field* ^org.jooq.Field [kw]
+    (field* (clojure.core/name kw)))
+
+  org.jooq.Field
+  (field* ^org.jooq.Field [f] f)
+
+  org.jooq.impl.Val
+  (field* ^org.jooq.Field [v] v))
+
+(extend-protocol ISortField
+  java.lang.String
+  (sort-field* ^org.jooq.SortField [s]
+    (-> (DSL/field s)
+        (.asc)))
+
+  clojure.lang.Keyword
+  (sort-field* ^org.jooq.SortField [kw]
+    (sort-field* (clojure.core/name kw)))
+
+  org.jooq.Field
+  (sort-field* ^org.jooq.SortField [f] (.asc f))
+
+  org.jooq.SortField
+  (sort-field* ^org.jooq.SortField [v] v)
+
+  clojure.lang.PersistentVector
+  (sort-field* ^org.jooq.SortField [v]
+    (let [^org.jooq.Field field (field* (first v))
+          ^org.jooq.SortField field (case (second v)
+                                      :asc (.asc field)
+                                      :desc (.desc field))]
+      (if (= (count v) 3)
+        (case (first (drop 2 v))
+          :nulls-last (.nullsLast field)
+          :nulls-first (.nullsFirst field))
+        field))))
+
+(extend-protocol ITable
+  java.lang.String
+  (table* [s] (DSL/table s))
+
+  clojure.lang.Keyword
+  (table* [kw] (table* (clojure.core/name kw)))
+
+  org.jooq.Table
+  (table* [t] t)
+
+  org.jooq.TableLike
+  (table* [t] (.asTable t))
+
+  suricatta.types.Deferred
+  (table* [t] @t))
+
+(extend-protocol IName
+  java.lang.String
+  (name* [s]
+    (-> (into-array String [s])
+        (DSL/name)))
+
+  clojure.lang.Keyword
+  (name* [kw] (name* (clojure.core/name kw))))
+
+(extend-protocol ICondition
+  java.lang.String
+  (condition* [s] (DSL/condition s))
+
+  org.jooq.Condition
+  (condition* [c] c)
+
+  clojure.lang.PersistentVector
+  (condition* [v]
+    (let [sql    (first v)
+          params (rest v)]
+      (->> (map unwrap* params)
+           (into-array Object)
+           (DSL/condition sql)))))
+
+(extend-protocol IVal
+  Object
+  (val* [v] (DSL/val v)))
+
+(extend-protocol IFieldCoerce
+  org.jooq.FieldLike
+  (as-field* [n args]
+    (let [^String alias (first args)]
+      (.asField n alias)))
+
+  suricatta.types.Deferred
+  (as-field* [n args] (as-field* @n args)))
+
+(extend-protocol ITableCoerce
+  org.jooq.Name
+  (as-table* [^org.jooq.Name n args]
+    (.as n ^String (first args)))
+
+  org.jooq.DerivedColumnList
+  (as-table* [n args]
+    (.as n (first args)))
+
+  org.jooq.TableLike
+  (as-table* [n args]
+    (let [^String alias (first args)]
+      (->> (into-array String (rest args))
+           (.asTable n alias))))
+
+  suricatta.types.Deferred
+  (as-table* [t args]
+    (as-table* @t args)))
+
+(extend-protocol IDeferred
+  Object
+  (unwrap* [self]
+    (impl/wrap-if-need self))
+
+  suricatta.types.Deferred
+  (unwrap* [self]
+    (unwrap* @self)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Common DSL functions
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn as-table
+  "Coerce querypart to table expression."
+  [o & args]
+  (defer
+    (->> (map unwrap* args)
+         (as-table* o))))
+
+(defn as-field
+  "Coerce querypart to field expression."
+  [o & args]
+  (defer
+    (->> (map unwrap* args)
+         (as-field* o))))
+
+(defn field
+  "Create a field instance."
+  [data & [{:keys [alias] :as opts}]]
+  (defer
+    (let [f (field* data)]
+      (if alias
+        (.as f (clojure.core/name alias))
+        f))))
+
+(defn val
+  [v]
+  (val* v))
+
+(defn table
+  "Create a table instance."
+  [data & [{:keys [alias] :as opts}]]
+  (defer
+    (let [f (table* data)]
+      (if alias
+        (.as f (clojure.core/name alias))
+        f))))
+
+(defn select
+  "Start select statement."
+  [& fields]
+  (defer
+    (let [fields (map unwrap* fields)]
+      (cond
+       (instance? org.jooq.WithStep (first fields))
+       (.select (first fields)
+                (->> (map field* (rest fields))
+                     (into-array org.jooq.Field)))
+       :else
+       (->> (map field* fields)
+            (into-array org.jooq.Field)
+            (DSL/select))))))
+
+(defn select-distinct
+  "Start select statement."
+  [& fields]
+  (defer
+    (->> (map (comp field unwrap*) fields)
+         (into-array org.jooq.Field)
+         (DSL/selectDistinct))))
+
+(defn select-from
+  "Helper for create select * from

+  statement directly (without specify fields)"
+  [t]
+  (-> (table* t)
+      (DSL/selectFrom)))
+
+(defn select-count
+  []
+  (DSL/selectCount))
+
+(defn select-one
+  []
+  (defer (DSL/selectOne)))
+
+(defn select-zero
+  []
+  (DSL/selectZero))
+
+(defn from
+  "Creates from clause."
+  [f & tables]
+  (defer
+    (->> (map table* tables)
+         (into-array org.jooq.TableLike)
+         (.from @f))))
+
+(defn join
+  "Create join clause."
+  [q t]
+  (defer
+    (.join @q t)))
+
+(defn cross-join
+  [step tlike]
+  (defer
+    (let [t (table* (unwrap* tlike))
+          step (unwrap* step)]
+      (.crossJoin step t))))
+
+(defn full-outer-join
+  [step tlike]
+  (defer
+    (let [t (table* (unwrap* tlike))
+          step (unwrap* step)]
+      (.fullOuterJoin step t))))
+
+(defn left-outer-join
+  [step tlike]
+  (defer
+    (let [t (table* (unwrap* tlike))
+          step (unwrap* step)]
+      (.leftOuterJoin step t))))
+
+(defn right-outer-join
+  [step tlike]
+  (defer
+    (let [t (table* (unwrap* tlike))
+          step (unwrap* step)]
+      (.rightOuterJoin step t))))
+
+(defmulti on (comp class unwrap* first vector))
+
+(defmethod on org.jooq.SelectOnStep
+  [step & clauses]
+  (defer
+    (->> (map condition* clauses)
+         (into-array org.jooq.Condition)
+         (.on (unwrap* step)))))
+
+(defmethod on org.jooq.TableOnStep
+  [step & clauses]
+  (defer
+    (->> (map condition* clauses)
+         (into-array org.jooq.Condition)
+         (.on (unwrap* step)))))
+
+(defn where
+  "Create where clause with variable number
+  of conditions (that are implicitly combined
+  with `and` logical operator)."
+  [q & clauses]
+  (defer
+    (->> (map condition* clauses)
+         (into-array org.jooq.Condition)
+         (.where @q))))
+
+(defn exists
+  "Create an exists condition."
+  [select']
+  (defer
+    (DSL/exists select')))
+
+(defn group-by
+  [q & fields]
+  (defer
+    (->> (map (comp field* unwrap*) fields)
+         (into-array org.jooq.GroupField)
+         (.groupBy @q))))
+
+(defn having
+  "Create having clause with variable number
+  of conditions (that are implicitly combined
+  with `and` logical operator)."
+  [q & clauses]
+  (defer
+    (->> (map condition* clauses)
+         (into-array org.jooq.Condition)
+         (.having @q))))
+
+(defn order-by
+  [q & clauses]
+  (defer
+    (->> (map sort-field* clauses)
+         (into-array org.jooq.SortField)
+         (.orderBy @q))))
+
+(defn for-update
+  [q & fields]
+  (defer
+    (let [q (.forUpdate @q)]
+      (if (seq fields)
+        (->> (map field* fields)
+             (into-array org.jooq.Field)
+             (.of q))
+        q))))
+
+(defn limit
+  "Creates limit clause."
+  [q num]
+  (defer
+    (.limit @q num)))
+
+(defn offset
+  "Creates offset clause."
+  [q num]
+  (defer
+    (.offset @q num)))
+
+(defn union
+  [& clauses]
+  (defer
+    (reduce (fn [acc v] (.union acc @v))
+            (-> clauses first deref)
+            (-> clauses rest))))
+
+(defn union-all
+  [& clauses]
+  (defer
+    (reduce (fn [acc v] (.unionAll acc @v))
+            (-> clauses first deref)
+            (-> clauses rest))))
+
+(defn returning
+  [t & fields]
+  (defer
+    (if (= (count fields) 0)
+      (.returning @t)
+      (.returning @t (->> (map field* fields)
+                          (into-array org.jooq.Field))))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Logical operators (for conditions)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn and
+  "Logican operator `and`."
+  [& conditions]
+  (let [conditions (map condition* conditions)]
+    (reduce (fn [acc v] (.and acc v))
+            (first conditions)
+            (rest conditions))))
+
+(defn or
+  "Logican operator `or`."
+  [& conditions]
+  (let [conditions (map condition* conditions)]
+    (reduce (fn [acc v] (.or acc v))
+            (first conditions)
+            (rest conditions))))
+
+(defn not
+  "Negate a condition."
+  [c]
+  (DSL/not c))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Common Table Expresions
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn name
+  [v]
+  (defer
+    (name* v)))
+
+(defn with
+  "Create a WITH clause"
+  [& tables]
+  (defer
+    (->> (map table* tables)
+         (into-array org.jooq.CommonTableExpression)
+         (DSL/with))))
+
+(defn with-fields
+  "Add a list of fields to this name to make this name a DerivedColumnList."
+  [n & fields]
+  (defer
+    (let [fields (->> (map clojure.core/name fields)
+                      (into-array String))]
+      (.fields @n fields))))
+
+(defmacro row
+  [& values]
+  `(DSL/row ~@(map (fn [x#] `(unwrap* ~x#)) values)))
+
+(defn values
+  [& rows]
+  (defer
+    (->> (into-array org.jooq.RowN rows)
+         (DSL/values))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Insert statement
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn insert-into
+  [t]
+  (defer
+    (DSL/insertInto (table* t))))
+
+(defn insert-values
+  [t values]
+  (defer
+    (-> (fn [acc [k v]]
+          (.set acc (field* k) (unwrap* v)))
+        (reduce (unwrap* t) values)
+        (.newRecord))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Update statement
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn update
+  "Returns empty UPDATE statement."
+  [t]
+  (defer
+    (DSL/update (table* t))))
+
+(defn set
+  "Attach values to the UPDATE statement."
+  ([t kv]
+   (defer
+     (let [t (unwrap* t)]
+       (reduce (fn [acc [k v]]
+                 (.set t (field* k) v))
+               t kv))))
+  ([t k v]
+   (defer
+     (let [v (unwrap* v)
+           t (unwrap* t)]
+       (if (instance? org.jooq.Row k)
+         (.set t k v)
+         (.set t (field* k) v))))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Delete statement
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn delete
+  [t]
+  (defer
+    (DSL/delete (table* t))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; DDL
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn truncate
+  [t]
+  (defer
+    (DSL/truncate (table* t))))
+
+(defn alter-table
+  "Creates new and empty alter table expression."
+  [name]
+  (defer
+    (-> (unwrap* name)
+        (table*)
+        (DSL/alterTable))))
+
+(defn create-table
+  [name]
+  (defer
+    (-> (unwrap* name)
+        (table*)
+        (DSL/createTable))))
+
+(defn drop-table
+  "Drop table statement constructor."
+  [t]
+  (defer
+    (DSL/dropTable (table* t))))
+
+;; Columns functions
 (defmulti add-column (comp class unwrap* first vector))

 (defmethod add-column org.jooq.AlterTableStep


give defhook defonce semantics so we don't lose any functions when reloading relevant namespace. Cleaner implementation of defhook macro

--- src/metabase/task.clj
+++ src/metabase/task.clj
@@ -44,10 +44,10 @@
   A hook is simply an atom storing a set of functions that you can run at any time with `run-hook`."
   [hook-name & [docstr?]]
   {:arglists '([hook-name docstr?])}
-  `(do (def ~hook-name
-            (atom #{}))
-       (alter-meta! #'~hook-name merge {:doc ~docstr?
-                                        :type ::hook})))
+  `(defonce ~(vary-meta hook-name
+                        :doc docstr?
+                        :type ::hook)
+     (atom #{})))

 ;; TODO Should we require that F be a var so as to avoid duplicate lambdas being added ?
 (defn add-hook!


Extract library loading from load-zmq-native

--- src/naughtmq/core.clj
+++ src/naughtmq/core.clj
@@ -69,6 +69,15 @@
         (log/error (str "Could not load native file: " s))
         (throw e)))))

+(defn- load-libraries
+  "Loads the native libraries."
+  []
+  (let [libs (get {"win"   ["msvcr100" "msvcp100" "libzmq" "jzmq"]
+                   "linux" ["libzmq" "libjzmq"]
+                   "mac"   ["libzmq.dylib" "libjzmq.dylib"]}
+                  (os))]
+    (doseq [l libs] (load-library l))))
+
 (defn load-zmq-native
   "Loads all required native libraries for using ZeroMQ on the current
   platform. This is done by first extracting the binaries from the JAR, then
@@ -76,10 +85,4 @@
   asking the JVM to load the native libraries there. This is done in the
   correct order, so that the JVM does not need to look at java.library.path."
   []
-  (let [libs (get {:win32 ["jzmq.dll" "libzmq.dll" "msvcp100.dll" "msvcr100.dll"]
-                   :win64 ["jzmq.dll" "libzmq.dll" "msvcp100.dll" "msvcr100.dll"]
-                   :linux32 ["libjzmq.so" "libzmq.so"]
-                   :linux64 ["libjzmq.so" "libzmq.so"]
-                   :mac ["libjzmq.dylib" "libzmq.dylib"]}
-                  (platform))]
-    (doseq [l libs] (load-library l))))
+  (load-libraries))


vertex collection

vertex collection

--- src/ophion/search.clj
+++ src/ophion/search.clj
@@ -116,7 +116,7 @@
         agg (mapv (partial multi-aggregation query) terms)
         queries (conj agg (multi-from query size from))
         lines (mapcat list (repeat in) queries)
-        url (elastic/multi-search-url connection index lines)
+        url (elastic/multi-search-url connection index "vertex")
         response (elastic-get connection url lines)]
     (:responses response)))


minor refactoring

minor refactoring

--- cljs/src/main/plastic/main/editor/render/code.cljs
+++ cljs/src/main/plastic/main/editor/render/code.cljs
@@ -6,8 +6,6 @@
             [plastic.main.frame :refer [subscribe]]
             [plastic.util.helpers :as helpers]
             [plastic.main.editor.toolkit.id :as id]))
-
-(declare code-block-component)

 (defn code-token-component
   "A reagent component responsible for rendering a singe code token.
@@ -56,20 +54,22 @@
              [inline-editor-component id]
              [raw-html-component (gen-html)])])))))

+(declare code-block-component)
+
 (defn emit-code-block [editor-id form-id node-id]
   ^{:key node-id} [code-block-component editor-id form-id node-id])

-(defn code-elements-row [emit hints items]
-  (let [row (map emit items)]
+(defn code-elements-row [emitter hints items]
+  (let [row (map emitter items)]
     (if (:indent? hints)
       (cons [:div.indent] row)
       row)))

-(defn code-elements-layout [emit [desc & lines]]
+(defn code-elements-layout [emitter [desc & lines]]
   (if (:oneliner? desc)
     [:div.elements
      (let [[hints & line-items] (first lines)]
-       (code-elements-row emit hints line-items))]
+       (code-elements-row emitter hints line-items))]
     [:table.elements
      [:tbody
       (for [[index [hints & line-items]] (helpers/indexed-iteration lines)]
@@ -78,10 +78,10 @@
                                            [[(first line-items) (second line-items)] (drop 2 line-items)]
                                            [[(first line-items)] (rest line-items)])]
             ^{:key index} [:tr
-                           [:td (code-elements-row emit hints left-items)]
-                           [:td (code-elements-row emit {} right-items)]])
+                           [:td (code-elements-row emitter hints left-items)]
+                           [:td (code-elements-row emitter {} right-items)]])
           ^{:key index} [:tr
-                         [:td {:col-span 2} (code-elements-row emit hints line-items)]]))]]))
+                         [:td {:col-span 2} (code-elements-row emitter hints line-items)]]))]]))

 (defn code-element-component [_editor-id _form-id _node-id _layout]
   (fn [editor-id form-id node-id layout]


feat(replay): idempotent geoserver proj [PDOK-2291]

For new features the insert query has a check if the id already exists. Other event types already were idempotent (update again, or delete again is ok)

--- src/main/clojure/pdok/featured/geoserver.clj
+++ src/main/clojure/pdok/featured/geoserver.clj
@@ -1,5 +1,5 @@
 (ns pdok.featured.geoserver
-  (:require [pdok.featured.projectors :as proj]
+  (:require [pdok.featured.projectors :as proj]
             [pdok.cache :refer :all]
             [pdok.featured.feature :as f :refer [as-jts]]
             [pdok.postgres :as pg]
@@ -19,7 +19,7 @@
       (recur (conj! target x) (first xs) (rest xs)))))

-(defn do-visualization? [options]
+(defn do-visualization? [options]
   (if (some #{"visualization"} options) true))

 (defn- gs-dataset-exists? [db dataset]
@@ -85,7 +85,8 @@
                             (when (= :line geo-group)  geometry)
                             (when (= :polygon geo-group)  geometry)
                             geo-group]
-                           sparse-attributes)]
+                           sparse-attributes
+                           [id])]
         record))))

 (defn- feature-keys [feature]
@@ -117,22 +118,26 @@
 (defn- geo-column [geo-group]
    (str "_geometry_" (name geo-group)))

+(defn gs-insert-sql [schema table columns]
+  (str "INSERT INTO " (pg/quoted schema) "." (pg/quoted table)
+       " ("  (str/join "," (map #(pg/quoted (name %)) columns)) ")"
+       " SELECT " (str/join "," (repeat (count columns) "?"))
+       " WHERE NOT EXISTS (SELECT 1 FROM " (pg/quoted schema) "." (pg/quoted table) " WHERE _id = ?)" ))
+
 (defn- gs-add-feature
   ([db proj-fn all-attributes-fn features]
    (try
      (let [selector (juxt :dataset :collection)
            per-dataset-collection (group-by selector features)]
         (doseq [[[dataset collection] grouped-features] per-dataset-collection]
-         (j/with-db-connection [c db]
-           (let [all-attributes (all-attributes-fn dataset collection)
-                 records (filter (comp not nil?)
-                                 (map #(feature-to-sparse-record proj-fn % (all-fields-constructor all-attributes)) grouped-features))]
-              (if (not (empty? records))
-                (let [fields (concat [:_id :_version :_geometry_point :_geometry_line :_geometry_polygon :_geo_group]
-                                   (map pg/quoted all-attributes))
-                      table collection]
-                  (apply (partial j/insert! c (str dataset "." (pg/quoted table)) fields)
-                       records)))))))
+         (let [all-attributes (all-attributes-fn dataset collection)
+               records (filter (comp not nil?)
+                               (map #(feature-to-sparse-record proj-fn % (all-fields-constructor all-attributes)) grouped-features))]
+           (if (not (empty? records))
+             (let [fields (concat [:_id :_version :_geometry_point :_geometry_line :_geometry_polygon :_geo_group]
+                                  all-attributes)
+                   sql (gs-insert-sql dataset collection fields)]
+               (j/execute! db (cons sql records) :multi? true :transaction? false))))))
      (catch java.sql.SQLException e
        (log/with-logs ['pdok.featured.projectors :error :error] (j/print-sql-exception-chain e))))))


(EZ-15) Clean up leiningen.ezbake-core based on PR feedback.

--- src/leiningen/ezbake_core.clj
+++ src/leiningen/ezbake_core.clj
@@ -43,12 +43,12 @@
   TODO: Add configuration option to clone a git repository containing ezbake
   resources instead of pulling them from the lein-ezbake jar."
   [project]
-  (let [template-type (-> (:lein-ezbake project)
-                          (get :templates)
-                          (get :type))]
+  (let [template-type (get-in project [:lein-project
+                                       :templates
+                                       :type]
+                              :jar-resource)]
     (case template-type
       :git-resource (throw (RuntimeException.
                              (format "Resource type, %s, not implemented."
                                      (str template-type))))
-      :jar-resource (copy-jar-resources core/resource-prefix core/resource-path)
-      (copy-jar-resources core/resource-prefix core/resource-path))))
+      :jar-resource (copy-jar-resources core/resource-prefix core/resource-path))))


Add bang to function

Add bang to function

--- src/play_clj/core.clj
+++ src/play_clj/core.clj
@@ -26,12 +26,12 @@
          on-pause dummy on-resize dummy on-resume dummy}}]
   (let [screen (atom {})
         entities (atom '())
-        execute (fn [func screen-map]
-                  (some->> (func screen-map @entities)
-                           list
-                           flatten
-                           (remove nil?)
-                           (reset! entities)))
+        execute-fn! (fn [func screen-map]
+                      (some->> (func screen-map @entities)
+                               list
+                               flatten
+                               (remove nil?)
+                               (reset! entities)))
         create-renderer-fn! #(swap! screen assoc :renderer (renderer %))
         create-camera-fn! #(swap! screen assoc :camera (camera %))]
     (proxy [Screen] []
@@ -41,17 +41,17 @@
                     :delta-time 0
                     :create-renderer create-renderer-fn!
                     :create-camera create-camera-fn!)
-             (execute on-show)))
+             (execute-fn! on-show)))
       (render [delta-time]
         (->> (swap! screen (fn [val]
                              (assoc val
                                     :total-time (+ (:total-time val) delta-time)
                                     :delta-time delta-time)))
-             (execute on-render)))
-      (hide [] (execute on-hide @screen))
-      (pause [] (execute on-pause @screen))
-      (resize [w h] (execute on-resize @screen))
-      (resume [] (execute on-resume @screen)))))
+             (execute-fn! on-render)))
+      (hide [] (execute-fn! on-hide @screen))
+      (pause [] (execute-fn! on-pause @screen))
+      (resize [w h] (execute-fn! on-resize @screen))
+      (resume [] (execute-fn! on-resume @screen)))))

 (defmacro defscreen
   [n & {:keys [] :as options}]


(maint) don't duplicate CTE for inactive nodes

Only apply the CTE to non-subqueries.

--- src/puppetlabs/puppetdb/query_eng/engine.clj
+++ src/puppetlabs/puppetdb/query_eng/engine.clj
@@ -1124,7 +1124,7 @@

 (defn honeysql-from-query
   "Convert a query to honeysql format"
-  [{:keys [projected-fields group-by call selection projections entity]}]
+  [{:keys [projected-fields group-by call selection projections entity subquery?]}]
   (let [fs (seq (map (comp hcore/raw :statement) call))
         select (if (and fs
                         (empty? projected-fields))
@@ -1134,9 +1134,8 @@
                                    (mapv (fn [[name {:keys [field]}]]
                                            [field name])))
                               fs)))
-        new-selection (-> selection
+        new-selection (-> (cond-> selection (not subquery?) wrap-with-inactive-nodes-cte)
                           (assoc :select select)
-                          wrap-with-inactive-nodes-cte
                           (cond-> group-by (assoc :group-by group-by)))]
     (log/spy new-selection)))


Modifications to Clojure day 5 solution.


Use real separate thread for handling each scenario in simulation.

This way it is guaranteed that all scenarios start roughly at a same time.
Internally scenario is run using asynchronous go blocks.


Update TODO comment.

Update TODO comment.

--- src/posthere/capture_request.clj
+++ src/posthere/capture_request.clj
@@ -110,6 +110,7 @@

 ;; TODO slurp is naive and will run out of memory on a large input stream
+;; TODO placeholder code, refactor this
 (defn- limit-body-request-size
   ""
   [request]


Add date & time functions using in text example.

--- src/quil_cljs_examples/text.cljs
+++ src/quil_cljs_examples/text.cljs
@@ -5,7 +5,9 @@
 (defn draw []
 	(q/background 255)
 	(q/fill 0)
-	(q/text "hello world" 25 25))
+
+	(q/text (str (q/day) "." (q/month) "." (q/year) " " (q/hour) ":" (q/minute) ":" (q/seconds))
+		25 25))

 (defsketch text-example


[CS] Move and docstring ballot-responses fn

--- src/vip/data_processor/output/referendum.clj
+++ src/vip/data_processor/output/referendum.clj
@@ -1,6 +1,20 @@
 (ns vip.data-processor.output.referendum
   (:require [vip.data-processor.output.xml-helpers :refer :all]
             [korma.core :as korma]))
+
+(defn ballot-responses
+  "Find ballot responses belonging to a referendum. Goes through the
+  referendum_ballot_responses table to grab their `id` and
+  `sort_order` columns, which is all that's needed for the ballot
+  response's XML representation."
+  [ctx referendum]
+  (let [referendum-ballot-responses-table (get-in ctx [:tables :referendum-ballot-responses])
+        ballot-responses-table (get-in ctx [:tables :ballot-responses])]
+    (korma/select referendum-ballot-responses-table
+                  (korma/fields :ballot_responses.id :ballot_responses.sort_order)
+                  (korma/join ballot-responses-table
+                              (= :ballot_responses.id :ballot_response_id))
+                  (korma/where {:referendum_id (:id referendum)}))))

 (defn ballot-response->xml [ballot-response]
   (let [xml {:tag :ballot_response_id
@@ -31,15 +45,6 @@
                          (map ballot-response->xml ballot-responses))]
     (simple-xml :referendum id children)))

-(defn ballot-responses [ctx referendum]
-  (let [referendum-ballot-responses-table (get-in ctx [:tables :referendum-ballot-responses])
-        ballot-responses-table (get-in ctx [:tables :ballot-responses])]
-    (korma/select referendum-ballot-responses-table
-                  (korma/fields :ballot_responses.id :ballot_responses.sort_order)
-                  (korma/join ballot-responses-table
-                              (= :ballot_responses.id :ballot_response_id))
-                  (korma/where {:referendum_id (:id referendum)}))))
-
 (defn xml-nodes [ctx]
   (let [referendums-table (get-in ctx [:tables :referendums])
         referendums (korma/select referendums-table)]


add cache control headers

add cache control headers

--- src/vignette/http/middleware.clj
+++ src/vignette/http/middleware.clj
@@ -35,6 +35,8 @@
   (fn [request]
     (let [response (handler request)]
       (-> response
+          (header "Cache-Control" "public, s-maxage=604800")
+          (header "X-Pass-Cache-Control" "public, max-age=31536000")
           (header "Varnish-Logs" "vignette")
           (header "X-Served-By" hostname)
           (header "X-Cache" "ORIGIN")


fixed typo

fixed typo

--- clients/clojure/src/samsara/client.clj
+++ clients/clojure/src/samsara/client.clj
@@ -30,9 +30,9 @@
    :url - Samsara URL
    :sourceId - Unique ID for the client. This property is defaulted with an autogenerated value.
    :publish-interval - Frequency in seconds, in which the events will be flushed to samsara API.
-   :max_buffer_size - Max size of the events ring buffer.
+   :max-buffer-size - Max size of the events ring buffer.

-   NOTE: Changes to publish-interval and max_buffer_size properties will require a restart immediately
+   NOTE: Changes to publish-interval and max-buffer-size properties will require a restart immediately
    after the first call to record-event"
   (swap! samsara-config into config))


forked devtools should use :legacy-formatter

--- cljs/src/dev/plastic/dev/devtools.cljs
+++ cljs/src/dev/plastic/dev/devtools.cljs
@@ -1,4 +1,6 @@
 (ns plastic.dev.devtools
   (:require [devtools.core :as devtools]))

-(devtools/install!)+(devtools/set-pref! :legacy-formatter true)
+
+(devtools/install!)


delaney.clj: made minimal function work correctly with undefined m values

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -547,7 +547,8 @@
             pairs (fn [i] (for [D reps] [(emap D) (emap (pfind p (s ds i D)))]))
             ops (into {} (for [i idcs] [(imap i), (into {} (pairs i))]))
             t (DSymbol. (dim ds) (count reps) ops {})
-            spin (fn [i j D] (/ (m ds i j D) (r t (imap i) (imap j) (emap D))))
+            spin (fn [i j D]
+                   (/ (or (m ds i j D) 0) (r t (imap i) (imap j) (emap D))))
             spins (fn [i j] (for [D reps] [(emap D) (spin i j D)]))
             ipairs (zipmap idcs (rest idcs))
             vs (into {} (for [[i j] ipairs] [(imap i) (into {} (spins i j))]))]


delaney.clj: added definitions for (r) and (m)

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -115,6 +115,17 @@
    any step is undefined, nil is returned."
   (reduce #(s ds %2 %1) D idxs))

+(defn r [ds i j D]
+  (loop [n 1, E D]
+    (when-let [F (walk ds E i j)]
+      (if (= F D)
+        n
+        (recur (inc n) F)))))
+
+(defn m [ds i j D]
+  (let [v (v ds i j D), r (r ds i j D)]
+    (when (and v r) (* v r))))
+
 (defn chain-end [ds D i j]
   "Returns the result of alternately applying operators indexed i and j,
    starting with the element D, until the end of the chain is reached.


More flexible local part for prefixed names


rest with liberator

rest with liberator

--- rest-media-demo/src/rest_media_demo/handler.clj
+++ rest-media-demo/src/rest_media_demo/handler.clj
@@ -14,7 +14,7 @@
    "text/html"])

 (defmethod render-map-generic "application/json" [data context]
-  (json/write str (conj (:links data) (:properties data) )))
+  (json/write-str (conj (:links data) (:properties data) )))

 (defmethod render-map-generic "text/html" [data context]
   (html [:div
@@ -25,8 +25,41 @@

 (defrecord Coffee [name price])

+(def restretto
+  (->Coffee "Ristretto" "$1.80"))
+(def macchiato
+  (->Coffee "Macchiato" "$1.80"))
+(def latte
+  (->Coffee "Caffe Latte" "$3.20"))
+
+(def coffees [latte macchiato restretto])
+
+(defn index-data [ctx]
+  coffees)
+
+(defresource index
+  :allowed-methods [:options :get :post :delete]
+  :available-media-types default-media-types
+  :handle-ok index-data)
+
+(defresource coffe [id]
+  :allowed-methods [:options :get]
+  :available-media-types ["text/html" "application/json"]
+  :handle-ok (fn [_]
+               {:properties
+                (nth coffees (Integer/parseInt id))
+                :links [{:rel ["self"]
+                         :href (str "/coffees/" id)}
+                        {:rel ["listing"]
+                         :href "/coffees"}]}))
+
 (defroutes app-routes
-  (GET "/" [] "Hello World")
+  (OPTIONS "/" [] {:headers {"Allow:" "GET, POST, DELETE, OPTIONS"}})
+  (ANY "/" [] index)
+  (ANY "/coffees" [] index)
+  (OPTIONS "/coffees/:id" [] {:headers {"Allow:" "GET, OPTIONS"}})
+  (ANY "/coffees/:id" [id] (coffe id))
+  (route/resources "/")
   (route/not-found "Not Found"))

 (def app


Detail table triggered upon new data in master table

--- src-cljs/kixi/hecuba/main.cljs
+++ src-cljs/kixi/hecuba/main.cljs
@@ -100,10 +100,13 @@
       (go-loop []
                (when-let [data (<! in)]
                  (om/set-state! owner :data data)
+                 (put! out {:type :row-selected :row (first data)})
                  (recur))))

     om/IRender
     (render [_]
+      ;; Select the first row
+      ;;(put! out {:type :row-selected :row (first (om/get-state owner :data))})
       (dom/table #js {:className "table table-bordered table-hover table-striped hecuba-table"}
            (dom/thead nil
                 (dom/tr nil
@@ -122,7 +125,8 @@
                          (for [[k {:keys [href]}] cols]
                            (dom/td nil (if href
                                          (dom/a #js {:href (get row href)} (get row k))
-                                         (get row k)))))))))))))
+                                         (get row k))))))))))
+      )))

 (defmulti render-content-directive (fn [itemtype _ _] itemtype))


Refactoring the way the ghost-town event is recorded

--- src/amindblowingworld/civs.clj
+++ src/amindblowingworld/civs.clj
@@ -202,7 +202,10 @@
     (if pos
       (record-event (str "Population of " (.name s) " growing to " (.pop s)) (.pos s))
       (record-event (str "Population of " (.name s) " shrinking to " (.pop s)) (.pos s)))
-    (update-settlement s)))
+    (update-settlement s)
+    (when (= (.pop s) 0)
+      (update-biome-map)
+      (record-event (str "Village " (.name s) " is now a ghost town") (.pos s)))))

 (defn ghost-town? [settlement]
   (= 0 (.pop settlement)))
@@ -257,9 +260,7 @@
             (update-settlement-pop id-settlement new-pop)))
         (let [s (get-settlement id-settlement)]
           (when (and (< (.pop s) 70) (chance 0.35))
-            (update-settlement-pop id-settlement 0)
-            (update-biome-map)
-            (record-event (str "Village " (.name s) " is now a ghost town") (.pos s)))
+            (update-settlement-pop id-settlement 0))
           (when (and (> (.pop s) 500) (chance 0.15))
             (spawn-new-village-from id-settlement)
             (update-biome-map)


cleanup

cleanup

--- src/babel/english/lexicon.cljc
+++ src/babel/english/lexicon.cljc
@@ -11,8 +11,6 @@
                               subject-verb-agreement
                               transitivize]]
    [dag_unify.core :refer [dissoc-paths fail? get-in strip-refs unifyc]]))
-
-(declare edn2lexicon)

 (def lexicon-source
   {


add missing curly braces

add missing curly braces

--- src/babel/espanol/lexicon.cljc
+++ src/babel/espanol/lexicon.cljc
@@ -109,7 +109,7 @@
                         :sem {:pred :add}}}

    "apagar" {:synsem {:cat :verb
-                      :sem {:pred :turn-off}
+                      :sem {:pred :turn-off}}}

    "apoyar" {:synsem {:cat :verb
                       :sem {:pred :support}}}


thin disk format

thin disk format

--- src/vmware/vijava.clj
+++ src/vmware/vijava.clj
@@ -6,6 +6,7 @@
   (:import
     java.net.URL
     com.vmware.vim25.mo.InventoryNavigator
+    com.vmware.vim25.VirtualMachineRelocateTransformation
     com.vmware.vim25.mo.ServiceInstance
     com.vmware.vim25.VirtualMachineCloneSpec
     com.vmware.vim25.VirtualMachineRelocateSpec
@@ -41,10 +42,11 @@
   ([type name within] (.searchManagedEntity within type name)))

 (defn resource-pools [dcname]
-  (first (find-all "ResourcePool" (navigator (find* "Datacenter" dcname)))))
+  (find-all "ResourcePool" (navigator (find* "Datacenter" dcname))))

 (defn relocation-spec [dcname]
   (doto (VirtualMachineRelocateSpec.)
+    (.setTransform (VirtualMachineRelocateTransformation/sparse))
     (.setPool (.getMOR (first (resource-pools dcname))))))

 (defn clone-spec [dcname]
@@ -64,8 +66,7 @@
       (wait-for (.cloneVM_Task vm (.getParent vm) vmname (clone-spec dcname))))))

 (comment
-  (bean (.getGuest (first (list-vms (connect "https://192.168.5.23/sdk" "Administrator" "Oox1kai7")))))
-  (clone "ubuntu-13.04_puppet-3.1" "foo")
+  (clone "ubuntu-13.04_puppet-3.1" "foo" "playground")
   )


Fix possible peer deadlock when peer completes.

--- src/onyx/coordinator/impl.clj
+++ src/onyx/coordinator/impl.clj
@@ -179,9 +179,9 @@

         (when (and (zero? n) (not complete?))
           (release-waiting-nodes! sync (:task-node peer-state))
-          (complete-task sync (:task-node peer-state))
-          (extensions/write-node sync cooldown-node {:completed? true}))
+          (complete-task sync (:task-node peer-state)))

+        (extensions/write-node sync cooldown-node {:completed? complete?})
         {:n-peers n :peer-state peer-state})
       (do (extensions/write-node sync cooldown-node {:completed? true})
           {:n-peers n :peer-state peer-state}))))


add -i/--in-place option for editing file in place

--- src/nml/core.clj
+++ src/nml/core.clj
@@ -24,9 +24,10 @@
 ;; utility defns

 (defn fail [& lines]
-  (doseq [line lines]
-    (println line))
-  (System/exit 1))
+  (binding [*out* *err*]
+    (doseq [line lines]
+      (println line))
+    (System/exit 1)))

 (defn warn [& lines]
   (binding [*out* *err*]
@@ -122,14 +123,15 @@
                  :ws       ""
                  :wsopt    ""))))

-(defn nml-tree [fname]
-  (let [ioerr  (str "Could not open namelist file '" fname "'.")
-        result (try (parse (slurp fname)) (catch Exception e (fail ioerr)))
-        child  :nvseq
-        f      (fn [& v] (into [child] (nml-uniq v)))]
+(defn nml-tree [file]
+  (let [child  :nvseq
+        f      (fn [& v] (into [child] (nml-uniq v)))
+        result (try (parse (slurp file))
+                    (catch Exception e
+                      (fail (str "Could not read from file '" file "'."))))]
     (if (insta/failure? result)
       (let [{t :text l :line c :column} result]
-        (fail (str "Error parsing '" fname "' at line " l " column " c ":")
+        (fail (str "Error parsing '" file "' at line " l " column " c ":")
               t
               (str (apply str (repeat (- c 1) " ")) "^")))
       (insta/transform {child f} result))))
@@ -196,5 +198,10 @@
       (if (and (:in-place options) (not file)) (warn (msgs 0)))
       (if debug (println tree))
       (cond gets  (nml-gets tree gets (:no-prefix options))
-            sets  (println (string/trim (nml-str (nml-sets tree sets))))
+            sets  (let [out (string/trim (nml-str (nml-sets tree sets)))]
+                    (if (and file (:in-place options))
+                      (try (spit file out)
+                           (catch Exception e
+                             (fail (str "Could not write to file '" file "'."))))
+                      (println out)))
             :else (println (string/trim (nml-str tree)))))))


- Dont use the handler atom from the library

--- src/clj/gorilla_repl/route.clj
+++ src/clj/gorilla_repl/route.clj
@@ -35,8 +35,9 @@
    (route/files (str prefix "project-files") {:root "."})
    (route/not-found "Bummer, not found")])

+(def handler (atom cider/cider-handler #_cljs/cljs-handler))
 (def default-api-routes (create-api-routes "/"))
-(def default-repl-routes (create-repl-routes "/" (partial ws-relay/on-receive-mem #_cljs/cljs-handler cider/cider-handler)))
+(def default-repl-routes (create-repl-routes "/" (partial ws-relay/on-receive-mem handler)))
 (def remote-repl-routes (create-repl-routes "/" ws-relay/on-receive-net))
 (def default-resource-routes (create-resource-routes "/"))
 (def dev-routes (apply compojure/routes (concat default-api-routes


Make picard.core.buffer/to-buffer private

picard.core.buffer/buffer is the public entry point

--- src/clj/picard/core/buffer.clj
+++ src/clj/picard/core/buffer.clj
@@ -21,7 +21,7 @@

 (defprotocol Conversion
   (^{:private true} estimate [_])
-  (to-buffer [_]))
+  (^{:private true} to-buffer [_]))

 (extend-protocol Conversion
   (class (byte-array 0))


Added comment for base-point, removed unnecessary code in repl playground

--- src/clj/stitch/util/opencv.clj
+++ src/clj/stitch/util/opencv.clj
@@ -38,9 +38,9 @@

 (defn matrix-multiplication [m1 m2]
   (let [res-mat (Mat.)]
-    (Core/gemm h p2 1  (Mat.) 0 res-mat 0))
-    res-mat
-  )
+    (Core/gemm h p2 1  (Mat.) 0 res-mat 0)
+    res-mat))
+
 ;; ----------------------------------------------------------------
 ;; Feature detection
 ;; ----------------------------------------------------------------
@@ -83,6 +83,14 @@
         a (into-array matches)]
     (.fromArray m a)
     m))
+
+;;Function for initial image base points setup
+(defn create-base-points [img]
+  (let [rows (.rows img)
+        cols (.cols img)
+        mat-bp (Mat. 4 3 CvType/CV_64FC1 (Scalar. 0 0))]
+        (.put mat-bp 0 0 (double-array [0 0 1 cols 0 1 0 rows 1 cols rows 1] ))
+    mat-bp))

@@ -329,23 +337,10 @@

   (def keyImage (first rsiv))
   (def h (calculate-homography (first rsiv) (second rsiv)))
-  (def r1 (Mat.))
-  (def r2 (Mat.))
-  (def r3 (Mat.))
-  (def r4 (Mat.))
-  (def p1 (Mat. 3 1 CvType/CV_64FC1 (Scalar. 0 0)))
-  (.put p1 0 0 (double-array [0.0 0.0 1.0] ))
-  (Core/gemm h p1 1  (Mat.) 0 r1 0)
-  (def p2 (Mat. 3 1 CvType/CV_64FC1 (Scalar. 0 0)))
-  (.put p2 0 0 (double-array [col 0.0 1.0] ))
-  (Core/gemm h p2 1  (Mat.) 0 r2 0)
-  (def p3 (Mat. 3 1 CvType/CV_64FC1 (Scalar. 0 0)))
-  (.put p3 0 0 (double-array [0 row 1.0] ))
-  (Core/gemm h p3 1  (Mat.) 0 r3 0)
-  (def p4 (Mat. 3 1 CvType/CV_64FC1 (Scalar. 0 0)))
-  (.put p4 0 0 (double-array [col row 1.0] ))
-  (Core/gemm h p4 1  (Mat.) 0 r4 0)
-  ;;(def s123456789 (reduce stitch iv1))
-  ;;(write-image "test_stitches/1/s56789.jpg" s56789)
+  (def base-points (create-base-points keyImage))
+  (def base-p-calc
+     (for [x (range 0 (.rows base-points))]
+      (matrix-multiplication h (.t (.row base-points x)))))
+

 )


Revert "Use >! instead of put!"

Revert "Use >! instead of put!"

This reverts commit eb060b7507f73212baa9170be72ee9656911ef56.

--- src/clj_gatling/simulation.clj
+++ src/clj_gatling/simulation.clj
@@ -33,11 +33,11 @@
         response (async/chan)
         function (memoize (request-fn request))
         callback (fn [result & context]
-                   (go (>! response [{:name (:name request)
+                   (put! response [{:name (:name request)
                                    :id user-id
                                    :start start
                                    :end (now)
-                                   :result result} (first context)])))]
+                                   :result result} (first context)]))]
     (go
       (function user-id context callback)
       (let [[result c] (alts! [response (async/timeout timeout)])]


moved calls to ensure-selection-visible to manual-refresh-browser-action instead of auto-refresh otherwise you cannot scroll with a selection present with auto-refresh

--- src/clj_ns_browser/browser.clj
+++ src/clj_ns_browser/browser.clj
@@ -346,7 +346,10 @@
   (action :name "Manual Refresh"
           :key  "menu R"
           :handler (fn [e]
-            (auto-refresh-browser-handler {:root (to-root e)}))))
+            (let [id (partial select-id (to-root e))]
+              (auto-refresh-browser-handler {:root (to-root e)})
+              (ensure-selection-visible (id :ns-lb))
+              (ensure-selection-visible (id :vars-lb))))))

 (add-app-action :auto-refresh-browser-action
   (action :name "Auto-Refresh"
@@ -743,8 +746,6 @@
     (swap! vars-lb-refresh-atom not)
     (when-not (= (selection (id :ns-lb)) selected-ns) (selection! (id :ns-lb) selected-ns))
     (selection! (id :vars-lb) selected-var)
-    (ensure-selection-visible (id :ns-lb))
-    (ensure-selection-visible (id :vars-lb))
     {:root root :selected-ns selected-ns :selected-var selected-var}))

 ;;seesaw.core/toggle-full-screen! (locks up computer!!! don't use)