rename alias fn

rename alias fn

--- src/clj/shadow/cljs/build.clj
+++ src/clj/shadow/cljs/build.clj
@@ -203,7 +203,11 @@
         :require-order (into [] (map munge-goog-ns) (.getRequires deps))
         :provides (into #{} (map munge-goog-ns) (.getProvides deps))))))

-(defn rewrite-clojure-requires
+(defn macros-from-ns-ast [state {:keys [require-macros use-macros]}]
+  {:pre [(compiler-state? state)]}
+  (into #{} (concat (vals require-macros) (vals use-macros))))
+
+(defn rewrite-ns-aliases
   [{:keys [requires uses require-order] :as ast}
    {:keys [ns-alias-fn] :as state}]
   (let [should-rewrite
@@ -244,7 +248,7 @@
         ))))

 (defn update-rc-from-ns
-  [state rc {:keys [name require-order require-macros use-macros] :as ast}]
+  [state rc {:keys [name require-order] :as ast}]
   {:pre [(compiler-state? state)]}
   (let [require-order
         (if (= 'cljs.core name)
@@ -288,7 +292,7 @@
           (if (identical? peek eof-sentinel)
             (throw (ex-info "file is empty" {:name name}))
             (let [ast (-> (util/parse-ns peek)
-                          (rewrite-clojure-requires state))]
+                          (rewrite-ns-aliases state))]
               (-> state
                   (update-rc-from-ns rc ast)
                   (assoc :cljc cljc?)))))
@@ -644,7 +648,7 @@

 (defn hijacked-parse-ns [env form name opts]
   (-> (util/parse-ns form)
-      (rewrite-clojure-requires opts)
+      (rewrite-ns-aliases opts)
       (assoc :env env :form form :op :ns)))

 (def default-parse ana/parse)


make {:cache-level :all} default

make {:cache-level :all} default

--- src/clj/shadow/cljs/build.clj
+++ src/clj/shadow/cljs/build.clj
@@ -57,7 +57,7 @@
     '{:input deref
       :output string
       :type (either :js :cljs)
-      :jar boolean
+      :from-jar boolean
       :last-modified long
       :requires #{name}
       :provides #{name}
@@ -294,7 +294,7 @@
             (let [url (URL. (str "jar:file:" abs-path "!/" name))
                   rc (inspect-resource state
                        {:name (normalize-resource-name name)
-                        :jar true
+                        :from-jar true
                         :source-path path
                         :last-modified last-modified
                         :url url
@@ -448,8 +448,10 @@
     (first rcs)))

 (defn- get-deps-for-src* [state name]
-  {:pre [(compiler-state? state)
-         (string? name)]}
+  {:pre [(compiler-state? state)]}
+  (when-not (string? name)
+    (throw (ex-info (format "trying to get deps for \"%s\"" (pr-str name)) {})))
+
   (if (contains? (:deps-visited state) name)
     state
     (let [requires (get-in state [:sources name :requires])]
@@ -458,7 +460,16 @@

       (let [state (conj-in state [:deps-visited] name)
             state (->> requires
-                       (map #(get-in state [:provide->source %]))
+                       (map (fn [require-sym]
+                              (let [src-name (get-in state [:provide->source require-sym])]
+                                (when-not src-name
+                                  (throw
+                                    (ex-info
+                                      (format "ns \"%s\" not available, required by %s" require-sym name)
+                                      {:ns require-sym
+                                       :src name})))
+                                src-name
+                                )))
                        (into #{})
                        (reduce get-deps-for-src* state))]
         (conj-in state [:deps-ordered] name)
@@ -663,9 +674,14 @@
           :warnings warnings
           :source-map source-map)))))

+
+;; FIXME: must manually bump if anything cache related changes
+;; use something similar to clojurescript-version
+(def cache-file-version "v1")
+
 (defn get-cache-file-for-rc
   [{:keys [cache-dir] :as state} {:keys [name] :as rc}]
-  (io/file cache-dir "ana" (str name ".cache.transit.json")))
+  (io/file cache-dir "ana" (str name "." cache-file-version ".cache.transit.json")))

 (defn load-cached-cljs-resource
   [{:keys [logger cache-dir] :as state} {:keys [ns js-name name last-modified] :as rc}]
@@ -726,16 +742,16 @@
 (defn maybe-compile-cljs
   "take current state and cljs resource to compile
    make sure you are in with-compiler-env"
-  [{:keys [cache-dir cache-level] :as state} {:keys [jar file] :as src}]
+  [{:keys [cache-dir cache-level] :as state} {:keys [from-jar file] :as src}]
   (let [cache? (and cache-dir
                     ;; i don't trust the register-constant! stuff for now
                     (not (:emit-constants state))
                     ;; even with :all only cache resources that are in jars or have a file
                     ;; cljs.user (from repl) or runtime-setup should never be cached
                     (or (and (= cache-level :all)
-                             (or jar file))
+                             (or from-jar file))
                         (and (= cache-level :jars)
-                             jar)))]
+                             from-jar)))]
     (or (when cache?
           (load-cached-cljs-resource state src))
         (let [src (do-compile-cljs-resource state src)]
@@ -794,12 +810,12 @@
     (cond
       ;; don't merge .cljc file if a .cljs of the same name exists
       (and cljc? (contains? (:sources state) cljs-name))
-      (do (log-warning logger (format "File conflict: \"%s\" -> \"%s\" (using \"%s\")" name cljs-name url))
+      (do (log-warning logger (format "File conflict: \"%s\" -> \"%s\" (using \"%s\")" name cljs-name cljs-name))
           state)

       ;; if a .cljc exists for a .cljs file unmerge the .cljc and merge the .cljs
       (and (is-cljs? name) (contains? (:sources state) cljc-name))
-      (do (log-warning logger (format "File conflict: \"%s\" -> \"%s\" (using \"%s\")" name cljs-name url))
+      (do (log-warning logger (format "File conflict: \"%s\" -> \"%s\" (using \"%s\")" name cljc-name name))
           (-> state
               (unmerge-resource cljc-name)
               (assoc-in [:sources name] src)
@@ -1728,11 +1744,11 @@
    :use-file-min true

-   :manifest-cache-dir (let [dir (io/file "target" "shadow-build" "jar-manifest")]
+   :manifest-cache-dir (let [dir (io/file "target" "shadow-build" "jar-manifest" "v1")]
                          (io/make-parents dir)
                          dir)
    :cache-dir (io/file "target" "shadow-build" "cljs-cache")
-   :cache-level :jars
+   :cache-level :all

    :public-dir (io/file "public" "js")
    :public-path "js"


Even more namespace prefixes. Where does this stop?

--- src/clj/sparqlab/prefixes.clj
+++ src/clj/sparqlab/prefixes.clj
@@ -6,6 +6,9 @@
   "Builds a function for compact IRIs in the namespace `iri`."
   [iri]
   (partial str iri))
+
+(def dcterms
+  (prefix "http://purl.org/dc/terms/"))

 (def exercise
   (prefix "http://mynarz.net/sparqlab/resource/exercise/"))
@@ -16,6 +19,12 @@
 (def rdfs
   (prefix "http://www.w3.org/2000/01/rdf-schema#"))

+(def skos
+  (prefix "http://www.w3.org/2004/02/skos/core#"))
+
+(def sparqlab
+  (prefix "http://mynarz.net/sparqlab/vocabulary#"))
+
 (def xsd
   (prefix "http://www.w3.org/2001/XMLSchema#"))


simple is not easy

simple is not easy

--- src/clj_kafka/consumer/zk.clj
+++ src/clj_kafka/consumer/zk.clj
@@ -48,7 +48,7 @@
        (lazy-iterate (.iterator ^KafkaStream stream))))

 (defn messages
-  "Provides a simple way to consume a sequence of KafkaMessage messages from the
+  "Provides an easy way to consume a sequence of KafkaMessage messages from the
   named topic. Consumes on a single thread and returns a lazy sequence."
   [^ConsumerConnector consumer topic & {:keys [key-decoder
                                                value-decoder]}]


Use count instead of .length for for truncation check of recent jars

Perhaps the real fix should be making all data have a description of "", but I need to do some analysis on the database before making that determination.

Fixes #238

--- src/clojars/web/dashboard.clj
+++ src/clojars/web/dashboard.clj
@@ -13,7 +13,7 @@
       [:h3.recent-jar-title
        (jar-link jar-map)]
       [:p.recent-jar-description
-       (if (> (.length description) truncate-length)
+       (if (> (count description) truncate-length)
          (str (subs description 0 truncate-length) "...")
          description)]
       [:p.hint.total-downloads "Downloads: " (stats/download-count stats


Remove unused function

Remove unused function

--- src/clojure/nightcode/git.clj
+++ src/clojure/nightcode/git.clj
@@ -39,10 +39,6 @@
   (let [s (.toString out "UTF-8")]
     (.reset out)
     s))
-
-(defn add-bold
-  [s]
-  [:pre {:style "font-family: monospace; font-weight: bold;"} s])

 (defn add-formatting
   [s]


Adding some methods to allow for proper repl start. Needs cleaup sometimes soon.

--- src/conceptnet_clj/loader.clj
+++ src/conceptnet_clj/loader.clj
@@ -8,7 +8,8 @@
             [clojure.core.async :as async :refer [chan go >! <! close!]]
             [datomic.api :as d :refer [q db]]
             [conceptnet-clj.core :refer :all]
-            [conceptnet-clj.system :as system]))
+            [conceptnet-clj.system :as system]
+            [cheshire.core :refer :all]))

 (System/setProperty "datomic.txTimeoutMsec" "30000") ;; 30 seconds

@@ -19,6 +20,43 @@
 (def char-quote "\"")
 (def char-tab "\t")

+(defn concept-title [^String line]
+  (let [tab (. line (indexOf "\t"))]
+    (when (not= tab -1)
+      (.. line (substring 0 tab) trim))))
+
+(defn concept-line? [^String line]
+  (and
+    (not (empty? line))
+    (not (.startsWith line char-quote))    ;
+    (= -1 (.indexOf line "{{SUSPENDED}}")) ; Not bad data
+    (= -1 (.indexOf line "(VG)"))          ;
+    (= -1 (.indexOf line "V)"))))          ;
+
+(defn load-concepts []
+  (println "TODO - load-concepts"))
+
+(defmacro ensure-transformed-file
+  "in and out are bound for you"
+  [[file outfile] & body]
+  `(when-not (.exists (io/as-file ~outfile))
+     (with-open [~'in (io/reader
+                        (java.util.zip.GZIPInputStream. (io/input-stream ~file))
+                        :encoding "ISO-8859-1")
+                 ~'out (io/writer ~outfile)]
+       ~@body)))
+
+(defn ensure-transformed-concepts [file outfile]
+  (ensure-transformed-file [file outfile]
+                           (loop [[line & lines] (drop-while #(not= % "CONCEPTS LIST") (line-seq in))]
+                             (when line
+                               (when (concept-line? line)
+                                 (when-let [title (concept-title line)]
+                                   (doto out
+                                     (.write title)
+                                     (.newLine))))
+                               (recur lines)))))
+
 (defn -main [& args]
   (println "\nTransforming files for faster load...")
   (let [system (system/start (system/system))]


Updated css guide ui with updated toolbar modifers

--- src/css-guide/guideui/ui.cljs
+++ src/css-guide/guideui/ui.cljs
@@ -228,8 +228,8 @@
     (let [{:keys [parts/selected-part parts searchbar] :or {parts/selected-part 0}} (om/props this)
           part-names (map :part/title parts)]
       (dom/div nil
-        (dom/header #js {:className "o-header"}
-          (dom/div #js {:className "o-toolbar o-toolbar--framed u-row--collapse u-trailer--half"}
+        (dom/header #js {:className "c-toolbar c-toolbar--framed c-toolbar--raised"}
+          (dom/div #js {:className "c-toolbar__row"}
            (dom/div #js {:className "u-column--4 u-column--3@md u-column--2@lg u-middle"}
              (dom/div #js {:className "o-toolbar__tile"}
                (dom/img #js {:src "/img/logo.png" :height "40" :width "40" :style #js {:marginTop "2px"}})


Add new fn to store current view and switch to the next

--- src/discuss/utils/common.cljs
+++ src/discuss/utils/common.cljs
@@ -231,6 +231,12 @@
   []
   (change-view! (get-in @app-state [:layout :next-template])))

+(defn save-current-and-change-view!
+  "Saves the current view and changes to the next specified view. Used for the 'close' button in some views."
+  [view]
+  (next-view! (current-view))
+  (change-view! view))
+

 ;;;; Last-api
 (defn last-api!


Add new field to app-state

Add new field to app-state

--- src/discuss/utils/common.cljs
+++ src/discuss/utils/common.cljs
@@ -35,7 +35,8 @@
                              :statement  ""
                              :selection  nil
                              :logged-in? false}
-                :references {:selected nil}
+                :references {:selected nil
+                             :highlighted #{}}
                 :clipboard  {:selections nil
                              :current    nil}
                 :sidebar    {:show? true}
@@ -57,11 +58,13 @@

 (defn unique-key-dict
   "Generate a dictionary with unique key."
-  [] {:key (get-unique-key)})
+  []
+  {:key (get-unique-key)})

 (defn unique-react-key-dict
   "Generate a dictionary with unique react-key."
-  [] {:react-key (get-unique-key)})
+  []
+  {:react-key (get-unique-key)})

 (defn merge-react-key
   "Get a unique key, create a small map with :react-key property and merge it with the given collection."


added distillery.processing/reverse-index-results

--- src/distillery/processing.clj
+++ src/distillery/processing.clj
@@ -3,6 +3,26 @@
   (:require [distillery.config :as cfg])
   (:require [distillery.data :refer :all]))

+(defn reverse-index-results
+  "Annotates the result data structures with indices pointing upwards."
+  [results]
+  (let [t-rword (fn [word result]
+                  (assoc word
+                    :result-no (:no result)))
+        t-pword (fn [word alt result]
+                  (assoc word
+                    :alt-no (:no alt)
+                    :result-no (:no result)))
+        t-alt (fn [alt result]
+                   (assoc alt
+                     :result-no (:no result)
+                     :words (vec (map #(t-pword % alt result) (:words alt)))))
+        t-result (fn [result]
+                   (-> result
+                       (assoc :words (vec (map #(t-rword % result) (:words result))))
+                       (assoc :alternates (vec (map #(t-alt % result) (:alternates result))))))]
+
+    (vec (map t-result results))))

 (defn word-text
   "Returns the text of a word. The word can be a string or a map with a the key :lexical-form."


revised externalDocs' :description & :url

--- src/ephemeris_api/service.clj
+++ src/ephemeris_api/service.clj
@@ -31,8 +31,8 @@
   {:info {:title       "Ephemeris API"
           :description "For Astrology Applications"
           :version     "0.1"}
-   :externalDocs {:description "Find out more"
-                  :url         "https://github.com/astrolet/ephemeris-api"}
+   :externalDocs {:description "Automatically deployed from the master branch on GitHub. Make it your own. Unlicensed Open Source. Follow the link for more info."
+                  :url         "https://github.com/astrolin/ephemeris-api"}
    :basePath "/"}
   [[[(get cfg :base) ^:interceptors
             [api/error-responses


Some easy wins on `prefix-dependency-imports!` performance

--- src/leiningen/source_deps.clj
+++ src/leiningen/source_deps.clj
@@ -153,6 +153,13 @@
   (info "unzipping repackaged class-deps.jar into target/srcdeps")
   (unzip (fs/file "target/class-deps.jar") (fs/file "target/srcdeps/")))

+(defn- filter-clj-files [imports package-names]
+  (if (seq package-names)
+    (->> (filter (fn [[_ import]] (some #(str/includes? import %) package-names)) imports)
+         (map first)
+         (map (partial str "target/srcdeps/")))
+    []))
+
 (defn- prefix-dependency-imports! [pname pversion pprefix prefix src-path srcdeps]
   (let [cleaned-name-version (clean-name-version pname pversion)
         prefix (some-> (first prefix)
@@ -167,11 +174,14 @@
         class-names (map class-file->fully-qualified-name (class-files))
         package-names (->> class-names
                            (map class-name->package-name)
-                           set)]
-    (info (format "    prefixing imports in clojure files in '%s' ..." (first clj-dep-path)))
-    (debug "      class-names" class-names)
-    (debug "      package-names" package-names)
-    (when (seq class-names)
+                           set)
+        clj-files (filter-clj-files imports package-names)]
+    (when (seq clj-files)
+      (info (format "    prefixing imports in clojure files in '%s' ..." (str/join ":" clj-dep-path)))
+      (debug "      class-names" class-names)
+      (debug "      package-names" package-names)
+      (debug "      imports" imports)
+      (debug "      clj files" (str/join ":" clj-files))
       (doseq [file clj-files]
         (let [old         (slurp (fs/file file))
               orig-import (find-orig-import imports file)
@@ -182,8 +192,8 @@
               new         (str/replace new uuid new-import)]
           (when-not (= old new)
             (debug "file: " file " orig import:" orig-import " new import:" new-import)
-            (spit file new)))))
-    (info "    prefixing imports: done")))
+            (spit file new))))
+      (info "    prefixing imports: done"))))

 (defn- dep-frequency [dep-hierarchy]
   (let [frequency (atom {})


make defc- dumb

make defc- dumb

--- src/main/cljs/dmohs/react.clj
+++ src/main/cljs/dmohs/react.clj
@@ -1,35 +1,31 @@
 (ns dmohs.react
   (:require
-    cljs.analyzer
-    [dmohs.react.common :as common]))
+   cljs.analyzer
+   [dmohs.react.common :as common]))

-(defmacro define [private? name doc-string-or-fn-map & [fn-map]]
+(defmacro defc [name doc-string-or-fn-map & [fn-map]]
   (let [[doc-string fn-map] (if (string? doc-string-or-fn-map)
                               [doc-string-or-fn-map fn-map]
-                              [nil doc-string-or-fn-map])
-        fn-map-var (gensym "fn-map-")]
-    `(let [~fn-map-var (merge {:display-name (name '~name)
-                               :namespace ~(str cljs.analyzer/*cljs-ns*)}
-                              ~fn-map)
-           ~fn-map-var (dmohs.react.core/wrap-fn-defs ~fn-map-var)
+                              [nil doc-string-or-fn-map])]
+    `(let [fn-map# (merge {:display-name (name '~name)
+                           :namespace ~(str cljs.analyzer/*cljs-ns*)}
+                          ~fn-map)
+           fn-map# (dmohs.react.core/wrap-fn-defs fn-map#)
            api-keys-to-check# (disj common/react-component-api-method-keys
                                     :get-default-props :render)
-           api-keys-used# (set (keys ~fn-map-var))]
+           api-keys-used# (set (keys fn-map#))]
        (if-not (cljs.core/exists? ~name)
-         (def ~name
-           ~(if private?
-              `(with-meta (dmohs.react.core/create-class ~fn-map-var) {:private true})
-              `(dmohs.react.core/create-class ~fn-map-var)))
+         (def ~name (dmohs.react.core/create-class fn-map#))
          ;; Assume hot-reload. Instead of redefining the symbol, modify the prototype by replacing
          ;; the methods.
          (let [prototype# (.-prototype ~name)]
            ;; Default props are set on the constructor, so we must replace them here.
            (aset ~name "defaultProps"
-                 (if (contains? ~fn-map-var :get-default-props)
-                   ((get ~fn-map-var :get-default-props))
+                 (if (contains? fn-map# :get-default-props)
+                   ((get fn-map# :get-default-props))
                    nil))
-           (doseq [[~'k ~'f] (dissoc ~fn-map-var :get-default-props)]
+           (doseq [[~'k ~'f] (dissoc fn-map# :get-default-props)]
              (aset prototype# (name ~'k) ~'f))
            (doseq [~'k api-keys-to-check#]
              (aset (if (= ~'k :get-initial-state) (.-constructor prototype#) prototype#)
@@ -38,8 +34,5 @@
                      (dmohs.react.core/create-camel-cased-react-method-wrapper ~'k)
                      nil))))))))

-(defmacro defc [name doc-string-or-fn-map & [fn-map]]
-  `(define false ~name ~doc-string-or-fn-map ~fn-map))
-
-(defmacro defc- [name doc-string-or-fn-map & [fn-map]]
-  `(define true ~name ~doc-string-or-fn-map ~fn-map))
+(defmacro defc- [& args]
+  `(defc ~@args))


Fix #7

Fix #7

--- src/ombs/handler/addevent.clj
+++ src/ombs/handler/addevent.clj
@@ -65,4 +65,4 @@
     (addevent-page (db/get-usernames)) ))

 (defn- add-participants [{event :name date :date users :participants}]
-  (dorun (map (comp (partial dbpay/add-participant (db/get-eid event date)) db/get-uid) users)))
+  (dorun (map (comp #(dbpay/add-participant % (db/get-eid event date)) db/get-uid) users)))


[#3073] Use sql aliasing in outer fetch-data sql

Co-authored-by: Iván Perdomo <a15f8b81a160b4eebe5c84e9e3b65c87b9b2f18e@perdomo.me>
Co-authored-by: Emmanuel Mulo <bd234ba4276433f0e5fc7a8fa2d18274fa711567@akvo.org>


edited docstrings in DSL

edited docstrings in DSL

--- src/push/instructions/dsl.clj
+++ src/push/instructions/dsl.clj
@@ -19,9 +19,7 @@

 (defn index-from-scratch-ref
-  "Takes a keyword and a scratch hashmap. If an integer is stored
-  under that key in the hashmap, it's returned. Otherwise raises an
-  exception."
+  "Takes a keyword and a scratch hashmap. If an integer is stored under that key in the hashmap, it's returned. Otherwise raises an exception."
   [k locals]
   (let [stored (k locals)]
     (if (number? stored)
@@ -30,10 +28,7 @@

 (defn- valid-DSL-index
-  "Takes an item (presumably part of a DSL function requiring an :at
-  index) and a hashmap, and returns an integer index value, or an
-  integer from the hashmap if a keyword. Blows up informatively if
-  neither of those is possible."
+  "Takes an item (presumably part of a DSL function requiring an :at index) and a hashmap, and returns an integer index value, or an integer from the hashmap if a keyword. Blows up informatively if neither of those is possible."
   [item scratch]
   (cond
     (integer? item) item
@@ -43,10 +38,7 @@

 (defn- get-nth-of
-  "Abstract function invoked by all the X-nth-of DSL functions.
-  Takes a PushDSL blob, a stackname, an :at index (integer or keyword)
-  (but no :as keyword), and returns the index and the item at that
-  index, raising any argument exceptions it finds."
+  "Abstract function invoked by all the X-nth-of DSL functions. Takes a PushDSL blob, a stackname, an :at index (integer or keyword) (but no :as keyword), and returns the index and the item at that index, raising any argument exceptions it finds."
   [[interpreter scratch] stackname & {:keys [at]}]
   (let [old-stack (u/get-stack interpreter stackname)]
     (if (empty? old-stack)
@@ -161,12 +153,7 @@

 (defn consume-stack
-  "Removes an entire named stack; if an `:as local` argument is given,
-  it saves the stack in that scratch variable. If no local is given,
-  it just deletes the stack.
-
-  Exceptions when:
-  - the stack doesn't exist"
+  "Removes an entire named stack; if an `:as local` argument is given, it saves the stack in that scratch variable. If no local is given, it just deletes the stack. Exceptions when: the stack doesn't exist"
   [[interpreter scratch] stackname & {:keys [as]}]
   (let [old-stack (u/get-stack interpreter stackname)]
     (if (nil? as)
@@ -178,12 +165,7 @@

 (defn consume-top-of
-  "Takes an PushDSL blob, a stackname (keyword) and a scratch variable
-  (keyword) in which to store the top value from that stack.
-
-    Exceptions when:
-    - the stack doesn't exist
-    - the stack is empty"
+  "Takes an PushDSL blob, a stackname (keyword) and a scratch variable (keyword) in which to store the top value from that stack. Exceptions when: the stack doesn't exist, the stack is empty"
   [ [interpreter scratch] stackname & {:keys [as]}]
   (let [old-stack (u/get-stack interpreter stackname)
         old-args (:ARGS scratch)]
@@ -208,18 +190,7 @@

 (defn consume-nth-of
-  "Takes a PushDSL blob, a stackname (keyword), an index argument (an
-  integer or a keyword), and a scratch key (also a keyword), copies
-  the indicated item from that stack into the scratch variable, and
-  deletes it from the stack.
-
-  Exceptions when:
-  - the stack doesn't exist
-  - the stack is empty
-  - no :as argument is present
-  - no :at argument is present
-  - the :at argument is not a keyword or integer
-  - the scratch value passed as a reference is not an integer"
+  "Takes a PushDSL blob, a stackname (keyword), an index argument (an integer or a keyword), and a scratch key (also a keyword), copies the indicated item from that stack into the scratch variable, and deletes it from the stack. Exceptions when: the stack doesn't exist, the stack is empty, no :as argument is present, no :at argument is present, the :at argument is not a keyword or integer, the scratch value passed as a reference is not an integer"
   [[interpreter scratch] stackname & {:keys [as at]}]
   (let [[idx old-stack]
           (get-nth-of [interpreter scratch] stackname :at at)]
@@ -234,18 +205,7 @@

 (defn delete-nth-of
-  "Usage: `delete-nth-of [stackname :at where]`
-
-  Removes item at index `where` from stack `stackname`. If `where` is
-  an integer, the index deleted is `(mod where (count stackname))`; if
-  it is a scratch reference, the numerical value is looked up. If the
-  item stored under key `where` is not an integer, an error occurs.
-
-  Exceptions when:
-    - the stack doesn't exist
-    - the stack is empty
-    - no index is given
-    - the index is a :keyword that doesn't point to an integer"
+  "Removes item at index `where` from stack `stackname`. If `where` is an integer, the index deleted is `(mod where (count stackname))`; if it is a scratch reference, the numerical value is looked up. If the item stored under key `where` is not an integer, an error occurs. Exceptions when: the stack doesn't exist, the stack is empty, no index is given, the index is a :keyword that doesn't point to an integer"
   [[interpreter scratch] stackname & {:keys [as at]}]
   (let [[idx old-stack]
           (get-nth-of [interpreter scratch] stackname :at at)]
@@ -262,8 +222,7 @@

 (defn delete-top-of
-  "Takes an PushDSL blob and a stackname (keyword); deletes the top
-  item of that stack."
+  "Takes an PushDSL blob and a stackname (keyword); deletes the top item of that stack."
   [[interpreter scratch] stackname]
   (let [old-stack (u/get-stack interpreter stackname)
         top-item  (first old-stack)]
@@ -290,9 +249,7 @@

 (defn insert-as-nth-of
-  "Usage: `insert-of-nth-of [stackname local :at where]`
-
-  Place item stored in scratch variable `local` into the named stack so it becomes the new item in the `where` position. If `where` is an integer, the index deleted is `(mod where (count stackname))`; if it is a scratch reference, the numerical value is looked up. If the item stored under key `where` in scratch is not an integer, an error occurs. Exceptions when the stack is empty, no index is given, or the index is a :keyword that doesn't point to an integer. Pushes an `:error` item if the number of points in the item plus the number of items in the stack exceeds `:max-collection-size`."
+  "Place item stored in scratch variable `local` into the named stack so it becomes the new item in the `where` position. If `where` is an integer, the index deleted is `(mod where (count stackname))`; if it is a scratch reference, the numerical value is looked up. If the item stored under key `where` in scratch is not an integer, an error occurs. Exceptions when the stack is empty, no index is given, or the index is a :keyword that doesn't point to an integer. Pushes an `:error` item if the number of points in the item plus the number of items in the stack exceeds `:max-collection-size`."
   [[interpreter scratch] stackname kwd & {:keys [as at]}]
     (let [old-stack (u/get-stack interpreter stackname)
           idx       (valid-DSL-index at scratch)
@@ -445,18 +402,7 @@

 (defn save-nth-of
-  "Takes a PushDSL blob, a stackname (keyword), an index argument (an
-  integer or a keyword), and a scratch key (also a keyword), and
-  copies the indicated item from that stack into the scratch
-  variable (without deleting it).
-
-  Exceptions when:
-  - the stack doesn't exist
-  - the stack is empty
-  - no :as argument is present
-  - no :at argument is present
-  - the :at argument is not a keyword or integer
-  - the scratch value passed as a reference is not an integer"
+  "Takes a PushDSL blob, a stackname (keyword), an index argument (an integer or a keyword), and a scratch key (also a keyword), and copies the indicated item from that stack into the scratch variable (without deleting it). Exceptions when: the stack doesn't exist, the stack is empty, no :as argument is present, no :at argument is present, the :at argument is not a keyword or integer, the scratch value passed as a reference is not an integer"
   [[interpreter scratch] stackname & {:keys [as at]}]
   (let [[idx old-stack]
           (get-nth-of [interpreter scratch] stackname :at at)]
@@ -467,13 +413,7 @@

 (defn save-top-of
-  "Takes a PushDSL blob, a stackname (keyword) and a scratch key (also
-  keyword), and copies the top item from that stack into the scratch
-  variable (without deleting it).
-
-  Exceptions when:
-  - no :as argument is present
-  - the stack is empty"
+  "Takes a PushDSL blob, a stackname (keyword) and a scratch key (also keyword), and copies the top item from that stack into the scratch variable (without deleting it). Exceptions when: no :as argument is present, the stack is empty"
   [[interpreter scratch] stackname & {:keys [as]}]
   (let [old-stack (u/get-stack interpreter stackname)]
     (cond (empty? old-stack) (oops/throw-empty-stack-exception stackname)
@@ -563,15 +503,7 @@

 (defn calculate
-  "Takes a PushDSL blob, a vector of keywords referring to scratch
-  item keys, a function over _those keys_ (using positional notation),
-  and an :as keyword in which to store the result of the function.
-
-  Exceptions when:
-  - [args] is not a vector
-  - no :as argument is present
-  - the wrong number of arguments are provided
-  - (does not check for nil arguments)"
+  "Takes a PushDSL blob, a vector of keywords referring to scratch item keys, a function over _those keys_ (using positional notation), and an :as keyword in which to store the result of the function. Exceptions when: [args] is not a vector, no :as argument is present, the wrong number of arguments are provided. Does not check for nil arguments."
   [[interpreter scratch] args fxn & {:keys [as]}]
   (let [locals (map scratch args)
         result (if (vector? args)


Refactor Ring session store

Refactor Ring session store

--- src/taoensso/carmine/ring.clj
+++ src/taoensso/carmine/ring.clj
@@ -1,18 +1,21 @@
 (ns taoensso.carmine.ring
-  "Carmine-backed Ring session store. Adapted from clj-redis-session."
+  "Carmine-backed Ring session store."
   {:author "Peter Taoussanis"}
-  (:require [ring.middleware.session.store :as session-store]
+  (:require [ring.middleware.session]
+            [taoensso.encore  :as enc]
             [taoensso.carmine :as car :refer (wcar)]))

 (defrecord CarmineSessionStore [conn-opts prefix ttl-secs]
-  session-store/SessionStore
-  (read-session   [_ key] (or (when key (wcar conn-opts (car/get key))) {}))
-  (delete-session [_ key] (wcar conn-opts (car/del key)) nil)
-  (write-session  [_ key data]
-    (let [key (or key (str prefix ":" (java.util.UUID/randomUUID)))]
-      (wcar conn-opts (if ttl-secs (car/setex key ttl-secs data)
-                                   (car/set   key          data)))
-      key)))
+  ring.middleware.session.store/SessionStore
+  (read-session   [_ k] (wcar conn-opts (car/get k)))
+  (delete-session [_ k] (wcar conn-opts (car/del k)) nil)
+  (write-session  [_ k data]
+    (let [k (or k (str prefix ":" (enc/uuid-str)))]
+      (wcar conn-opts
+        (if ttl-secs
+          (car/setex k ttl-secs data)
+          (car/set   k          data)))
+      k)))

 (defn carmine-store
   "Creates and returns a Carmine-backed Ring SessionStore. Use `expiration-secs`
@@ -20,8 +23,8 @@
   sessions will never expire."
   [conn-opts & [{:keys [key-prefix expiration-secs]
                  :or   {key-prefix      "carmine:session"
-                        expiration-secs (* 60 60 24 30)}}]]
-  (->CarmineSessionStore conn-opts key-prefix expiration-secs))
+                        expiration-secs (enc/secs :days 30)}}]]
+  (CarmineSessionStore. conn-opts key-prefix expiration-secs))

 (defn make-carmine-store ; 1.x backwards compatiblity
   "DEPRECATED. Use `carmine-store` instead."


Add rules for only connecting above existing coral.

--- src/videotest/coral/coral.clj
+++ src/videotest/coral/coral.clj
@@ -45,19 +45,27 @@
 (defn is-occupied? [coral coords]
   (contains? coral coords))

-(defn bumping-coral? []
-  )
+(defn is-row-under-occupied? [coral [col row]]
+  (let [row-under (inc row)]
+   (or
+    (and (even? col)
+         (some #(is-occupied? coral %) [[(dec col) row]
+                                        [     col  row-under]
+                                        [(inc col) row]]))
+    (and (odd? col)
+         (some #(is-occupied? coral %) [[(dec col) row-under]
+                                        [     col  row-under]
+                                        [(inc col) row-under]])))))

 (def BOTTOM-ATTACH-PCT 0.1)

 (defn is-attaching? [num-rows cell-w coral x y]
   (let [[col row :as coords] (xy->coords cell-w x y)]
-   (cond
-    (is-bottom? num-rows row)
     (and (not (is-occupied? coral coords))
-         (> BOTTOM-ATTACH-PCT (rand)))
-
-    :default false)))
+         (or (and (is-bottom? num-rows row)
+                  (> BOTTOM-ATTACH-PCT (rand)))
+             (is-row-under-occupied? coral coords))
+    )))

 (defn remove-seeds [all-seeds seeds]
   (remove (set seeds) all-seeds))


Move identities lookup down to where it's needed

--- src-cljs/frontend/components/aside.cljs
+++ src-cljs/frontend/components/aside.cljs
@@ -378,7 +378,7 @@
         branch (:current-branch project)]
     (utils/md5 (str project-id branch))))

-(defn branch-activity-list [app owner opts]
+(defn branch-activity-list [app owner]
   (reify
     om/IRender
     (render [_]
@@ -387,9 +387,11 @@
             sort-branches-by-recency? (get-in app state/sort-branches-by-recency-path false)
             projects (get-in app state/projects-path)
             settings (get-in app state/settings-path)
+            user (get-in app state/user-path)
+            identities (:identities user)
             recent-projects-filter (if (and sort-branches-by-recency?
                                             (not show-all-branches?))
-                                     (partial project-model/personal-recent-project? (:identities opts))
+                                     (partial project-model/personal-recent-project? identities)
                                      identity)]
         (html
          [:div.aside-activity.open
@@ -430,7 +432,7 @@
                                       (take 100))
                        :show-all-branches? show-all-branches?
                        :navigation-data (:navigation-data app)}
-                      {:opts {:identities (:identities opts)
+                      {:opts {:identities identities
                               :show-project? true}})
             [:ul.projects
              (for [project (sort project-model/sidebar-sort projects)]
@@ -440,9 +442,9 @@
                           :expanded-repos expanded-repos
                           :navigation-data (:navigation-data app)}
                          {:react-key (project-model/id project)
-                          :opts {:identities (:identities opts)}}))])])))))
-
-(defn aside-menu [app owner opts]
+                          :opts {:identities identities}}))])])))))
+
+(defn aside-menu [app owner]
   (reify
     om/IDisplayName (display-name [_] "Aside Menu")
     om/IInitState (init-state [_] {:scrollbar-width 0})
@@ -455,8 +457,7 @@
         (om/build org-settings-menu app)
         (om/build admin-settings-menu app)
         (om/build account-settings-menu app)
-        (om/build branch-activity-list app {:opts {:identities (:identities opts)
-                                                   :scrollbar-width (om/get-state owner :scrollbar-width)}})]))))
+        (om/build branch-activity-list app {:opts {:scrollbar-width (om/get-state owner :scrollbar-width)}})]))))

 (defn- aside-nav-clicked
   [owner event-name]
@@ -608,8 +609,6 @@
     om/IDisplayName (display-name [_] "Aside")
     om/IRender
     (render [_]
-      (let [user (get-in app state/user-path)
-            identities (:identities user)]
-        (html
-         [:aside.app-aside
-          (om/build aside-menu app {:opts {:identities identities}})])))))
+      (html
+       [:aside.app-aside
+        (om/build aside-menu app)]))))


made some updates on how the data was passed around on the build page plus added a check for the user to be logged in to show upsells

--- src-cljs/frontend/components/build.cljs
+++ src-cljs/frontend/components/build.cljs
@@ -121,15 +121,12 @@

     ))

-(defn container-pills [data owner]
+(defn container-pills [{:keys [build-running? build container-data project-data user view]} owner]
   (reify
     om/IRender
     (render [_]
       (analytics/track-parallelism-button-impression  {:view view})
-      (let [container-data (:container-data data)
-            build-running? (:build-running? data)
-            build (:build data)
-            {:keys [containers current-container-id]} container-data
+      (let [{:keys [containers current-container-id]} container-data
             hide-pills? (or (>= 1 (count containers))
                             (empty? (remove :filler-action (mapcat :actions containers))))
             style {:position "fixed"}
@@ -142,8 +139,9 @@
                                 :current-container-id current-container-id}
                                {:react-key (:index container)}))
                    (if (and
-                         (not (get-in data [:project-data :plan :paid]))
-                         (not (get-in data [:project-data :project :feature_flags :oss]))
+                         user
+                         (not (get-in project-data [:plan :paid]))
+                         (not (get-in project-data [:project :feature_flags :oss]))
                          (= "button" (om/get-shared owner  [:ab-tests :upgrade_banner])))
                      [:a.container-selector.parallelism-tab.upgrade
                       {:role "button"
@@ -199,7 +197,7 @@
                         (not (:dismiss-config-errors build-data)))
                (om/build build-config/config-errors build))]]]])))))

-(defn upgrade-banner [data owner]
+(defn upgrade-banner [{:keys [build view]} owner]
   (reify
     om/IRender
     (render [_]
@@ -209,7 +207,7 @@
          [:i.fa.fa-tachometer.fa-lg]
          [:p.main.message [:b "Build Diagnostics"]
           [:p.sub.message "Looking for faster builds? "
-           [:a {:href (build-model/path-for-parallelism (:build data))
+           [:a {:href (build-model/path-for-parallelism build)
                 :on-click #(analytics/track-parallelism-button-click {:view view})}
             "Adding containers"]
            " can cut down time spent testing."]]]))))
@@ -237,17 +235,21 @@
                                               :user user
                                               :scopes (get-in data state/project-scopes-path)})
              (when (and
+                     user
                      (not (get-in project-data [:plan :paid]))
                      (not (get-in project-data [:project :feature_flags :oss]))
                      (= "banner" (om/get-shared owner  [:ab-tests :upgrade_banner])))
-               (om/build upgrade-banner {:build build}))
+               (om/build upgrade-banner {:build build
+                                         :view view}))
              (om/build notices {:build-data (dissoc build-data :container-data)
                                 :project-data project-data
                                 :invite-data invite-data})
-             (om/build container-pills {:container-data container-data
+             (om/build container-pills {:build build
+                                        :build-running? (build-model/running? build)
+                                        :container-data container-data
                                         :project-data project-data
-                                        :build-running? (build-model/running? build)
-                                        :build build})
+                                        :user user
+                                        :view view})
              (om/build build-steps/container-build-steps container-data)

              (when (< 1 (count (:steps build)))


Extensions

Extensions

--- src-cljs/kixi/hecuba/tabs/profiles.cljs
+++ src-cljs/kixi/hecuba/tabs/profiles.cljs
@@ -422,6 +422,25 @@
                    (text-control c state owner :glazed_perimeter "Glazed Perimeter")
                    (text-control c state owner :height "Height")]))]
               [:p "No conservatories."]))])]))))
+
+(defn extensions-row [profiles owner]
+  (reify
+    om/IRenderState
+    (render-state [_ state]
+      (html
+       [:div.col-md-12
+        (for [profile profiles]
+          [:div {:class (profile-column-width)}
+           (bs/panel
+            "Extensions"
+            (if-let [extensions (seq (:extensions profile))]
+              [:div {:class (profile-column-width)}
+               (for [item extensions]
+                 (bs/panel
+                  "Extension"
+                  [(text-control item state owner :age ":age")
+                   (text-control item state owner :construction_date ":construction_date")]))]
+              [:p "No extensions."]))])]))))

 (defn profile-rows [profiles owner]
   (reify
@@ -453,8 +472,8 @@

          ;; dwelling details
          (om/build conservatories-row profiles)
-         ;; (om/build extensions profiles)
          ;; (om/build heating-systems profiles)
+         (om/build extensions-row profiles)
          ;; (om/build hot-water-systems profiles)
          ;; (om/build storeys profiles)
          ;; (om/build walls profiles)


renamed dispatch predicate to token-changed-to-id?, which is 2% less ugly

--- src/app/cljs/one/sample/controller.cljs
+++ src/app/cljs/one/sample/controller.cljs
@@ -59,8 +59,8 @@
 (dispatch/react-to #{:init :workspace}
                    (fn [t d] (action (assoc d :type t))))

-(defn is-doc-id-token? [s]
+(defn token-changed-to-id?
   (.test (js/RegExp. "^[a-z0-9]{32}$") (name s)))

-(dispatch/react-to is-doc-id-token?
+(dispatch/react-to token-changed-to-id?
                    (fn [t d] (get-document (name t))))


txd-gen: Fix bug creating temporary eids

The first bug I feel I really discovered through generative testing.
Tempids should be negative, not 0. Therefore shift that range by one. I
wonder why datamic.api/tempid doesn't throw an exception, though. It
seems like (< n 0) could be a precondition.

--- src/clj/theatralia/database/txd_gen.clj
+++ src/clj/theatralia/database/txd_gen.clj
@@ -55,7 +55,7 @@
     (let [[eids present-tags] (get-present-tags db tags user-eid)
           tags-to-add (remove (set present-tags) tags)
           tempids (map #(d/tempid :part/bibliography %)
-                       (invert (range (count tags-to-add))))]
+                       (invert (range 1 (inc (count tags-to-add)))))]
       [(concat eids tempids)
        (mapv (fn [i t]
                {:db/id i


Reindent site-list

Reindent site-list

--- src/cljs/comic_reader/ui/site_list.cljs
+++ src/cljs/comic_reader/ui/site_list.cljs
@@ -10,14 +10,14 @@
   (assoc db :site-list sites))

 (defn setup-site-list! []
- (re-frame/register-sub
-  :site-list
-  (fn [app-db v]
-    (reaction (get-site-list @app-db))))
+  (re-frame/register-sub
+   :site-list
+   (fn [app-db v]
+     (reaction (get-site-list @app-db))))

- (re-frame/register-handler
-  :set-site-list
-  set-site-list))
+  (re-frame/register-handler
+   :set-site-list
+   set-site-list))

 (defn site-list [view-site sites]
   (base/list-with-loading


Tweak signature addition to docstring.

Tweak signature addition to docstring.

--- src/com/palletops/api_builder/stage.clj
+++ src/com/palletops/api_builder/stage.clj
@@ -202,8 +202,10 @@
 (defn format-sigs
   [sigs]
   (str \newline \newline
-       "    "
-       (join "\n    " (map format-sig sigs))))
+       "## Function Signatures\n"
+       (apply str
+            (for [s (map format-sig sigs)]
+              (str "\n  - " s)))))

 (defn add-sig-doc
   "Add :sig the function's doc string."


[#11113] Can't send image without description in 1-1 and group chats

--- src/status_im/chat/models/mentions.cljs
+++ src/status_im/chat/models/mentions.cljs
@@ -103,21 +103,23 @@
   ([text users-fn]
    (replace-mentions text users-fn 0))
   ([text users-fn idx]
-   (let [mention-key-idx (string/index-of text "@" idx)]
-     (if-not mention-key-idx
-       text
-       (let [users (users-fn)
-             {:keys [public-key alias]}
-             (match-mention text users mention-key-idx)]
-         (if-not alias
-           (recur text (fn [] users) (inc mention-key-idx))
-           (let [new-text (string/join
-                           [(subs text 0 (inc mention-key-idx))
-                            public-key
-                            (subs text (+ (inc mention-key-idx)
-                                          (count alias)))])
-                 mention-end (+ (inc mention-key-idx) (count public-key))]
-             (recur new-text (fn [] users) mention-end))))))))
+   (if (string/blank? text)
+     text
+     (let [mention-key-idx (string/index-of text "@" idx)]
+       (if-not mention-key-idx
+         text
+         (let [users (users-fn)
+               {:keys [public-key alias]}
+               (match-mention text users mention-key-idx)]
+           (if-not alias
+             (recur text (fn [] users) (inc mention-key-idx))
+             (let [new-text (string/join
+                             [(subs text 0 (inc mention-key-idx))
+                              public-key
+                              (subs text (+ (inc mention-key-idx)
+                                            (count alias)))])
+                   mention-end (+ (inc mention-key-idx) (count public-key))]
+               (recur new-text (fn [] users) mention-end)))))))))

 (defn check-mentions [cofx text]
   (replace-mentions text #(get-mentionable-users cofx)))


Use destructuring

Use destructuring

--- test/desdemona/jobs/sample_job_test.clj
+++ test/desdemona/jobs/sample_job_test.clj
@@ -8,16 +8,13 @@
             [onyx.plugin.sql]))

 (deftest build-job-test
-  (let [job (build-job)
+  (let [{:keys [catalog workflow lifecycles]} (build-job)
         expected-catalog-names [:original-wrapper :determine-origin :build-row :prepare-rows :read-lines :write-lines]
-        catalog (job :catalog)
-        workflow (job :workflow)
         expected-workflow [[:read-lines :original-wrapper]
                            [:original-wrapper :determine-origin]
                            [:determine-origin :build-row]
                            [:build-row :prepare-rows]
                            [:prepare-rows :write-lines]]
-        lifecycles (job :lifecycles)
         expected-lifecycles [{:lifecycle/task :write-lines :lifecycle/calls :desdemona.lifecycles.logging/log-calls}
                              {:lifecycle/task :read-lines :lifecycle/calls :desdemona.lifecycles.logging/log-calls}
                              {:lifecycle/task :write-lines :lifecycle/calls :onyx.plugin.sql/write-rows-calls}


Remove extra require for base

Remove extra require for base

--- test/kixi/integration/metadata_test.clj
+++ test/kixi/integration/metadata_test.clj
@@ -7,8 +7,7 @@
             [kixi.datastore.metadatastore :as ms]
             [kixi.datastore.web-server :as ws]
             [kixi.datastore.schemastore.conformers :as conformers]
-            [kixi.datastore.schemastore :as ss]
-            [kixi.integration.base :as base]))
+            [kixi.datastore.schemastore :as ss]))

 (alias 'ms 'kixi.datastore.metadatastore)


Rudimentary Mithril's m function in ClojureScript

--- src/cljs/modern_cljs/core.cljs
+++ src/cljs/modern_cljs/core.cljs
@@ -1,6 +1,9 @@

 (ns modern-cljs.core
   (:require [foo.bar] [m]))
+
+(defn m [tag attrs values]
+  (js/m tag (clj->js attrs) (clj->js values)))

 (def db
   {:var (str "tosi:" (rand-int 10))})
@@ -9,7 +12,7 @@
   (println "Calling major Tom"))
 (defn ^:export viewer [c]
   (println "Seeing things")
-  (js/m "div" (.-var (clj->js db))))
+  (m "div" {:style {:color "green"}} (:var db)))

 (def app {:controller ctrl :view viewer})

@@ -23,4 +26,3 @@
 (.mount js/m
   (.getElementById js/document "app")
   (clj->js app))
-


the code is much cleaner now that I remembered that I can use (comp ...);

--- src/mustached_hipster/core.clj
+++ src/mustached_hipster/core.clj
@@ -6,13 +6,20 @@
 (defn get-playlist
    [m3u8]

-   (let
-      [before (System/nanoTime)]
+   (let [
+      before (System/nanoTime)
+      after #(* (- (System/nanoTime) before) 1e-9)
+      grab-and-process (comp
+         (partial map #(s/replace % #"\?.*" "\n"))
+         (partial filter #(not= \# (first %)))
+         s/split-lines
+         :body
+         http/get)]

       (let
-         [response (http/get m3u8)]
-         (println "the request took" (* (- (System/nanoTime) before) 1e-9) "seconds")
-         response)))
+         [playlist (grab-and-process m3u8)]
+         (println "the request took" (after) "seconds")
+         playlist)))

 (defn -main
    [url]
@@ -21,14 +28,10 @@
    (alter-var-root #'*read-eval* (constantly false))

    (let
-      [not-comment #(not= \# (first %))
-       chop-query  #(s/replace % #"\?.*" "\n") ]
+      [post-process (comp
+         (partial spit "foo.txt")
+         (partial apply str)
+         (partial take 10)
+         get-playlist)]

-      (spit "foo.txt"
-         (apply str
-            (take 10
-               (map chop-query
-                  (filter not-comment
-                     (s/split-lines
-                        (:body
-                           (get-playlist url))))))))))
+      (post-process url)))


update video info only if it is missing.

--- src/oc/storage/api/entries.clj
+++ src/oc/storage/api/entries.clj
@@ -46,7 +46,9 @@
   (bot/send-share-entry-trigger! (bot/->share-entry-trigger org board entry share-request user))))

 (defn- handle-video-data [conn entry]
-  (when (:video-id entry)
+  (when (and (:video-id entry)
+             (or (nil? (:video-processed entry))
+                 (nil? (:video-transcript entry))))
     (ziggeo/video (:video-id entry)
       (fn [video] (entry-res/update-video-data conn video entry)))))
 ;; ----- Validations -----


Introduced relative metronomes.

Introduced relative metronomes.

--- src/overtunes/songs/before.clj
+++ src/overtunes/songs/before.clj
@@ -77,24 +77,31 @@
           with-bass (concat bass tones)]
       (doall (map (fn [tone] (play-note tone instrument duration)) with-bass)))))

-(defn play-progression [progression metro start]
+(defn metronome-from
+  "Returns a metronome that measures beats relative to start."
+  ([metro start] (fn
+    ([] (metro (+ 0 start)))
+    ([beat] (metro (+ beat start))))))
+
+(defn play-progression [progression metro]
   "Plays a seq of chords for two beats each on the cornet.
-  Takes a metronome and a starting beat in addition to the chord progression.
-  (play-progression [root fourth fifth] metro (metro))"
+  Takes a relative metronome in addition to the chord progression.
+  (play-progression [root fourth fifth] metro)"
   (let [beats-per-chord 2
         duration (* beats-per-chord (beat-length metro))]
     (when-not (empty? progression)
-      (at (metro start) (play-chord (first progression) organ-cornet duration))
-      (play-progression (rest progression) metro (+ start beats-per-chord)))))
+      (at (metro) (play-chord (first progression) organ-cornet duration))
+      (play-progression (rest progression)
+        (metronome-from metro beats-per-chord)))))

-(defn play-melody [melody metro start]
+(defn play-melody [melody metro]
   "Plays a seq of notes on the cornet.
-  Takes a metronome and a starting beat in addition to the melody.
-  (play-progression [root fourth fifth] metro (metro))"
+  Takes a relative metronome in addition to the melody.
+  (play-melody [:C3 :E3 :G3] metro)"
   (let [duration (beat-length metro)]
     (when-not (empty? melody)
-      (at (metro start) (play-note (first melody) organ-cornet duration))
-      (play-melody (rest melody) metro (+ start 1)))))
+      (at (metro) (play-note (first melody) organ-cornet duration))
+      (play-melody (rest melody) (metronome-from metro 1)))))

 (defn cycle-n
   "Returns a new seq which is cycled n times.
@@ -103,12 +110,12 @@
   (take (* (count s) n) (cycle s)))

 (defn play
-  "Play the melody over the chords to metro's time."
+  "Play the melody over the chords to the relative metro's time."
   [chords metro]
   (let [repetitions-per-chord (/ (count melody) 2)
         melody-line (cycle-n (/ (count chords) repetitions-per-chord) melody)]
-  (play-melody melody-line metro (metro))
-  (play-progression (concat chords finish) metro (metro))))
+  (play-melody melody-line metro)
+  (play-progression (concat chords finish) metro)))

 (defn full-version []
   "The full version of 'Before', grave."


Disable buttons when crunching pokemon

Disable buttons when crunching pokemon

--- frontend/src/cruncher/utils/views.cljs
+++ frontend/src/cruncher/utils/views.cljs
@@ -16,7 +16,7 @@
   [fn & strs]
   (dom/button #js {:className "btn btn-primary"
                    :onClick   fn
-                   :disabled  (lib/loading?)
+                   :disabled  (or (lib/loading?) (lib/progress?))
                    :react-key (lib/get-unique-key)}
               strs))

@@ -51,7 +51,7 @@
   ; "Spinning icon to indicate if there is data being transferred."
   Object
   (render [this]
-    (when (lib/loading?)
+    (when (or (lib/loading?) (lib/progress?))
       (dom/div #js {:style #js {:paddingTop "2em"}}
                (fa-icon "fa-circle-o-notch fa-spin fa-fw")
                " Loading..."))))


Added new test case for linear search.

Added new test case for linear search.

--- test/minijava/test_compile.clj
+++ test/minijava/test_compile.clj
@@ -10,8 +10,9 @@
                  (accept [_ name] (not (nil? (re-find #"java$" name)))))
         files (-> "resources/sample" java.io.File. (.listFiles filter))]
     (doseq [f files]
-      (pprint (compile-program f))))))
-
+    (compile-program f))))
+)
+(comment
 (deftest test-factorial
 	(let [prog

@@ -34,6 +35,113 @@

 }" ]

- (pprint (compile-program prog))
+ (println (compile-program prog))

 ))
+)
+
+(deftest test-ls
+	(let [prog
+"class LinearSearch{
+	public static void main(String[] a){
+		System.out.println(new LS().Start(10));
+	}
+}
+
+
+// This class contains an array of integers and
+// methods to initialize, print and search the array
+// using Linear Search
+class LS {
+	int[] number ;
+	int size ;
+
+	// Invoke methods to initialize, print and search
+	// for elements on the array
+	public int Start(int sz){
+		int aux01 ;
+		int aux02 ;
+
+		aux01 = this.Init(sz);
+		aux02 = this.Print();
+		System.out.println(9999);
+		System.out.println(this.Search(8));
+		System.out.println(this.Search(12)) ;
+		System.out.println(this.Search(17)) ;
+		System.out.println(this.Search(50)) ;
+		return 55 ;
+	}
+
+	// Print array of integers
+	public int Print(){
+		int j ;
+
+		j = 1 ;
+		while (j < (size)) {
+			System.out.println(number[j]);
+			j = j + 1 ;
+		}
+		return 0 ;
+	}
+
+	// Search for a specific value (num) using
+	// linear search
+	public int Search(int num){
+		int j ;
+		boolean ls01 ;
+		int ifound ;
+		int aux01 ;
+		int aux02 ;
+		int nt ;
+
+		j = 1 ;
+		ls01 = false ;
+		ifound = 0 ;
+
+		//System.out.println(num);
+		while (j < (size)) {
+			aux01 = number[j] ;
+			aux02 = num + 1 ;
+			if (aux01 < num) nt = 0 ;
+			else if (!(aux01 < aux02)) nt = 0 ;
+			else {
+				ls01 = true ;
+				ifound = 1 ;
+				j = size ;
+			}
+			j = j + 1 ;
+		}
+
+		return ifound ;
+	}
+
+
+
+	// initialize array of integers with some
+	// some sequence
+	public int Init(int sz){
+		int j ;
+		int k ;
+		int aux01 ;
+		int aux02 ;
+
+		size = sz ;
+		number = new int[sz] ;
+
+		j = 1 ;
+		k = size + 1 ;
+		while (j < (size)) {
+			aux01 = 2 * j ;
+			aux02 = k - 3 ;
+			number[j] = aux01 + aux02 ;
+			j = j + 1 ;
+			k = k - 1 ;
+		}
+		return 0 ;
+	}
+
+}"]
+
+ (println (compile-program prog))
+
+))


change dev repl-port to 12345

change dev repl-port to 12345

--- dev/user.clj
+++ dev/user.clj
@@ -24,6 +24,7 @@
   (alter-var-root #'system (constantly (system/system system/dev-system-components
                                         :handler-wrapper stacktrace/wrap-stacktrace
                                         :cljs-optimized? false
+                                        :repl-port 12345
                                         :cljs-repl-script-fn cljs-repl/script-tag-fn))))

 (defn socket-logger []


Give a more meaningful error message when a handler returns nil.

--- modules/web/src/main/clojure/immutant/web/servlet.clj
+++ modules/web/src/main/clojure/immutant/web/servlet.clj
@@ -50,7 +50,7 @@
             (if-let [response-map (binding [current-servlet-request request]
                                     ((servlet-session-wrapper handler) request-map))]
               (servlet/update-servlet-response response response-map)
-              (throw (NullPointerException. "Handler returned nil.")))))))
+              (throw (NullPointerException. "Ring handler returned nil instead of a response map.")))))))
     (init [_ _])
     (destroy [_])))


Add proper IBuffer implementation (incomplete) for NIO and Netty.

--- src/bytebuf/buffer.clj
+++ src/bytebuf/buffer.clj
@@ -12,19 +12,29 @@
   (write-long [_ pos value] "Write an long to the buffer."))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; NIO ByteBuffer implementation
+;; NIO & Netty Buffer implementations
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(extend-type ByteBuffer
-  IBuffer
-  (read-integer* [buff]
-    (.getInt buff))
-  (read-long* [buff]
-    (.getLong buff))
-  (tell* [buff]
-    (.position buff))
-  (seek* [buff val]
-    (.position buff val)))
+(extend-protocol IBuffer
+  ByteBuffer
+  (read-int [buff pos]
+    (.getInt buff pos))
+  (read-long [buff pos]
+    (.getLong buff pos))
+  (write-int [buff pos value]
+    (.putInt buff pos value))
+  (write-long [buff pos value]
+    (.putLong buff pos value))
+
+  ByteBuf
+  (read-int [buff pos]
+    (.getInt buff pos))
+  (read-long [buff pos]
+    (.getLong buff pos))
+  (write-int [buff pos value]
+    (.setInt buff pos value))
+  (write-long [buff pos value]
+    (.setLong buff pos value)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Public Api


Drop incorrect type hints.

Drop incorrect type hints.

--- src/cavm/statement.clj
+++ src/cavm/statement.clj
@@ -26,10 +26,10 @@
     (apply execute args)))

 (defn- stmt-execute
-  ([^PreparedStatement conn stmt fields]
+  ([conn stmt fields]
    (fn [values]
      (jdbc/db-do-prepared {:connection conn} false stmt (mapv values fields))))
-  ([^PreparedStatement conn stmt]
+  ([conn stmt]
    (fn [values]
      (jdbc/db-do-prepared {:connection conn} false stmt values))))

@@ -42,10 +42,10 @@
       (apply stmt-execute conn stmt args))))

 (defn- query-execute
-  ([^PreparedStatement conn stmt fields]
+  ([conn stmt fields]
    (fn [values]
      (jdbc/query {:connection conn} [stmt (mapv values fields)])))
-  ([^PreparedStatement conn stmt]
+  ([conn stmt]
    (fn [values]
      (jdbc/query {:connection conn} (into [stmt] values)))))


Moved make-lane/conn-loop to closure for future server/lane state.

--- src/cbfg/world/t2.cljs
+++ src/cbfg/world/t2.cljs
@@ -21,39 +21,37 @@

 ; --------------------------------------------

-(defn make-fenced-pump-lane [actx lane-name lane-out-ch]
-  (let [max-inflight 10
-        lane-buf-size 20
-        lane-in-ch (achan-buf actx lane-buf-size)]
-    (cbfg.fence/make-fenced-pump actx lane-name lane-in-ch lane-out-ch
-                                 max-inflight false)
-    lane-in-ch))
-
-(defn server-conn-loop [actx server-send-ch server-recv-ch close-server-recv-ch]
-  (cbfg.world.net/server-conn-loop actx server-send-ch server-recv-ch
-                                   close-server-recv-ch
-                                   :make-lane-fn make-fenced-pump-lane))
-
 ; --------------------------------------------

 (defn kv-server [server-addr & ports]
-  (doseq [port ports]
-    (let [world (:world (prog-base-now))
-          done (atom false)]
-      (act server-init world
-           (when-let [listen-result-ch (achan server-init)]
-             (aput server-init (:net-listen-ch (prog-base-now))
-                   [server-addr port listen-result-ch])
-             (when-let [[accept-ch close-accept-ch]
-                        (atake server-init listen-result-ch)]
-               (cbfg.world.net/server-accept-loop world accept-ch close-accept-ch
-                                                  :server-conn-loop server-conn-loop)))
-           (reset! done true))
-      (wait-done done)
-      (prog-evt world :kv-server {:server-addr server-addr :server-port port}
-                #(update-in % [:servers server-addr] conj port))))
-  (addr-override-xy server-addr
-                    300 (+ 20 (* 120 (dec (count (:servers (prog-curr-now))))))))
+  (let [lane-max-inflight 10
+        lane-buf-size 20
+        make-lane (fn [actx lane-name lane-out-ch]
+                    (let [lane-in-ch (achan-buf actx lane-buf-size)]
+                      (cbfg.fence/make-fenced-pump actx lane-name lane-in-ch lane-out-ch
+                                                   lane-max-inflight false)
+                      lane-in-ch))
+        conn-loop (fn [actx server-send-ch server-recv-ch close-server-recv-ch]
+                    (cbfg.world.net/server-conn-loop actx server-send-ch server-recv-ch
+                                                     close-server-recv-ch
+                                                     :make-lane-fn make-lane))]
+    (doseq [port ports]
+      (let [world (:world (prog-base-now))
+            done (atom false)]
+        (act server-init world
+             (when-let [listen-result-ch (achan server-init)]
+               (aput server-init (:net-listen-ch (prog-base-now))
+                     [server-addr port listen-result-ch])
+               (when-let [[accept-ch close-accept-ch]
+                          (atake server-init listen-result-ch)]
+                 (cbfg.world.net/server-accept-loop world accept-ch close-accept-ch
+                                                    :server-conn-loop conn-loop)))
+             (reset! done true))
+        (wait-done done)
+        (prog-evt world :kv-server {:server-addr server-addr :server-port port}
+                  #(update-in % [:servers server-addr] conj port))))
+    (addr-override-xy server-addr
+                      300 (+ 20 (* 120 (dec (count (:servers (prog-curr-now)))))))))

 (defn kv-client [client-addr server-addr server-port]
   (let [world (:world (prog-base-now))


Regrouped functions for readability.

Regrouped functions for readability.

--- src/cbfg/world/t2.cljs
+++ src/cbfg/world/t2.cljs
@@ -18,6 +18,18 @@

 ; --------------------------------------------

+(defn server-handler [server-state m]
+  (case (:op m)
+    :authenticate
+    (if-let [{:keys [realm user pswd]} m]
+      (if (and realm user pswd)
+        (if (= pswd (get-in server-state [:realms realm :users user :pswd]))
+          [server-state (assoc (dissoc m :pswd) :status :ok)]
+          [server-state (assoc (dissoc m :pswd) :status :mismatch)])
+        [server-state (assoc (dissoc m :pswd) :status :invalid)])
+      [server-state (assoc (dissoc m :pswd) :status :invalid)])
+    nil))
+
 (defn rq-authenticate [actx m]
   (act rq-authenticate actx
        (let [{:keys [server-state-ch lane-state-ch realm user]} m
@@ -34,12 +46,19 @@
            (assoc (dissoc m :pswd)
              :status :failed :status-info [:authenticate :closed])))))

+; --------------------------------------------
+
+(defn lane-handler [lane-state m]
+  (case (:op m)
+    "realms-list"
+    [lane-state (assoc m :status :invalid)]
+    nil))
+
 (defn rq-handle-lane [actx m] ; Forward to lane-state-ch to handle the request.
   (act rq-handle-lane actx
        (let [lane-state-ch (:lane-state-ch m)
              res-ch (achan rq-handle-lane)]
-         (if (aput rq-handle-lane lane-state-ch
-                   (assoc m :res-ch res-ch))
+         (if (aput rq-handle-lane lane-state-ch (assoc m :res-ch res-ch))
            (atake rq-handle-lane res-ch)
            (assoc m :status :failed
                   :status-info [(:op m) :closed :dispatch-lane])))))
@@ -66,26 +85,6 @@
     (cbfg.world.t1/world-vis-init-t "cbfg.world.t2"
                                     cmd-handlers el-prefix
                                     cbfg.world.t1/ev-msg init-event-delay))
-
-; --------------------------------------------
-
-(defn server-handler [server-state m]
-  (case (:op m)
-    :authenticate
-    (if-let [{:keys [realm user pswd]} m]
-      (if (and realm user pswd)
-        (if (= pswd (get-in server-state [:realms realm :users user :pswd]))
-          [server-state (assoc (dissoc m :pswd) :status :ok)]
-          [server-state (assoc (dissoc m :pswd) :status :mismatch)])
-        [server-state (assoc (dissoc m :pswd) :status :invalid)])
-      [server-state (assoc (dissoc m :pswd) :status :invalid)])
-    nil))
-
-(defn lane-handler [lane-state m]
-  (case (:op m)
-    "realms-list"
-    [lane-state (assoc m :status :invalid)]
-    nil))

 ; --------------------------------------------


Load records in batch instead of one-by-one

--- src/cfpb/qu/loader.clj
+++ src/cfpb/qu/loader.clj
@@ -99,27 +99,36 @@

 (defn- load-csv-file
   "Given a table and CSV file name and the definitions of the table's
-columns, read the data from the CSV file, transform it, and insert it
-into the table."
+  columns, read the data from the CSV file, transform it, and insert
+  it into the table.
+
+  Steps:
+  1. We read in the data from the CSV.
+  2. We get the headers.
+  3. We split the data into chunks of 100, and in parallel,
+     transform each of those chunks into a map.
+  4. We insert each of those chunks into the DB in a batch load."
   [table file columns]
   (with-open [in-file (io/reader (io/resource file))]
     (let [data (csv/read-csv in-file)
           headers (map keyword (first data))
-          data (->> (rest data)
-                    (partition-all 100)
-                    (pmap (fn [chunk]
-                            (doall
-                             (map #(->> %
-                                        (zipmap headers)
-                                        (cast-data columns)) chunk))))
-                    (apply concat))]
-      (doseq [datum data]
-        (coll/insert table datum)))))
+          chunk-size 100
+          chunks (->> (rest data)
+                      (partition-all chunk-size)
+                      (pmap (fn [chunk]
+                              (doall
+                               (map #(->> %
+                                          (zipmap headers)
+                                          (cast-data columns)) chunk)))))]
+      (doseq [chunk chunks]
+        (coll/insert-batch table chunk)))))

 (defn load-dataset
   "Given the name of a dataset, load that dataset from disk into the
-database. The dataset must be under the datasets/ directory as a
-directory containing a definition.json and a set of CSV files."
+  database. The dataset must be under the datasets/ directory as a
+  directory containing a definition.json and a set of CSV files.
+
+  These files are loaded in parallel."
   [name]
   (let [dir (str "datasets/" name)
         definition (-> (str dir "/definition.json")
@@ -145,4 +154,3 @@

 ; (ensure-mongo-connection)
 ; (with-out-str (time (load-dataset "county_taxes")))
-; (with-out-str (time (pload-dataset "county_taxes")))


Updated little-float to be more general.

--- src/clj/forma/rain.clj
+++ src/clj/forma/rain.clj
@@ -105,27 +105,25 @@
 ;; using [big endian](http://goo.gl/os4SJ) format, by default. The
 ;; PRECL dataset was stored using [little endian](http://goo.gl/KUpiy)
 ;; floats, 4 bytes each. We define a function below that coerces
-;; groups of 4 bytes into a float.
+;; groups of little-endian bytes into a float.

 (defn little-float
-  "Converts four input bits to a float, in little endian
-  format. Special case of a more general `littleize` function, on the
-  horizon."
-  [b0 b1 b2 b3]
-  (Float/intBitsToFloat
-   (bit-or
-   (bit-shift-left b3 24)
-   (bit-or
-    (bit-shift-left (bit-and b2 0xff) 16)
-    (bit-or
-     (bit-shift-left (bit-and b1 0xff) 8)
-     (bit-and b0 0xff))))))
+  "Converts the supplied byte sequence into a float, in little endian
+  format."
+  [bitseq]
+  (->> bitseq
+       (map-indexed (fn [idx bit]
+                      (bit-shift-left
+                       (bit-and bit 0xff)
+                       (* 8 idx))))
+       (reduce +)
+       (Float/intBitsToFloat)))

 (defn little-floats
   "Converts the supplied byte array into a seq of
   little-endian-ordered floats."
   [bytes]
-  (vec (map (partial apply little-float)
+  (vec (map little-float
             (partition float-bytes bytes))))

 ;; As our goal is to process each file into the tuple-set described


don't append accounts when a map is specified

assume that if given a map of accounts, we're adding
accounts to an empty entity

--- src/clj_money/seed.clj
+++ src/clj_money/seed.clj
@@ -35,12 +35,14 @@
   (let [entity (->> (:entities context)
                     (filter #(= entity-name (:name %)))
                     first)]
-    (update-in context
-               [:accounts]
-               (fnil #(concat (accounts/select-by-entity-id storage-spec
-                                                            (:id entity))
-                              %)
-                     []))))
+    (if (-> context :accounts map?)
+      context
+      (update-in context
+                 [:accounts]
+                 (fnil #(concat (accounts/select-by-entity-id storage-spec
+                                                              (:id entity))
+                                %)
+                       [])))))

 (defn seed
   [user entity identifier]


Added get-by-id functionality

Added get-by-id functionality

--- bin/seminarski/db.clj
+++ bin/seminarski/db.clj
@@ -29,6 +29,10 @@
     (mquery/paginate :page page :per-page limit))
 )

+(defn get-by-id [col id]
+  (mcol/find-map-by-id db col (Integer/parseInt id))
+)
+
 (defn delete-data [col & {:keys [condition] :or {condition {}}}]
   (mcol/remove db col condition)
 )


resource path

resource path

--- bot/dl.clj
+++ bot/dl.clj
@@ -10,18 +10,22 @@

 (def db-spec {:classname "org.sqlite.JDBC"
               :subprotocol "sqlite"
-              :subname (.getPath (io/file (io/resource "butterfly.db")))})
+              :subname "./butterfly.db"})

 (defn- url-encode [url] (some-> url (java.net.URLEncoder/encode "UTF-8") (.replace "+" "%20")))

 (defn- parse-result [body]
   (let [{:keys [label score]} (first (json/decode body true))
         [genus species] (str/split label #" ")
-        {:keys [vn_name url]} (first (jdbc/query db-spec
-                                                 ["SELECT vn_name, url
+        {:keys [vn_name url]} (try
+                                (first (jdbc/query db-spec
+                                                   ["SELECT vn_name, url
                                                    FROM butterfly
                                                    WHERE genus = ? AND species = ?"
-                                                   genus (str/lower-case species)]))]
+                                                    genus (str/lower-case species)]))
+                                (catch Exception e
+                                  (println "caught exception: " (.getMessage e))
+                                  {:vn_name (str genus (str/lower-case species))}))]
     [vn_name (str genus (str/lower-case species) " - " score) url]))

 (defn- label-image [image-url]


added avoid model

added avoid model

--- src/crawler/corpus.clj
+++ src/crawler/corpus.clj
@@ -143,6 +143,40 @@
     [(count leaves)
      (count documents)]))

+(defn repair-leaf-fuck-up
+  "Try to repair the leaf node yield
+   rate along the current action seq
+
+   muscle URLs we want
+   fat URLs we don't"
+  [action-seq corpus muscle fat]
+  (let [documents (filter
+                   (fn [[u x]]
+                     (and (:leaf? x)
+                          (= (:src-xpath x)
+                             action-seq)))
+                   corpus)
+
+        src-urls (map
+                  (fn [[u x]]
+                    (:src-url x))
+                  documents)
+
+        src-docs (map
+                  #(corpus %)
+                  src-urls)
+
+        action-taken (first action-seq)]
+    (map
+     (fn [[u x]]
+      (dom/refine-xpath
+       action-taken
+       (:body x)
+       u
+       muscle
+       fat))
+     src-docs)))
+
 (defn refine-model-with-positions
   "Try to maximize the model yield with position info"
   [model corpus]
@@ -165,5 +199,15 @@
           (and (:leaf? x)
                (= (:src-xpath x)
                   action-seq)))
+        corpus))
+
+      :fat
+      (map
+       first
+       (filter
+        (fn [[u x]]
+          (and (not (:leaf? x))
+               (= (:src-xpath x)
+                  action-seq)))
         corpus))])
    model))


Fix #30

Fix #30

--- src/dakait/handler.clj
+++ src/dakait/handler.clj
@@ -23,11 +23,11 @@

 (defn as-json
   ([]
-   (as-json nil))
+   (as-json {}))
   ([m]
    { :status 200
     :headers { "Content-Type" "application/json; charset=utf-8" }
-    :body (when-not (nil? m) (json/write-str m)) }))
+    :body (json/write-str m) }))

 (defn as-json-error
   ([code error-message]


Dispatch when the control-panel is being shown

--- src/discuss/views.cljs
+++ src/discuss/views.cljs
@@ -81,9 +81,11 @@
                       ;; TODO: :find (om/build find/view data)
                       :create/argument (carg/create-argument-with-reference (om/props this))
                       (discussion-elements-next (om/props this)))
-                    (if (some #{view} [:login :options :find :reference-usages :eden/overview])
+                    (cond
+                      (some #{view} [:login :options :find :reference-usages :eden/overview])
                       (close-button-next)
-                      (control-elements-next))]]))))
+                      (some #{view} [:create/argument]) nil
+                      :default (control-elements-next))]]))))
 (def view-dispatcher-next (om/factory ViewDispatcher))

 (defui MainView


Add postgres/jdbc dependencies

Add postgres/jdbc dependencies

--- build.boot
+++ build.boot
@@ -50,6 +50,8 @@
                                           org.apache.httpcomponents/httpclient
                                           org.slf4j/slf4j-nop]]
                             [io.rkn/conformity "0.4.0"]
+                            [org.clojure/java.jdbc "0.6.1"]
+                            [org.postgresql/postgresql "9.4-1201-jdbc41"]

                             ;; Comic scraping
                             [clj-http "2.3.0"]


server-clj should be a dev dependency, so the main project can decide what version to use

--- build.boot
+++ build.boot
@@ -4,13 +4,11 @@
                   ; dev
                   [adzerk/bootlaces "0.1.13" :scope "test"]
                   [adzerk/boot-test "1.0.4"  :scope "test"]
+                  [alda/server-clj  "0.0.1"  :scope "test"]
                   [str-to-argv      "0.1.0"  :score "test"]

                   ; silence slf4j logging dammit
                   [org.slf4j/slf4j-nop        "1.7.21"]
-
-                  ; alda server / worker
-                  [alda/server-clj  "0.0.1"]

                   ; client
                   [com.beust/jcommander                 "1.48"]


Still hardcoded

Still hardcoded

--- src/edge/webserver.clj
+++ src/edge/webserver.clj
@@ -17,6 +17,22 @@

 (def URI "http://live-cdn.me-tail.net/cantor/api/wanda/garment-details/81e36a81-1921-4247-a8de-1ed7eb67840f?skus=nct_sandbox_dress_37_7cpxa7,nct_sandbox_trousers_2_5bahk2,nct_sandbox_jacket_4_btcjsf,nct_sandbox_coat_3_vxbetj,nct_sandbox_top_24_7k94td,nct_sandbox_skirt_15_04s5md,nct_sandbox_top_15_zwzenw")

+(def app-state
+  (atom
+   {:garments/by-id
+    {"nct_sandbox_dress_37_7cpxa7"
+     {:name "Dress"
+      :colour "Yellow"
+      :description "A nice dress"}
+     "nct_sandbox_jacket_4_btcjsf"
+     {:name "Jacket"
+      :colour "Blue"
+      :description "Very fetching"}
+     "nct_sandbox_trousers_2_5bahk2"
+     {:name "Trousers"
+      :colour "Brown"
+      :description "What's more to say??"}}}))
+
 (defn get-garments [uri]
   {:garments
    (let [response (deref (http/get uri))]
@@ -24,74 +40,29 @@
        (json/decode (b/to-string (:body response)) keyword)
        (throw (Exception. "Oh no!!!"))))})

-#_(defmulti read (fn [_ k _] k))
-#_(defmulti mutate (fn [_ k _] k))
-
-#_(defmethod read :default [env k params]
+(defn readf [env k params]
   (let [st @(:state env)]
     (if-let [[_ v] (find st k)]
       {:value v}
       {:value :not-found})))

-#_(defn readf [env k params]
-  (infof "READ! %s %s" k (:state env))
-  {k "ABC"}
-  )
+(defn mutatef [env k params]
+  (infof "MUTATE! %s" k)
+  {})

-#_(defn mutatef [env k params]
-  (infof "MUTATE! %s" k)
-  )
+(defn om-resource [parser app-state]
+  (resource
+   {:methods
+    {:post
+     {:consumes "application/transit+json"
+      :produces "application/transit+json"
+      :response (fn [ctx] (parser {:state app-state} (:body ctx)))}}}))

-#_(let [parser (om/parser {:read readf :mutate mutatef})]
-  (parser {:state {:a "A"}} '[:a]))
-
-(defn create-api []
+(defn create-api [parser]
   ["/"
    [
     ["garments" (yada (get-garments URI))]
-
-    ["api" (yada
-            (resource
-             {:methods
-              {:post
-               {:consumes "application/transit+json"
-                :produces "application/transit+json"
-                :response (fn [ctx]
-                            (infof "Message received: %s" (:body ctx))
-
-
-                            {:garments/by-id {"nct_sandbox_dress_37_7cpxa7"
-                                              {:name "SDress"
-                                               :colour "Yellow"
-                                               :description "A nice dress"}
-                                              "nct_sandbox_jacket_4_btcjsf"
-                                              {:name "SJacket"
-                                               :colour "Blue"
-                                               :description "Very fetching"}
-                                              "nct_sandbox_trousers_2_5bahk2"
-                                              {:name "STrousers"
-                                               :colour "Brown"
-                                               :description "What's more to say?"}}}
-
-
-                            #_(let [parser (om/parser {:read readf :mutate mutatef})]
-
-                              (parser)
-
-                              #_{"nct_sandbox_dress_37_7cpxa7"
-                                 {:name "Dress"
-                                  :colour "Yellow"
-                                  :description "A nice dress"}
-                                 "nct_sandbox_jacket_4_btcjsf"
-                                 {:name "Jacket"
-                                  :colour "Blue"
-                                  :description "Very fetching"}
-                                 "nct_sandbox_trousers_2_5bahk2"
-                                 {:name "Trousers"
-                                  :colour "Brown"
-                                  :description "What's more to say?"}}))}
-               }}))]
-
+    ["api" (yada (om-resource parser app-state))]
     ["" (redirect "index.html")]
     ["favicon.ico" (yada nil)]
     ["" (yada (io/file "target/dev"))]
@@ -102,7 +73,7 @@
                         api]
   Lifecycle
   (start [component]
-    (let [api (create-api)]
+    (let [api (create-api (om/parser {:read readf :mutate mutatef}))]
       (assoc component
              :server (http/start-server (make-handler api) component)
              :api api)))


Highlight edges adjacent to selected node

--- src/graphito/core.cljs
+++ src/graphito/core.cljs
@@ -36,6 +36,8 @@
 (def displacement-factor 1)

 (def max-radius 32)
+(def link-width 3)
+(def selected-link-width 5)
 (def label-font "Verdana")
 (def label-font-size 24)
 (def hitbox-size 96)
@@ -44,6 +46,7 @@

 (def background-color "#EDF0F2")
 (def link-color "#C9CBCB")
+(def selected-link-color "#a7b6c2")
 (def node-color "#777A7A")
 (def node-label-color node-color)
 (def selected-node-color "#FE9F51")
@@ -206,6 +209,13 @@
           (.attr "class" "link")
           (.style "stroke" link-color)
           (.style "stroke-width" 3))
+      (-> link-selection
+          (.style "stroke" link-color)
+          (.style "stroke-width" link-width)
+          (.filter (fn [link] (or (= (:source link) (:index selected-node))
+                                  (= (:target link) (:index selected-node)))))
+          (.style "stroke" selected-link-color)
+          (.style "stroke-width" selected-link-width))
       (-> link-selection
           maybe-transition
           (.attr "x1" #(-> % :source positions v/x))
@@ -243,7 +253,7 @@
           (.remove))
       (-> node-selection
           (.style "fill"
-                  #(if (= % selected-node) selected-node-color node-color))
+                  #(if (identical? % selected-node) selected-node-color node-color))
           maybe-transition
           (.attr "transform"
                  (fn [node]
@@ -257,7 +267,7 @@
           (.attr "opacity" (fn [node]
                              (project-label-opacity (distance-for-node node))))
           (.attr "font-weight" (fn [node]
-                                 (if (= node selected-node) "bold" "normal")))
+                                 (if (identical? node selected-node) "bold" "normal")))
           (.text #(:title %))))
     (.classed detail-button "invisible" (or (nil? selected-node)
                                             (= projection :zoom-out)))
@@ -285,7 +295,7 @@
 (defn deselect-node-if-away! [current-state]
   (when-let [selected-node (:selected-node @current-state)]
     (when (and (> (scaled-distance-from-camera @current-state (:pos selected-node))
-                   deselection-distance)
+                  deselection-distance)
                (= (:projection @current-state) :fisheye))
       (swap! current-state assoc :selected-node nil))))

@@ -627,18 +637,18 @@
 (defn zoom-and-select-on-tap! [manager current-state animation-observable]
   (let [taps (tap-observable manager)
         partitions (-> taps
-            (suppress-while-animating animation-observable)
-            (.map #(closest-node @current-state %))
-            (.partition #(< (:distance %) (/ hitbox-size 2))))
+                       (suppress-while-animating animation-observable)
+                       (.map #(closest-node @current-state %))
+                       (.partition #(< (:distance %) (/ hitbox-size 2))))
         node-taps (aget partitions 0)
         space-taps (.map (aget partitions 1) #(:pos %))]
-        (.subscribe node-taps
-                    (fn [{:keys [node]}]
-                        (select-and-zoom-to-node! current-state node)))
-        (.subscribe space-taps
-                    #(if (= (:projection @current-state) :zoom-out)
-                       (zoom-in-to-pos! current-state
-                                        (zoom-out->world-pos @current-state %))))))
+    (.subscribe node-taps
+                (fn [{:keys [node]}]
+                  (select-and-zoom-to-node! current-state node)))
+    (.subscribe space-taps
+                #(if (= (:projection @current-state) :zoom-out)
+                   (zoom-in-to-pos! current-state
+                                    (zoom-out->world-pos @current-state %))))))

 ;; Exported function to do magic


Integrate Thin_Aerofoil_Theory.clj into core.clj

--- src/hydrofoil/core.clj
+++ src/hydrofoil/core.clj
@@ -1,8 +1,8 @@
 (ns hydrofoil.core
   (:require [clojure.data.json :as json]
             [hydrofoil.evolution :refer :all]
-            [hydrofoil.model :refer :all]
-            [hydrofoil.utils :refer :all]))
+            [hydrofoil.utils :refer :all]
+            [hydrofoil.Model.Thin_Aerofoil_Theory :refer :all]))

 (defn run-constants
   [dencity velocity angle-of-attack]
@@ -60,5 +60,6 @@

         )))))

-
-
+(defn -main [angle-of-attack]
+  ;(println (inc  (Integer/parseInt angle-of-attack))))
+  (hill-climber 10000 (run-constants 1 50 (Integer/parseInt angle-of-attack))))


Update print statements to print only when a child beats a parent

--- src/hydrofoil/core.clj
+++ src/hydrofoil/core.clj
@@ -16,31 +16,53 @@
             :angle-of-attack angle-of-attack
             :angle-of-attack-radians (*(/ (Math/PI) 180) angle-of-attack)))

+
 (defn hill-climber [max-tries run-constants]
   (loop [parent (rand-individual)
          num-tries 1
-         performance-data {}]
+         performance-data '()]
     (let [child (new-indv parent)
-          parent-score (:lift (lift-function parent run-constants))
-          child-score (:lift (lift-function child run-constants))]
+          parent-performance (lift-function parent run-constants)
+          parent-score (:lift parent-performance)
+          child-score (:lift (lift-function child run-constants))
+          cl (:cl parent-performance)]
+
       (if (>= num-tries max-tries)
-        parent
+
+        (do (print performance-data)
+            parent)
+
         (if (> child-score parent-score)

-          (if (mod num-tries 100)
-            (do (print performance-data)
-                (recur child (inc num-tries) (conj parent {:generation num-tries :lift parent :cl parent})))
-            (recur child (inc num-tries) {}))
+          (if (= (mod num-tries 250) 0)
+            (do (println performance-data)
+                (println "")
+                (recur child (inc num-tries) '() ))
+            (recur child (inc num-tries) (conj performance-data (conj parent {:lift parent-score :cl cl}))))

-          (if (mod num-tries 100)
-            (do (print performance-data)
-                (recur parent (inc num-tries) (conj parent {:generation num-tries :lift parent-score :cl parent})))
-            (recur parent (inc num-tries) {}))
+          (recur parent (inc num-tries) performance-data)
+
+          ;(if (= (mod num-tries 250) 0)
+          ;  (do (println performance-data)
+           ;     (recur parent (inc num-tries) '()))
+           ; (recur parent (inc num-tries) (conj performance-data (conj parent {:lift parent-score :cl cl}))))

         )))))

 (defn -main [& args]
-  (hill-climber 1000 (run-constants 1 5 5)))
+  (hill-climber 1000 (run-constants 1 50 -10)))
+
+(lift-function (NACA-design 5 5 12) (run-constants 1 1 5))
+
+;(conj performance-data (conj {:generation num-tries} (conj {:lift parent-score :cl cl} parent))
+
+
+
+
+
+
+      ;((conj parent {:generation num-tries :lift parent-score :cl cl}))
+

 ;(lift-function (hill-climber 20 (run-constants 1 5 5)) (run-constants 1 5 5))


no need to duplicate the class import list

--- src/insn/namespace.clj
+++ src/insn/namespace.clj
@@ -2,28 +2,19 @@
   "Namespace utils.")

 (def ^:private asm-import-decl
-  (if (or (System/getProperty "insn.objectweb-asm")
-          (find-ns 'insn.objectweb-asm))
-    '[org.objectweb.asm
-      AnnotationVisitor
-      ClassVisitor
-      ClassWriter
-      FieldVisitor
-      Handle
-      Label
-      MethodVisitor
-      Opcodes
-      Type]
-    '[clojure.asm
-      AnnotationVisitor
-      ClassVisitor
-      ClassWriter
-      FieldVisitor
-      Handle
-      Label
-      MethodVisitor
-      Opcodes
-      Type]))
+  (cons (if (or (System/getProperty "insn.objectweb-asm")
+                (find-ns 'insn.objectweb-asm))
+          'org.objectweb.asm
+          'clojure.asm)
+        '[AnnotationVisitor
+          ClassVisitor
+          ClassWriter
+          FieldVisitor
+          Handle
+          Label
+          MethodVisitor
+          Opcodes
+          Type]))

 (def ^:private import-decls
   (list asm-import-decl


api: add hook for graphite query. brings us closer to #137

--- src/io/cyanite/api.clj
+++ src/io/cyanite/api.clj
@@ -9,6 +9,7 @@
             [io.cyanite.engine.buckets  :as b]
             [io.cyanite.index           :as index]
             [io.cyanite.store           :as store]
+            [io.cyanite.query           :as query]
             [qbits.jet.server           :refer [run-jetty]]
             [io.cyanite.utils           :refer [nbhm assoc-if-absent! now!]]
             [clojure.tools.logging      :refer [info debug error]]
@@ -88,6 +89,14 @@
   [{{:keys [query]} :params index :index}]
   (index/matches index (if (blank? query) "*" query) false))

+(defmethod dispatch :query
+  [{{:keys [from to query]} :params :keys [index store engine]}]
+  (let [from  (or (parse-time from)
+                  (throw (ex-info "missing from parameter"
+                                  {:suppress? true :status 400})))
+        to    (or (parse-time to) (now!))]
+    (query/run-query! store index engine from to query)))
+
 (defmethod dispatch :metrics
   [{{:keys [from to path agg]} :params :keys [index store engine]}]
   (let [from  (or (parse-time from)
@@ -98,7 +107,7 @@
                            (if (sequential? path) path [path]))
                    (map (partial engine/resolution engine from))
                    (remove nil?))]
-    (store/query! store from to paths)))
+    (store/query! store index engine from to paths)))

 (defmethod dispatch :default
   [_]


Everything working, including reactor

Everything working, including reactor

Now I need to polish the API (convenience stuff)
Probably tweak the reactor signature to take the pad as an input
Probably rename make-launchpad to get-launchpad, and memoize it.

  ;; Roxanne!
  (use 'launchpad.core)
  (def pad (make-launchpad)
  (defn redlight [what where val]
   (.light pad what where [3 0]))

--- src/launchpad/core.clj
+++ src/launchpad/core.clj
@@ -137,6 +137,8 @@
     (.update! this (.light (.state this) what where color)))
   (unlight [this what where]
     (.light this what where [0 0]))
+  (react [this f]
+    (.update! this (.react (.state this) f)))
   GetState
   (state [this] @state)
   ILaunchpad
@@ -174,10 +176,13 @@
   (.setReceiver
    midi-in
    (reify javax.sound.midi.Receiver
+     (close [this])
      (send [this msg ts]
-       (when-let [reactor (.reactor pad)]
-         (when-let [msg (decode-midi msg)]
+       (let [reactor (.reactor (.state pad))
+             msg (decode-midi msg)]
+         (when (and reactor msg)
            (apply reactor msg)))))))
+

 (defn make-launchpad
   "Make a LaunchpadS corresponding to the last real launchpad device listed
@@ -193,4 +198,5 @@
      (when-let [pad (Launchpad. (atom state) midi-in midi-out)]
        (do
          (link-midi->pad midi-in pad)
+         (.reset pad)
          pad)))))


add missing protocol fn implementation

add missing protocol fn implementation

--- src/asphalt/core.clj
+++ src/asphalt/core.clj
@@ -55,23 +55,25 @@
         ^JdbcEventListener stmt-creation-listener (as-jdbc-event-listener stmt-creation)
         ^JdbcEventListener sql-execution-listener (as-jdbc-event-listener sql-execution)
         nanos-now (fn (^long [] (System/nanoTime))
-                    (^long [^long start] (- (System/nanoTime) start)))]
+                    (^long [^long start] (- (System/nanoTime) start)))
+        make-conn (fn [f] (let [event :jdbc-connection-creation-event
+                                ^String id (.before conn-creation-listener event)
+                                start (nanos-now)]
+                            (try
+                              (let [result (ConnectionWrapper.
+                                             (f connection-source)
+                                             i/jdbc-event-factory
+                                             stmt-creation-listener sql-execution-listener)]
+                                (.onSuccess conn-creation-listener id (nanos-now start) event)
+                                result)
+                              (catch Exception e
+                                (.onError conn-creation-listener id (nanos-now start) event e)
+                                (throw e))
+                              (finally
+                                (.lastly conn-creation-listener id (nanos-now start) event)))))]
     (reify t/IConnectionSource
-      (obtain-connection            [this] (let [event :jdbc-connection-creation-event
-                                                 ^String id (.before conn-creation-listener event)
-                                                 start (nanos-now)]
-                                             (try
-                                               (let [result (ConnectionWrapper.
-                                                              (t/obtain-connection connection-source)
-                                                              i/jdbc-event-factory
-                                                              stmt-creation-listener sql-execution-listener)]
-                                                 (.onSuccess conn-creation-listener id (nanos-now start) event)
-                                                 result)
-                                               (catch Exception e
-                                                 (.onError conn-creation-listener id (nanos-now start) event e)
-                                                 (throw e))
-                                               (finally
-                                                 (.lastly conn-creation-listener id (nanos-now start) event)))))
+      (create-connection            [this] (make-conn t/create-connection))
+      (obtain-connection            [this] (make-conn t/obtain-connection))
       (return-connection [this connection] (t/return-connection connection-source connection)))))


improve logging at WARN level

improve logging at WARN level

--- src/babel/cache.cljc
+++ src/babel/cache.cljc
@@ -157,12 +157,13 @@
     (lazy-shuffle result)))

 (defn get-head-phrases-of [parent cache]
-  (let [result (:head-phrases (get cache (get-in parent [:rule])))
-        result (if (nil? result) (list) result)
-        label (label-of parent)]
-    (if (empty? result)
-      (log/warn (str "headed-phrases of parent: " label " is empty.")))
-    (lazy-shuffle result)))
+  (if (= true (get-in parent [:head :phrasal] :true))
+    (let [result (:head-phrases (get cache (get-in parent [:rule])))
+          result (if (nil? result) (list) result)
+          label (label-of parent)]
+      (if (empty? result)
+        (log/warn (str "headed-phrases of parent: " label " is empty: " (get-in parent [:head]))))
+      (lazy-shuffle result))))

 (defn get-comp-phrases-of [parent cache]
   (let [result (:comp-phrases (get cache (get-in parent [:rule])))


+(defn parse-from-file)

+(defn parse-from-file)

--- src/babel/parse.cljc
+++ src/babel/parse.cljc
@@ -124,6 +124,14 @@
                                 ;; </value>
                                 })
                              (get span-map n)))))))
+
+(declare parse)
+
+(defn parse-from-file [reader]
+  "parse linefeed-separated file line-by-line."
+  (map parse
+       (line-seq reader)))
+
 (defn parse
   "return a list of all possible parse trees for a string or a sequence of tokens.
    If the input is a string, then use a language-independent tokenizer to turn the string into a sequence of tokens.


spacing

spacing

--- src/babel/reader.clj
+++ src/babel/reader.clj
@@ -47,13 +47,14 @@

     ;; get the structure of a random expression in the target language that matches the specification _spec_.
     ;; TODO: this is wasteful - we are getting *all* possible expressions, when we only need one (random) expression.
+    ;; instead, we should use the target.surface as an input to a hash function; that is, ORDER BY
+    ;; the value of the hash function on each row.
     (let [results (db/exec-raw [(str "SELECT target.serialized::text AS target,target.surface
                                         FROM expression AS target
                                        WHERE target.language=?
                                          AND target.structure IS NOT NULL
                                          AND target.surface != ''
-                                         AND target.structure @> '" target-json-spec "'
-")
+                                         AND target.structure @> '" target-json-spec "'")
                                 [target-language]]
                                :results)]
       (if (empty? results)