Skip to content

Instantly share code, notes, and snippets.

View jebberjeb's full-sized avatar

Jeb Beich jebberjeb

View GitHub Profile
@jebberjeb
jebberjeb / .from-virmc
Last active August 29, 2015 13:56
Use vim-fireplace to run unit tests, highlight failed test fns in red!
function! RunTests()
" reload the namespace
norm cpr
" setup
call clearmatches()
highlight Red ctermbg=darkred
redir => output
" use Clojure to do the real work, run tests,
(ns test-app.foo
(:require [clojure.java.io :as io])
(:import [java.util Properties]))
;;dotenv (w/ precedence per Colin -- shell > .env.foo > .env)
(defn f->p
[f]
(let [file (io/as-file f)]
(when (.exists file) (doto (Properties.) (.load (io/input-stream file))))))

State Monad

TL;DR I'll probably just use a macro

What

A structure which allows you to represent a computation as a sequence of steps. The monad allows you to decorate each step with additional processing rules.

  • Logging
(ns test-app.foo
(:require [taoensso.timbre.profiling :as p]
[datomic.api :as d]))
;; GOALS
;; * perf test both approaches
;; * compare size/complexity of code for boath approaches
;; Properties from input file. Only properties w/ even :id have been selected.
(def props-from-file
(ns test-app.bar)
(defmulti do-it :foo)
(defmethod do-it "foo"
[m]
"foo'd it")
(defmethod do-it "bar"
[m]
@jebberjeb
jebberjeb / todo.md
Last active December 30, 2015 04:39

Datomic

What

  • keystore data, w/o the tradeoffs of other nosql databases

  • ACID tx, joins, datalog, simple schema

  • "Facts dont change when you incorporate time"

  • SQL db in past, CRUD triggers, history tables
(ns testapp.core)
(def p (promise))
(.start (java.lang.Thread.
(fn []
(Thread/sleep 2000)
(deliver p "foozle")
(println "promise set"))))
(ns test-app.core)
(def v1 [4 5 6])
(def v2 [1 2 3])
(def m {0 7 1 8})
(def get* (fn [k a] (get a k)))
[(min-key first v1 v2)
(max-key (partial get* 0) v1 v2 m)]
(ns test-app.core)
(def h (atom (make-hierarchy)))
(swap! h derive ::square ::shape)
(swap! h derive ::red-square ::square)
(def one (isa? @h ::red-square ::shape)) ;; => true
(ns test-app.core)
(defprotocol Fooable
(foo [this f])
(bar [this b]))
(deftype FooPrinter []
Fooable
(foo [this f] (println "foo: " f))
(bar [this b] (println "bar: " b)))