Skip to content

Instantly share code, notes, and snippets.

jgdavey / scratch.clj
Created Sep 30, 2016
Datomic Database Functions
View scratch.clj
;; Install boot.
;; In the same folder as this file, run:
;; boot -d com.datomic/datomic-free:0.9.5404 -r $PWD repl
(ns scratch
(:require [datomic.api :as d]))
(d/create-database "datomic:mem://scratch")
(def conn (d/connect "datomic:mem://scratch"))
(def schema

Keybase proof

I hereby claim:

  • I am jgdavey on github.
  • I am joshuadavey ( on keybase.
  • I have a public key ASC8tdiHKKv4NE6qgIYzZDyVegyL9IrqEoKXxomWczwAuwo

To claim this, I am signing this object:

jgdavey / expiry_chan.clj
Last active Feb 12, 2016
Channel that excludes "old" items (defined by max-age-millis)
View expiry_chan.clj
(ns expiry-chan
(:require [clojure.core.async :as async :refer [go >! <! chan]]))
(defn expiry-chan [in max-age-millis]
(let [middler (chan 1024 (map #(vector (System/currentTimeMillis) %)))
out (chan)]
(async/pipe in middler)
(go (loop []
(if-let [[ts value] (<! middler)]
jgdavey / .vimrc
Created Feb 23, 2015
browser repl vimrc workaround
View .vimrc
function! s:brepl(remove) abort
if a:remove
call fireplace#platform().piggieback("", 1)
echo "Piggieback connection removed"
let form = '(do ' .
\ '(require ''adzerk.boot-cljs-repl)' .
\ '(let [env (adzerk.boot-cljs-repl/repl-env)]' .
\ ' (Thread/sleep 100)' .
\ ' env))'
jgdavey /
Created Jun 13, 2014
Clojure + vim: Basic Evaluation and Documentation

Vim is a powerful text editor. Clojure is a powerful programming language. While its been possible to edit Clojure code in vim for years, the toolchain has improved greatly over the past year. Today we're going to see how we can integrate vim with our Clojure REPL environment.

Life without integration

In a shell session, let's fire up a Clojure REPL. I'm going to use lein repl to do this. In another shell session, let's start vim and edit a clojure file.

jgdavey / projections.json
Created Apr 24, 2014
Clojure .projections.json
View projections.json
"*" : {
"start" : "lein repl",
"src/*.clj": {
"command": "namespace",
"alternate": "test/{}_test.clj",
"template": "(ns {dot|hyphenate})\n\n"
"test/*_test.clj": {
jgdavey / trace_paths.clj
Created Mar 4, 2014
How to get paths for map of sets?
View trace_paths.clj
(use 'clojure.test)
(deftest tracing-paths
(testing "trace-paths"
(is (= (trace-paths {:a nil} :a)
(is (= (trace-paths {:a #{:b}
:b nil} :a)
jgdavey / atomically
Created Dec 20, 2012
Verify a series of commits are atomic
View atomically
#!/usr/bin/env bash
if [ -n "$(git status --porcelain)" ]; then
echo "ERROR: You have a dirty working copy. This command would remove any files not already checked in"
exit 1
log() {
if [ -z "$quiet" ]; then
jgdavey /
Created May 14, 2012
Simulate network latency and packet loss on Mac OS X (requires sudo)
set -e
USAGE="Usage: $0 [ip_address | reset]"
if [ "$#" == "0" ]; then
echo "$USAGE"
exit 1
jgdavey / .gitconfig
Created Mar 30, 2012
Git alias to add untracked files
View .gitconfig
add-untracked = !"git status --porcelain | awk '/\\?\\?/{ print $2 }' | xargs git add"