Skip to content

Instantly share code, notes, and snippets.

View telekid's full-sized avatar
👨‍🚀

Jake telekid

👨‍🚀
View GitHub Profile
@telekid
telekid / koans.clj
Last active October 16, 2023 15:55
rama koans
(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 []
(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)
(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]]
(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
;; 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:
{'preferences.myGeoPolygon':
{'$geoIntersects':
{'$geometry':
{'type': 'Point',
'coordinates': [job.longitude, job.latitude]
}
}
}
}
{'myGeopoint':
{'$geoWithin':
{'$box':
[
[sw_longitude, sw_latitude],
[ne_longitude, ne_latitude]
]
}
}
}
@telekid
telekid / 🙃.js
Created February 2, 2017 20:59
Javascript does the darndest things
function factory() {
return {
method: method,
};
var name = "hello";
function method() {
console.log(name);
}
@telekid
telekid / RWojKV.markdown
Last active September 27, 2015 20:13
RWojKV
@telekid
telekid / a.scss
Last active August 29, 2015 14:14
.c {
color: blue;
.b & {
color: red;
}
}
.test {
color: green;