Skip to content

Instantly share code, notes, and snippets.

View viebel's full-sized avatar

Yehonathan Sharvit viebel

View GitHub Profile
(ns viebel.a8a0349b00689c40571b0faaa36a9ae8.raw.foo)
(defn square [x] (* x x))
(ns viebel.62563c3ad1a09e2fcabe9482972f2ee0.raw.bar
(:require [viebel.a8a0349b00689c40571b0faaa36a9ae8.raw.foo :refer [square]]))
(defn square-square [x] (square (square x)))
@viebel
viebel / dump-1464465949284.cljs
Created May 28, 2016 20:05
ClojureScript REPL dump
cljs.user=> (ns my.ns$macros)
nil
my.ns$macros=> (defmacro hello[x] x)
true
my.ns$macros=> (my.ns/hello 19)
19
@viebel
viebel / dump-1464465956723.cljs
Created May 28, 2016 20:05
ClojureScript REPL dump
cljs.user=> (ns my.ns$macros)
nil
my.ns$macros=> (defmacro hello[x] x)
true
my.ns$macros=> (my.ns/hello 19)
19
@viebel
viebel / dump-1464465971417.cljs
Created May 28, 2016 20:06
ClojureScript REPL dump
cljs.user=> (ns my.ns$macros)
nil
my.ns$macros=> (defmacro hello[x] x)
true
my.ns$macros=> (my.ns/hello 19)
19
@viebel
viebel / spec_example.cljs
Last active April 27, 2017 01:00 — forked from bhb/spec-example.clj
Recursive spec with clojure.spec
(ns viebel.gist-57d9ebad3381e727c2f0a373e1bd4eec.raw.spec-example
(:require [cljs.spec :as s]))
(s/def ::tag (s/cat :type #{:div}
:attrs map?
:children (s/spec (s/* ::tag))))
(s/explain ::tag [:div {} [[:div {} []]]])
;; In: [2 0] val: [:div {} []] fails spec: _ at: [:children :type] predicate: #{:div}
@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
(extend-type object
ILookup
(-lookup
([this k]
(-lookup this k nil))
([this k not-found]
(let [k (name k)]
(if (.hasOwnProperty this k)
(aget this k)
not-found)))))
(ns viebel.color-loop
(:require-macros
[cljs.core.async.macros :refer [go-loop]])
(:require
[cljs.core.async :refer [timeout <!]]
[viebel.gist-3800b8ebae5292921c7d6fcb6c995c1f.raw.body-color :refer [set-bg-color]]))
(def colors ["red" "yellow" "magenta" "blue" "green"])
(go-loop []
(set-bg-color (rand-nth colors))
@viebel
viebel / green_body_background.cljs
Created June 15, 2016 05:40
green body background
(defn set-bg-color [c]
(set! (.. js/document -body -style -backgroundColor) c))
(set-bg-color "green")