This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
S1 | |
tap -> S3 | |
S1default | |
click -> S1a | |
tap -> S1b | |
S1a | |
go -> S2 | |
back -> S1 | |
S1b | |
go -> S3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[maria.eval :as e] | |
'[goog.object :as gobj] | |
'[clojure.string :as string]) | |
(defn resolve-to-val [sym] | |
(let [{the-name :name} (e/resolve-var sym)] | |
(->> (string/split (str the-name) #"[\./]") | |
(map munge) | |
(to-array) | |
(apply gobj/getValueByKeys js/window)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn lorenz-points [p sigma beta dt] | |
(loop [n 6000 | |
x 0.01 | |
y 0 | |
z 0 | |
out []] | |
(if (= 0 n) | |
out | |
(recur (dec n) | |
(+ x (* p (- y x) dt)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns localstorage) | |
#_[] | |
[1 | |
2 | |
3 | |
4] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; "Πυργεωμετρία ('Pyrgi-ometry')", a Processing sketch using Clojure and Quil | |
(ns livecode.pyrgi | |
(:use quil.core)) | |
(def stripe-height 50) | |
(def canvas-height (* 9 stripe-height)) | |
(def canvas-width (* canvas-height (/ 3 2))) | |
;; Color conversion, courtesy of Jack Rusher | |
(defn hex-to-color [hex] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns spec-test.as-vec | |
(:require [clojure.spec :as s :include-macros true] | |
[cljs.spec.impl.gen :as gen] | |
[clojure.test.check.generators])) | |
(defn as-vec | |
"Wrap the generator of expr to return a vector" | |
[expr] | |
(s/with-gen expr #(gen/bind (s/gen expr) | |
(comp gen/return vec)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns app.x | |
(:require [app.y :refer [y-macro] :include-macros true])) | |
(defmacro x-macro [& args] | |
(y-macro args)) | |
;; how can we use macros from one .clj namespace in another .clj namespace? | |
;; take a close look at the :require statement above. Two important points: | |
;; - it must say :require, not :require-macros |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn flat-map | |
([m] (clj->js (apply hash-map (flat-map "" m)))) | |
([path m] | |
(mapcat (fn [[k v]] (if (map? v) | |
((partial flat-map (str path "/" (name k))) v) | |
[(str path "/" (name k)) v])) m))) | |
(= (flat-map {:users {"x0x0x0" {:name "Matt" | |
:email "me@matt.is"}}}) | |
{"users/x0x0x0/name" "Matt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro defroutes [& routes] | |
`(do | |
~@(map (fn [[[path] body]] | |
(let [has-args? (or (vector? (first body)) (map? (first body))) | |
body (if has-args? body (cons [] body))] | |
`(~'secretary.core/defroute ~path ~@body))) | |
(partition 2 (partition-by string? routes))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns app.cljs-core-cache | |
(:require | |
[cognitect.transit :as transit] | |
[cljs.js :as cljs])) | |
(defn print-core [] | |
(let [writer (transit/writer :json) | |
cache (cljs.js/dump-core)] | |
(.log js/console (transit/write writer cache)))) | |