Skip to content

Instantly share code, notes, and snippets.

View lbradstreet's full-sized avatar

Lucas Bradstreet lbradstreet

View GitHub Profile
{:user {:aliases {"slamhound" ["run" "-m" "slam.hound"]}
:plugins [[cider/cider-nrepl "0.6.1-SNAPSHOT"]
; swap to actual versions and then use lein ancient instead
[lein-git-deps "0.0.1-SNAPSHOT"]
[lein-bikeshed "RELEASE"]
[lein-kibit "RELEASE"]
[jonase/eastwood "RELEASE"]
(defn popover
"wrapper for the ReactBootstrap/Popover component"
[{:keys [content
title
data]} owner opts]
(reify
om/IRender
(render [this]
(ReactBootstrap/OverlayTrigger #js {:trigger "hover"
:placement "top"
(defmacro defntraced
"Define a function with it's inputs and output logged to the console."
[sym & body]
(let [[_ _ [_ & specs]] (macroexpand `(defn ~sym ~@body))
new-specs (map
(fn [[args body]]
(let [prns (for [arg args]
`(js/console.log (str '~arg) "=" (pr-str ~arg)))]
(list
args
@lbradstreet
lbradstreet / clojure-uuid-test-check
Last active August 29, 2015 14:04
Clojure test check uuid
(ns test-check-contrib.gen-uuid
(:require [clojure.string]
[clojure.test.check :as tc]
[clojure.test.check.generators :as gen]
[clojure.test.check.properties :as prop]
[clojure.test.check.clojure-test :refer [defspec]])
(:import [java.util UUID])
(:require [clojure.core :as core]))
(def gen-uuid-simple
@lbradstreet
lbradstreet / multipart upload
Last active August 29, 2015 14:06
multipart upload
[:div
[:b "Now that you've submitted your message, you can upload an image of your own, or read the messages"]
[:form.form-horizontal {:action "/upload" :method "post" :encType "multipart/form-data"}
[:div.form-group
[:input.form-control {:name "file"
:on-change (fn [e] (om/set-state! owner :can-upload-image true))
:type "file"
:size "20"}]
[:label.control-label "Who are you?"]
[:input.form-control {:name "person"}]
(ns onyx-timeline-example.onyx.component
(:require [clojure.core.async :as a :refer [go-loop pipe chan >!! <!! close!]]
[clojure.data.fressian :as fressian]
[clojure.core.match :as match :refer (match)]
[clojure.tools.logging :as log]
[com.stuartsierra.component :as component]
[onyx.peer.task-lifecycle-extensions :as l-ext]
[onyx.extensions :as extensions]
[onyx.api]
[onyx.plugin.core-async]
(filter even? (range 10))
;; equals
(new clojure.lang.LazySeq
(fn []
(when-let
[s (. clojure.lang.RT
(seq (new clojure.lang.LazySeq
#(let [b (clojure.lang.ChunkBuffer. 32)
@lbradstreet
lbradstreet / BootTime
Created January 29, 2015 16:48
Boot hello-world startup time
#!/usr/bin/env boot
(require '[clojure.string :refer [join]])
(defn -main [& args]
(println (join " " ["hello," "world!"]))
(System/exit 0))
./hello.boot 8.64s user 0.46s system 383% cpu 2.375 total
(defn with-env-peers [env-config peer-config n-peers f]
(let [env (onyx.api/start-env env-config)
v-peers (onyx.api/start-peers! n-peers peer-config)]
(try
(f)
(finally
(doseq [v-peer v-peers]
(onyx.api/shutdown-peer v-peer))
(onyx.api/shutdown-env env)))))

The Anatomy of an Onyx Program

In this tutorial, we'll take an in-depth view of what's happening when you execute a simple Onyx program. All of the code can be found in the Onyx Starter repository if you'd like to follow along. The code uses the development environment with HornetQ and ZooKeeper running in memory, so you don't need additional dependencies to run the example for yourself on your machine.

The Workflow

At the core of the program is the workflow - the flow of data that we ingest, apply transformations to, and send to an output for storage. In this program, we're going to ingest some sentences from an input source, split the sentence into individual words, play with capitalization, and add a suffix. Finally, we'll send the transformed data to an output source.

Let's examine the workflow pictorially: