Skip to content

Instantly share code, notes, and snippets.

@thosmos
thosmos / mock-connection.clj
Created October 21, 2015 18:17 — forked from vvvvalvalval/mock-connection.clj
Mocking datomic.Connection for fast in-memory testing
(ns bs.utils.mock-connection
"Utilities for using Datomic"
(:require [datomic.api :as d])
(:use clojure.repl clojure.pprint)
(:import (java.util.concurrent BlockingQueue LinkedBlockingDeque)
(datomic Connection)))
(defrecord MockConnection
[dbAtom, ^BlockingQueue txQueue]
(def views
{:some-view SomeView
:another-view AnotherView})
(def factories
(map om/factory (vals views)))
(defui Router
static om/Ident
(ident [this {:keys [route]}]
@thosmos
thosmos / broadbrim.datomic.api.cljc
Created December 16, 2015 07:59 — forked from domkm/broadbrim.datomic.api.cljc
Datomic EntityMap wrapper for DataScript consistency
;;;; Entity wrapper
#?(:clj (declare ->EntityMap))
#?(:clj (deftype EntityMap [^datomic.query.EntityMap entity ^boolean ident?]
Object
(hashCode [this]
(.hashCode entity))
(equals [this o]
(and (instance? (class this) o)
(.equals entity (.entity o))))
@thosmos
thosmos / firebase-firestore-externs.js
Created May 21, 2018 05:41
Externs for Google Firebase's Firestore
firebase.firestore = function(app) {};
firebase.app.App.prototype.firestore = function(app) {};
firebase.firestore.Firestore = function() {};
firebase.firestore.Firestore = {};
firebase.firestore.Firestore.app;
firebase.firestore.Firestore.DocumentData;
firebase.firestore.Firestore.setLogLevel = function(logLevel) {};
firebase.firestore.Firestore.prototype.batch = function () {};
firebase.firestore.Firestore.prototype.collection = function (collectionPath) {};
@thosmos
thosmos / specfn.clj
Created September 5, 2018 06:46 — forked from borkdude/specfn.clj
Use a spec for defining function arguments and get validation automatically
(ns specfn.core
(:require [clojure.spec :as s]
[clojure.spec.test :as t]))
(defn- spec-symbols [s]
(->> s
(drop 1)
(partition-all 2)
(map first)
(map name)