Skip to content

Instantly share code, notes, and snippets.


Keybase proof

I hereby claim:

  • I am thosmos on github.
  • I am thosmos ( on keybase.
  • I have a public key ASDr34LMnE3iK29HEAqWRne-zjMLUUaMIFwQSGTNQbpWYwo

To claim this, I am signing this object:

thosmos / benchmark-pristine->entity.cljs
Last active Feb 10, 2020
cljs benchmark pristine->entity
View benchmark-pristine->entity.cljs
(ns riverdb.ui.bench
[com.fulcrologic.fulcro.components :as comp :refer [defsc]]
[com.fulcrologic.fulcro.dom :as dom :refer [div]]
[com.fulcrologic.fulcro.algorithms.form-state :as fs]
[com.fulcrologic.fulcro.algorithms.normalize :as fnorm]))
(defsc Person [this props]
{:query [:db/id ::person-name ::person-age
thosmos / benchmark-pristine->entity
Created Feb 10, 2020
benchmark a few options for fulcro3 form-state/pristine->entity*
View benchmark-pristine->entity
(in-ns 'user)
'[com.fulcrologic.fulcro.components :as comp :refer [defsc]]
'[com.fulcrologic.fulcro.algorithms.form-state :as fs]
'[com.fulcrologic.fulcro.algorithms.normalize :as fnorm])
(defsc Person [this props]
{:query [:db/id ::person-name ::person-age
:ident [:person/id :db/id]
thosmos / validation.cljs
Created Feb 9, 2020
Fulcro Validator with custom error strings
View validation.cljs
(defn make-validator
"Create a form/field validation function using a supplied field checker. The field checker will be given
the entire form (denormalized) and a single field key that is to be checked. It must return
a boolean indicating if that given field is valid or not, or a custom error map if invalid.
During a recursive check for a form, the validation function will be in the correct context (e.g. the form supplied will contain
the field. There is no need to search for it in subforms).
make-validator returns a three arity function:
- `(fn [form] ...)` - Calling this version will return :unchecked, :valid, or :invalid for the entire form.
- `(fn [form field] ...)` - Calling this version will return :unchecked, :valid, or :invalid for the single field.
thosmos / about.cljs
Created Feb 16, 2019
fulcro code-split routing
View about.cljs
(defsc AboutComp [this {:keys [about/hello]}]
{:query [:about/hello]
:initial-state {:about/hello "Hello from the About module!"}}
(debug "Rendering AboutComp")
thosmos / 1_routing.cljs
Last active Feb 7, 2019
fulcro dynamic routing + code splitting
View 1_routing.cljs
(defsc-route-target AboutPage [this props]
{:query [{:about-comp ['*]}]
:ident (fn [] [:PAGE/by-id :about])
:initial-state {:about-comp {}}
:route-segment (fn [] ["about"])
:route-cancelled (fn [_])
:will-enter (fn [reconciler route-params]
(if (get-in @st/pending-route [:about :is-loaded])
(dr/route-immediate [:PAGE/by-id :about])
(dr/route-deferred [:PAGE/by-id :about]
thosmos / specfn.clj
Created Sep 5, 2018 — forked from borkdude/specfn.clj
Use a spec for defining function arguments and get validation automatically
View specfn.clj
(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 / firebase-firestore-externs.js
Created May 21, 2018
Externs for Google Firebase's Firestore
View firebase-firestore-externs.js
firebase.firestore = function(app) {}; = function(app) {};
firebase.firestore.Firestore = function() {};
firebase.firestore.Firestore = {};;
firebase.firestore.Firestore.setLogLevel = function(logLevel) {};
firebase.firestore.Firestore.prototype.batch = function () {};
firebase.firestore.Firestore.prototype.collection = function (collectionPath) {};
thosmos / cljs-perf.core
Created Nov 20, 2017
js->clj using transients
View cljs-perf.core
(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\": \"\",\n \"age\": 35,\n \"eyeColor\": \"green\",\n \"name\": \"Duran Bond\",\n \"gender\": \"male\",\n \"company\": \"SPRINGBEE\",\n \"email\": \"\",\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 / cljs_perf.core.cljs
Created Oct 21, 2016
js->clj using transients
View cljs_perf.core.cljs
(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\": \"\", \"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