Skip to content

Instantly share code, notes, and snippets.

@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)
@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 / cljs-perf.core
Created November 20, 2017 20:01
js->clj using transients
(ns cljs_perf.core
(:require [goog.object :as gobject]))
(def data "[\n {\n \"_id\": \"5a1313dbcb701efd98a8e0e0\",\n \"index\": 0,\n \"guid\": \"e2e397fb-8d26-48e0-82a9-6a66433fa2ac\",\n \"isActive\": false,\n \"balance\": \"$1,369.60\",\n \"picture\": \"http://placehold.it/32x32\",\n \"age\": 35,\n \"eyeColor\": \"green\",\n \"name\": \"Duran Bond\",\n \"gender\": \"male\",\n \"company\": \"SPRINGBEE\",\n \"email\": \"duranbond@springbee.com\",\n \"phone\": \"+1 (881) 448-3188\",\n \"address\": \"189 Centre Street, Nicholson, New Mexico, 5961\",\n \"about\": \"Excepteur eu incididunt qui fugiat proident. Ut voluptate elit anim mollit aliqua elit in ut aliqua. Anim ad nisi consequat incididunt aute sunt consectetur labore ipsum deserunt proident. Est nisi est adipisicing ea anim id excepteur aliqua fugiat. Sunt ex cillum officia Lorem laboris. Consequat qui qui anim do minim adipisicing laboris Lorem irure reprehenderit duis veniam minim. Non quis tempor esse a
@thosmos
thosmos / cljs_perf.core.cljs
Created October 21, 2016 07:24
js->clj using transients
(ns cljs_perf.core
(:require [goog.object :as gobject]))
(let [data
"[{ \"web-app\": { \"servlet\": [ { \"servlet-name\": \"cofaxCDS\", \"servlet-class\": \"org.cofax.cds.CDSServlet\", \"init-param\": { \"configGlossary:installationAt\": \"Philadelphia, PA\", \"configGlossary:adminEmail\": \"ksm@pobox.com\", \"configGlossary:poweredBy\": \"Cofax\", \"configGlossary:poweredByIcon\": \"/images/cofax.gif\", \"configGlossary:staticPath\": \"/content/static\", \"templateProcessorClass\": \"org.cofax.WysiwygTemplate\", \"templateLoaderClass\": \"org.cofax.FilesTemplateLoader\", \"templatePath\": \"templates\" } }, { \"servlet-name\": \"cofaxAdmin\", \"servlet-class\": \"org.cofax.cds.AdminServlet\" }, { \"servlet-name\": \"cofaxTools\", \"servlet-class\": \"org.cofax.cms.CofaxToolsServlet\", \"init-param\": { \"templatePath\": \"toolstemplates/\", \"log\": 1, \"logLocation\": \"/usr/local/tomcat/logs/CofaxTools.log\", \"logMaxSize\": \"\", \"dataLog\": 1, \"dataLogLocation\": \"/usr/local/tomcat/logs/dataL
@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))))
(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 / core.cljs
Last active November 11, 2015 19:01
Om Next Ident + IKey
(ns om-tutorial.core
(:require [goog.dom :as gdom]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[cljs.pprint :as pprint]))
(enable-console-print!)
(def conn
(d/create-conn
@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]
@thosmos
thosmos / components.cljs
Last active August 29, 2015 14:11
Imagining atomatizing the App
;; see blog post here: http://code.thosmos.com/om/clojurescript/2014/12/15/imagining-atomatizing-the-app.html
{ :ns "hmmm.core"
:require ["om.core :as om :include-macros true"
"om.dom :as dom :include-macros true"]
:app {
:root [:app-state :app-def {:elementId "content"}]
@thosmos
thosmos / designer.html
Last active August 29, 2015 14:11
designer
<link href="../core-scaffold/core-scaffold.html" rel="import">
<link href="../core-header-panel/core-header-panel.html" rel="import">
<link href="../core-menu/core-menu.html" rel="import">
<link href="../core-item/core-item.html" rel="import">
<link href="../core-icon-button/core-icon-button.html" rel="import">
<link href="../core-toolbar/core-toolbar.html" rel="import">
<link href="../core-menu/core-submenu.html" rel="import">
<link href="../paper-button/paper-button.html" rel="import">
<link href="../paper-checkbox/paper-checkbox.html" rel="import">
<link href="../core-icons/core-icons.html" rel="import">