Skip to content

Instantly share code, notes, and snippets.

View viebel's full-sized avatar

Yehonathan Sharvit viebel

View GitHub Profile
@viebel
viebel / regex_as_a_function.cljs
Last active June 10, 2016 07:51 — forked from alandipert/reinvoke.cljs
Make a regex behave like a function
; Make a regex behave like a function
; Inspired by: http://blog.klipse.tech/clojure/2016/04/07/ifn.html
(extend-type js/RegExp
IFn
(-invoke ([this s] (re-find this s))))
(#"clojure" "clojurescript")
@viebel
viebel / spec.cljs
Last active June 8, 2016 14:00 — forked from swannodette/spec.cljs
om.next query spec
(ns om.next.spec
(:require [cljs.spec :as s]))
(s/def ::ident (s/and vector? (s/cat :ident keyword? :value #(not (coll? %)))))
(s/def ::join-key (s/or :prop keyword? :ident ::ident))
(s/def ::join (s/and (s/map-of ::join-key ::query) #(= (count %) 1)))
(s/def ::union (s/and (s/map-of keyword? ::query) #(> (count %) 1)))
(s/def ::param-expr
(s/cat :query-expr ::query-expr