Skip to content

Instantly share code, notes, and snippets.


Chris Thompson teaforthecat

  • Saint Paul, MN
View GitHub Profile

Keybase proof

I hereby claim:

  • I am teaforthecat on github.
  • I am teaforthecat ( on keybase.
  • I have a public key ASB1dfXKtsulaHTXHgRPQC4pzMzpu2CbqIJGJOEw2whMcwo

To claim this, I am signing this object:

teaforthecat / personal_consumer.clj
Last active Dec 26, 2015
Consume a kafka message stream of filtered keys
View personal_consumer.clj
(def consumer-registry (atom {}))
(defn get-or-create-message-stream [topic]
(if-let [message-stream (get @consumer-registry topic)]
(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)
teaforthecat / jobs.clj
Created Dec 18, 2015
An onyx job builder, basically a shortcut to this: kafka-input->function->kafka-output
View jobs.clj
" 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 ( {} [:x.y/fn]))
(kafka/produce \"x.y..fn-input\" \"hello\")
(kafka/consume \"x.y..fn-output\") => \"hello-yo\"
(defn topic-reader [^String topic]
teaforthecat / clj-kafka-test.clj
Last active Dec 2, 2015
trying to fetch data from kafka, not being able to use "take"
View clj-kafka-test.clj
(defn consumer-config [] {"zookeeper.connect" "localhost:2182"
"" (str (java.util.UUID/randomUUID))
"auto.offset.reset" "smallest"
"auto.commit.enable" "false"})
(defn fetch-first [topic]
(with-resource [c (zk/consumer (consumer-config))]
(first (zk/messages c topic))))
teaforthecat / comment-or-uncomment-sexp.el
Created Oct 18, 2015
one function with a few lines addded to keep the structure of lisp forms when commenting a form inside another form
View comment-or-uncomment-sexp.el
(defun comment-sexp--raw ()
"Comment the sexp at point or ahead of point."
(pcase (or (bounds-of-thing-at-point 'sexp)
(skip-chars-forward "\r\n[:blank:]")
(bounds-of-thing-at-point 'sexp)))
(`(,l . ,r)
(goto-char r)
(skip-chars-forward "\r\n[:blank:]")
teaforthecat / gist:85c518b3164445602334
Last active Aug 29, 2015
neat idea to bookmark commands
View gist:85c518b3164445602334
;; 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))
View gist:d5921a1516f27877ddda
;; 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]]))
teaforthecat / project.clj
Created May 7, 2014
offending lein project file with dependencies configured to trigger a bug in clojurescript compilation. "NoSuchMethodError:"
View project.clj
(defproject intrepid-life-coffee "0.1.0-SNAPSHOT"
:description "website to advertise the coffee shop"
:url ""
:license {:name "Eclipse Public License"
:url ""}
:dependencies [[org.clojure/clojure "1.5.1"]
[compojure "1.1.6"]
[ring "1.2.1"]
[hiccup "1.0.5"]
;; [org.slf4j/log4j-over-slf4j "1.6.6"] ;;avoids dep loop
teaforthecat / common.yaml
Created Dec 1, 2013
puppet-hiera hash data access fails why?
View common.yaml
home: "%{gdnet_env}-netapp1:/vol/home/qtree0"
yum_cache: "%{gdnet_env}-netapp1:/vol/yum_cache/qtree0"
techops: "%{gdnet_env}-netapp1:/vol/techops/qtree0"
websites: "%{gdnet_env}-netapp1:/vol/websites_%{gdnet_env}/qtree0"
apache_logs: "%{gdnet_env}-netapp1:/vol/apache_logs_%{gdnet_env}/qtree0"
evolution_logs: "%{gdnet_env}-netapp1:/vol/evolution_logs_%{gdnet_env}/qtree0"
View ruby.el
(setq ruby-deep-indent-paren nil)
(defadvice ruby-indent-line (after unindent-closing-paren activate)
(let ((column (current-column))
indent offset)
(let ((state (syntax-ppss)))
(setq offset (- column (current-column)))
(when (and (eq (char-after) ?\))
(not (zerop (car state))))
You can’t perform that action at this time.