Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am taylorSando on github.
  • I am taylorsando (https://keybase.io/taylorsando) on keybase.
  • I have a public key whose fingerprint is FEC4 DC18 F535 B5E3 D634 7926 AEB3 47B5 3773 442E

To claim this, I am signing this object:

@taylorSando
taylorSando / transact.clj
Created May 19, 2016 14:21
A way of enforcing transactions
(ns datomscript.model
(:require #?@(:clj [[datomic.api :as d]
[clojure.tools.logging :as log]])
#?@(:cljs [[datascript.core :as d]])
[clojure.string :as string]
[clojure.walk :as walk]))
(def vconcat (comp vec concat))
(defn get-model [models model-type]
@taylorSando
taylorSando / pr-opts.cljs
Created February 8, 2016 15:07
A way to have better function output using pr-str
;; Using defonce, because in a reloaded workflow, only want this to run once
;; Changes the default printing of the javascript source code of a function to just the function name.
;; Changes instances of dollar sign to dot, and underscores to hyphens.
;; cljs$core$pr_str would be cljs.core.pr-str instead
(defonce
ugly-pr-opts-hack
(set!
cljs.core/pr-opts
(let [old-pr-opts (cljs.core/pr-opts) ]
(fn []
@taylorSando
taylorSando / poller.clj
Last active November 3, 2015 19:48
Email polling
(ns workzone.services.email-poll
(:require [clojure.tools.logging :as log]
[clojure.core.async :as core.async]
[clojure.set]
[workzone.model.error :as model.error]
[plumbing.core :refer :all]
[puppetlabs.trapperkeeper.core :refer [defservice]])
(:import javax.mail.Flags
javax.mail.Message
javax.mail.internet.InternetAddress
@taylorSando
taylorSando / selector.clj
Created November 1, 2015 20:38
A simple selector
(defn is-predicate-keyword? [k]
(= (last (name k)) (last "?") ))
(reduce
(fn [acc [k v]]
(if (is-predicate-keyword? k)
(if (true? v)
(conj acc (apply str (butlast (name k))))
acc)
acc))
@taylorSando
taylorSando / material-ui-reagent.clj
Created March 12, 2015 04:10
Material UI Reagent
;; material-ui.macros.clj
(ns material-ui.macros)
(def material-tags
'[AppBar
AppCanvas
Circle
Checkbox
DatePicker
DialogWindow
(ns path.to.services.env
(:require
[clojure.tools.logging :as log]
[puppetlabs.trapperkeeper.core :as tk]
[puppetlabs.trapperkeeper.services :as s]))
(defprotocol EnvironmentConfigService
(get-config [this]
"Returns a map containing all of the configuration values (enviornmentally aware). Any string value that is
prefixed by ENV_, will be considered an environmental variable.")
@taylorSando
taylorSando / ui-material-build
Last active August 29, 2015 14:13
Altering javascript
(function () {
var React = require('react'),
injectTapEventPlugin = require("react-tap-event-plugin"),
materialUI = require('material-ui');
//Needed for React Developer Tools
window.React = React;
window.MaterialUI = materialUI;
@taylorSando
taylorSando / clj-material-ui
Last active November 18, 2016 11:06
How to use material ui with om
(ns om-material-ui.core
(:require [clojure.string :as str]
[om-tools.dom :as omt]))
(defn kebab-case
"Converts CamelCase / camelCase to kebab-case"
[s]
(str/join "-" (map str/lower-case (re-seq #"\w[a-z]+" s))))
(def material-tags
@taylorSando
taylorSando / datomic-rules.clj
Created June 5, 2014 01:15
Datomic recursion using rules
(defn recursive-rule
"A recursive rule for establishing prototype inheritance/isa relationship.
Can specify a maximum depth to travel, or none if there are no restrictinos.
rule The name of the rule
e The entity
a The attribute
v The value
Should be creating the rule like: (recursive-rule 'isa '?e '?a '?v)
Then within a query, can refer to it like this:
(isa ?e :thing/isa ?v) "