Skip to content

Instantly share code, notes, and snippets.

View robert-stuttaford's full-sized avatar
💭
Clojure!

Robert Stuttaford robert-stuttaford

💭
Clojure!
View GitHub Profile
15-Aug-19 22:29:18 MacBook-Pro.local WARN [onyx.peer.task-lifecycle] -
java.lang.Thread.run Thread.java: 745
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 617
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1142
...
clojure.core.async/thread-call/fn async.clj: 405
onyx.peer.task-lifecycle.TaskLifeCycle/fn task_lifecycle.clj: 706
onyx.peer.task-lifecycle/run-task-lifecycle task_lifecycle.clj: 431
onyx.peer.task-lifecycle/write-batch task_lifecycle.clj: 304
onyx.plugin.datomic.DatomicLogInput/write-batch datomic.clj: 255
(ns onyx-tx-report-queue
(:require [clojure.core.async :refer [>!! alts!! chan close! put! thread]]
[clojure.tools.logging :as log]
;; :all so clj-refactor doesn't remove it:
[onyx.plugin.core-async :refer :all]
[datomic.api :as d])
(:import [java.util.concurrent TimeUnit]))
(defn prepare-datom [db [e a v tx added]]
[e (d/ident db a) v tx added])
(let [dt #(-> (clj-time.core/date-time 2015 % %2)
clj-time.coerce/to-date)
now (d/db (d/connect (db/database-uri :main)))]
[(db/conn (db/database-uri :main))
(vec
(for [db [now ;; 29th July 2015
(-> now
(d/since (dt 2 1))) ;; 1st Feb 2015
(-> now
(d/as-of (dt 2 1))) ;; 1st Feb 2015
@robert-stuttaford
robert-stuttaford / config.edn
Last active May 1, 2017 07:07
Using Onyx with Trapperkeeper
{:environment :production
:global {:logging-config "./logback.xml"}
:onyx {:job-scheduler :onyx.job-scheduler/balanced
:task-scheduler :onyx.task-scheduler/balanced
:peer-config {:onyx.messaging/impl :netty
:onyx.messaging/peer-port-range [40200 40220]
:onyx.messaging/peer-ports [40199]
:onyx.messaging/bind-addr "localhost"
:onyx.messaging/backpressure-strategy :high-restart-latency}
:peer-count 20
@robert-stuttaford
robert-stuttaford / scratch.clj
Created May 26, 2015 19:12
Testing behaviour of Datomic's :db/isComponent
(ns scratch
(:require [datomic.api :as d]))
(def u "datomic:mem://component-test")
(d/delete-database u)
(d/create-database u)
(def c (d/connect u))
@robert-stuttaford
robert-stuttaford / datomic.clj
Last active April 27, 2018 15:10
Handy protocols for working with Datomic
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Connection
(defprotocol DatomicConnection
(as-conn [_]))
(extend-protocol DatomicConnection
datomic.Connection
(as-conn [c] c)
datomic.db.Db
@robert-stuttaford
robert-stuttaford / start.cljs
Created August 21, 2014 13:07
Nicely grouped transaction logging in JS Console for Om apps
(ns app
(:require [om.core :as om :include-macros true]))
(defn log-tx [tx-data root-cursor]
(let [{:keys [path old-value new-value]} tx-data
c js/console]
(doto c (.group (str "TRANSACTION " path)) (.groupCollapsed "OLD"))
(prn (pr-str old-value))
(doto c (.groupEnd) (.group "NEW"))
(prn (pr-str new-value))
@robert-stuttaford
robert-stuttaford / notes.md
Last active August 29, 2015 13:56
Immutable data...base? Notes
@robert-stuttaford
robert-stuttaford / notes.md
Last active December 24, 2015 21:29
Gain massive leverage in your tech stack with Clojure: Notes