A Pen by Jake Zerrer on CodePen.
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 hypo.server.reg | |
(:use [com.rpl.rama] | |
[com.rpl.rama.path]) | |
(:require [com.rpl.rama :as r] | |
[com.rpl.rama.test :as rtest] | |
[hyperfiddle.rcf :as rcf])) | |
(rcf/tests | |
"operations output to streams" | |
(deframaop one [] |
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 hi [name] (println "hello " name)) | |
(s/def ::hi-args (s/cat :name string?)) | |
(def registry {`hi ::hi-args}) | |
(defn instrument [] | |
(s/check-asserts true) | |
(for [[sym spec] registry] | |
(alter-var-root (find-var sym) |
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 automatic-differentiation | |
"Perform simple automatic differentiation with dual numbers using the | |
technique described here: | |
https://blog.demofox.org/2014/12/30/dual-numbers-automatic-differentiation/" | |
(:require [clojure.walk :refer [postwalk postwalk-replace]])) | |
(defn dual-add [[ar ad] [br bd]] | |
[(+ ar br) (+ ad bd)]) | |
(defn dual-subtract [[ar ad] [br bd]] |
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 '[clojure.spec.alpha :as s] | |
'[clojure.spec.test.alpha :as spec.test]) | |
;; In Clojure, multimethods are designed to be open for extension. That means that | |
;; a library author can define a function, and then consumers of that library | |
;; can extend it arbitrarily by defining additional implementations of that function. | |
;; | |
;; However, there isn't a ton of documentation floating around that describes how | |
;; to properly spec functions in an open way. This gist provides an example of doing | |
;; just that; it defines a function called `magic`, and then extends it with two |
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
;; Spec's global ns registry makes it challenging to declare multiple instances | |
;; of the same concept in the same ns. For example, say I want to define specs | |
;; for multiple continents in (ns models.geography.continent). Different continents | |
;; have different animal populations, so they require different animal counts: | |
(ns models.geography.continent | |
(:require [models.animals :as animals])) | |
;; First, we define a spec for Antarctica: |
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
{'preferences.myGeoPolygon': | |
{'$geoIntersects': | |
{'$geometry': | |
{'type': 'Point', | |
'coordinates': [job.longitude, job.latitude] | |
} | |
} | |
} | |
} |
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
{'myGeopoint': | |
{'$geoWithin': | |
{'$box': | |
[ | |
[sw_longitude, sw_latitude], | |
[ne_longitude, ne_latitude] | |
] | |
} | |
} | |
} |
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
function factory() { | |
return { | |
method: method, | |
}; | |
var name = "hello"; | |
function method() { | |
console.log(name); | |
} |
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
.c { | |
color: blue; | |
.b & { | |
color: red; | |
} | |
} | |
.test { | |
color: green; |
NewerOlder