I hereby claim:
- I am teaforthecat on github.
- I am teaforthecat (https://keybase.io/teaforthecat) on keybase.
- I have a public key ASB1dfXKtsulaHTXHgRPQC4pzMzpu2CbqIJGJOEw2whMcwo
To claim this, I am signing this object:
| ;; implicit upsert due to unique constraint on message | |
| ;; temp id will get replaced with real id if message exists | |
| (defn upsert-message-tx [greeting] | |
| (let [tempid (d/tempid :db.part/user -1 )] | |
| [{ :db/id tempid | |
| :greeting/message greeting} | |
| [:inc tempid :greeting/hit-count 1]])) |
| ;; not working: service is not found in services; | |
| (let ((service (prodigy-define-service | |
| :name "* head *" | |
| :cwd "~/.emacs.d/lisp" | |
| :command "head" | |
| :args '("my-functions.el") | |
| )) | |
| ) | |
| (prodigy-start-service service)) |
| (defun comment-sexp--raw () | |
| "Comment the sexp at point or ahead of point." | |
| (pcase (or (bounds-of-thing-at-point 'sexp) | |
| (save-excursion | |
| (skip-chars-forward "\r\n[:blank:]") | |
| (bounds-of-thing-at-point 'sexp))) | |
| (`(,l . ,r) | |
| (goto-char r) | |
| (skip-chars-forward "\r\n[:blank:]") | |
| (save-excursion |
| (defn consumer-config [] {"zookeeper.connect" "localhost:2182" | |
| "group.id" (str (java.util.UUID/randomUUID)) | |
| "auto.offset.reset" "smallest" | |
| "auto.commit.enable" "false"}) | |
| (defn fetch-first [topic] | |
| (with-resource [c (zk/consumer (consumer-config))] | |
| zk/shutdown | |
| (first (zk/messages c topic)))) |
| (ns bones.jobs | |
| " given a symbol and config, build all components of an onyx job | |
| with three tasks kafka-input->function->kafka-output | |
| (def x.y/fn [s] (str s \"-yo\")) | |
| (api/submit-jobs (bones.jobs/build-jobs {} [:x.y/fn])) | |
| (kafka/produce \"x.y..fn-input\" \"hello\") | |
| (kafka/consume \"x.y..fn-output\") => \"hello-yo\" | |
| ") | |
| (defn topic-reader [^String topic] |
| (def consumer-registry (atom {})) | |
| (defn get-or-create-message-stream [topic] | |
| (if-let [message-stream (get @consumer-registry topic)] | |
| message-stream | |
| (let [[cnsmr messages] (kafka/open-consumer "consumer-registry" topic) | |
| new-message-stream (ms/->source messages)] | |
| ;; create lifespan for consumer of 1 minute, should probably be a component | |
| (a/go (a/<! (a/timeout 60e3 )) | |
| (kafka/shutdown cnsmr) |
I hereby claim:
To claim this, I am signing this object:
| (defn detect-controls [{:keys [enter escape]}] | |
| (fn [keypress] | |
| (case (.-which keypress) | |
| 13 (enter) | |
| ;; chrome won't fire 27, so use on-blur instead | |
| 27 (escape) | |
| nil))) | |
| (defn field [form-type identifier attr html-attrs] | |
| (let [path [:editable form-type identifier :inputs attr] |
| (defn collate | |
| "This is a transducer for collecting things that are connected in series. It | |
| will store one previous input. The previous input can then be compared to it's | |
| successor using COMPARES-FN and optionally integrated into a single output | |
| using COLLATE-FN. | |
| COMPARES-FN must accept 2 arguments, being 2 inputs (which are in order) | |
| COLLATE-FN must accept 2 arguments, being an accumulator and an input | |
| COLLATE-FN is a reducing function. A third arg can be given as the starting |
| (defn date? | |
| "Ensure a date string is a date and after a cutoff date. This protects against technically valid but corrupt dates like from a century ago or in the future." | |
| ([s] | |
| ;; store the year 10 years from now so we don't have to compute it every call | |
| (date? s 2010 `~(+ 10 (clj-time.core/year (clj-time.core/now))))) | |
| ([s past-cutoff future-cutoff] | |
| (try | |
| (if-let [d | |
| (clj-time.format/parse |