Skip to content

Instantly share code, notes, and snippets.

stevebuik / gist:7a8b4a8bc63cec2a6f40
Last active Aug 29, 2015
Database function test case
View gist:7a8b4a8bc63cec2a6f40
(ns scratch.db-fns-test-case
[datomic.api :refer (q db) :as d]))
(def test-state (atom
{:db-str "datomic:free://localhost:4334/somedb"
(swap! test-state
stevebuik / parser.clj
Created Nov 1, 2015
An example of logging and sanitizing server parsers exceptions
View parser.clj
(defn handle
[env params]
(let [p (parser {:read readf
:mutate mutatef})
result (p env params)
errors (->> result
(filter (fn [[k v]] (instance? Throwable v))))]
(if (seq errors)
(doseq [[req res] errors]
View dali-sample
{:direction :down, :anchor :center, :gap 25, :position [100 100]}
{:direction :right, :anchor :left, :gap 25}
View gist:665511e028295f422ce21f2596b77c3a
(require '[ :as om])
(require '[clojure.pprint :refer [pprint]])
(def initial-state
{:root {:id 1
:name "root"
:type :branch
:children [{:id 2
:type :leaf
:name "first child"}
stevebuik / terse.clj
Created Jun 25, 2017
terse datomic schema vectors. based on ideas from this presentation at clj-syd
View terse.clj
(require '[clojure.pprint :refer [pprint]])
(require '[datomic.api :as d])
(require '[clojure.spec :as s])
(require '[clojure.spec.test :as st])
(s/def ::optional-attributes (s/* (s/alt :db/fulltext (s/and (partial = :fulltext)
; conformer should be last so that it returns the transformed value
(s/conformer (constantly true)))
:db/index (s/and (partial = :index)
(s/conformer (constantly true)))
View components.datomic.core-test.clj
(ns components.datomic.core-test
[clojure.pprint :refer [pprint]]
[clojure.test :refer :all]
[datomic.client.api :as d]
[datomic.client.api.impl :as di]
[datomic.api :as db-free])
(:import (java.util UUID)))
(declare test-conn)
View ion-release.clj
(defn release
"Do push and deploy of app. Supports stable and unstable releases. Returns when deploy finishes running."
(println "Pushing..")
(let [push-data (ion-dev/push args)
deploy-args (merge (select-keys args [:creds-profile :region :uname])
(select-keys push-data [:rev])
{:group group})]
(println "Deploying..")

Keybase proof

I hereby claim:

  • I am stevebuik on github.
  • I am beechhouses ( on keybase.
  • I have a public key ASD09p9I5oo2CA7Yos0DGyreoRyJrpE53h-09XoS39YebQo

To claim this, I am signing this object:

stevebuik / gist:e289d6783b43639726cbc39357728bbf
Created May 21, 2020
lacinia optional string params in mutations
View gist:e289d6783b43639726cbc39357728bbf
(ns tools.graphql-fiddle
(:require [clojure.pprint :refer [pprint]]
[com.walmartlabs.lacinia.schema :as schema]
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
[com.walmartlabs.lacinia :as lacinia]))
(def definition
{:objects {:person {:fields {:name '{:type String}
:nicknames '{:type (list String)}}}
:saveResult {:fields {:status '{:type String}}}}
stevebuik / recursive-malli-perf.clj
Created Dec 26, 2020
slow recursive validation in Malli
View recursive-malli-perf.clj
(ns recursive-malli-perf
(:require [malli.core :as m]
[criterium.core :as criterium]))
(def simple-node
[:name string?]])
(def simple-tree-node
[:and simple-node