Skip to content

Instantly share code, notes, and snippets.

Avatar
😀

Gardner Vickers gardnervickers

😀
View GitHub Profile
View gist:7106790
(ns statefunction.web
(:require [compojure.core :refer [defroutes GET PUT POST DELETE ANY]]
[compojure.handler :refer [site]]
[compojure.route :as route]
[clojure.java.io :as io]
[ring.middleware.stacktrace :as trace]
[ring.middleware.session :as session]
[ring.middleware.session.cookie :as cookie]
[ring.adapter.jetty :as jetty]
[ring.middleware.basic-authentication :as basic]
View onyx_ns_load.clj
(ns flat-workflow.functions.sample-functions)
(defn ^{:batch-size 10 :onyx? true} increment-age [segment]
(update-in segment [:age] inc))
(defn ^{:batch-size 10 :onyx? true} legal?
"hello world"
[age segment]
age)
View gist:9e915efc3ec875c68bcd
Executing before task -=___ Peer 1 starts task/job and batch
Executing before batch -=__/ Segments are loaded through the :core.async/read-from-chan :in
Executing after batch -=__/
Executing before batch -=___ Segments are loaded into the :inc function and processed
Executing after batch -=__/
Executing before batch -=___ Segments are loaded through the :core.async/write-to-chan :out
Executing after task -=___ Why does this happen *before* "Executing after batch"
Executing after batch -=__/
@gardnervickers
gardnervickers / gist:178f4c4ac0607f6275c5
Last active Aug 29, 2015
Read json file and parse to edn with core.async
View gist:178f4c4ac0607f6275c5
(defn try-parse [x]
(try
(json/parse-string x true)
(catch Exception e
x)))
(defn lazy-test-data []
"Returns a channel that reads json maps line by line from mock_data.json "
(let [channel (chan 5 (map try-parse))]
(future (with-open [rdr (clojure.java.io/reader "resources/mock_data.json")]
View gist:0e6f5b6c00ab7197eb04
;; Code
[[:in :concat-names]
[:concat-names :parse-dates]
[:parse-dates :time-left]
[:time-left :notify-near-expiration]
[:notify-near-expiration :out]
[:time-left :out]]
;; What the code means
:in ; Read data line-by-line from a file
View gist:a6f326e04c26597e8f0f
(defn gen-contact-table
[size]
(mapv (fn [i]
{:name (str (rand-nth ["Gardner" "Mike" "Matt" "Jordan" "Vinny" "Jacob"])
" "
(rand-nth ["Vickers" "Heskie" "Dawson" "Carol" "Stark"]))
:email (rand-nth ["gardner@vickers.me" "test@test.com" "fakemail@inva.lid"])
:position (rand-nth ["floor-sweeper" "cart-pusher" "president"])
:company (rand-nth ["mcdonalds" "carousel" "medlyfe" "YoloCorp"])
:expertise [(rand-nth ["avaya" "nortel" "cisco" "alarmtraq"])
View setjdk
function setjdk() {
if [ $# -ne 0 ]; then
removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin'
if [ -n "${JAVA_HOME+x}" ]; then
removeFromPath $JAVA_HOME
fi
export JAVA_HOME=`/usr/libexec/java_home -v $@`
export PATH=$JAVA_HOME/bin:$PATH
fi
}
View gist:dddfd447016d03a3edf6
mv lib lib2 // Moved the symlink
cp lib2 ~/jars // copied the jars from lib2 to ~/jars
cp -r lib2 ~/jars // recursive copy ^^
cp -r lib2 ~/jars // recursive copy ^^
sudo cp -r lib2 ~/jars // recursive copy ^^ sudo
find lib2 -user root -exec cp {} ~/lib/{} \; // copy jars owned by root to ~/lib in my local
find lib2/ -user root -exec cp {} ~/lib/{} \; // sudo copy jars owned by root to ~/lib in my local
ls lib2
mv lib2 lib // reset lib2 to lib
View gist:2ec104687b44b7fe36a0
[:pdf-table
[10 20 15]
["foo" [:chunk {:style :bold} "bar"] [:phrase "baz"]]
[[:pdf-cell "foo"] [:pdf-cell "foo"] [:pdf-cell "foo"]]
[[:pdf-cell "foo"] [:pdf-cell "foo"] [:pdf-cell "foo"]]]