Skip to content

Instantly share code, notes, and snippets.

Yehonathan Sharvit viebel

Block or report user

Report or block viebel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View foo.cljs
(ns viebel.a8a0349b00689c40571b0faaa36a9ae8.raw.foo)
(defn square [x] (* x x))
View bar.cljs
(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
ClojureScript REPL dump
View dump-1464465949284.cljs
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
ClojureScript REPL dump
View dump-1464465956723.cljs
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
ClojureScript REPL dump
View dump-1464465971417.cljs
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 Apr 27, 2017 — forked from bhb/spec-example.clj
Recursive spec with clojure.spec
View spec_example.cljs
(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 Jun 8, 2016 — forked from swannodette/spec.cljs
om.next query spec
View spec.cljs
(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
View js_objects_as_clj_objects.cljs
(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)))))
View color_loop.cljs
(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))
View green_body_background.cljs
(defn set-bg-color [c]
(set! (.. js/document -body -style -backgroundColor) c))
(set-bg-color "green")
You can’t perform that action at this time.