This file contains hidden or 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 hidden or 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
(defun giraffe () | |
"Passes a the active region (highlighted text in non-emacs | |
speak) to an external command that produces an SVG graph of the | |
data, which is then placed in a buffer called *giraffe* and | |
viewed as an image." | |
;; Declare that this is an interactive command. Whenever a function | |
;; starts this way emacs will make it available to be called with | |
;; M-x or bound to a key. | |
(interactive) |
This file contains hidden or 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 hidden or 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
#ifdef GL_ES | |
precision mediump float; | |
precision mediump int; | |
#endif | |
#define PROCESSING_TEXTURE_SHADER | |
uniform sampler2D texture; | |
uniform vec2 texOffset; | |
varying vec4 vertTexCoord; |
This file contains hidden or 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
(def points | |
(atom | |
(let [radius 150 points 28] | |
(mapv #(vec2 (* radius (Math/cos (* 2 Math/PI (/ % points)))) | |
(* radius (Math/sin (* 2 Math/PI (/ % points))))) | |
(range (inc points)))))) | |
(defn mid-point [[x1 y1] [x2 y2]] | |
(vec2 (/ (+ x1 x2) 2) (/ (+ y1 y2) 2))) |
This file contains hidden or 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
;; owned by bertelsmann directly | |
(query '[:select ?item ?itemLabel | |
:where [[?item (prop :owned-by) (entity "Bertelsmann")]]]) | |
;;=> | |
#{{:item "Q2908540", :itemLabel "Penguin Random House"} | |
{:item "Q7679725", :itemLabel "Talkback Thames"} | |
{:item "Q744182", :itemLabel "Random House"} | |
{:item "Q3621644", :itemLabel "Archivio Storico Ricordi"} | |
{:item "Q796316", :itemLabel "BMG Rights Management"} | |
{:item "Q22080314", :itemLabel "Boundless productions"} |
This file contains hidden or 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
;; convert a PDF to EDN, then: | |
(def test | |
(clojure.edn/read-string (slurp "to_2007_prius_brake_control.edn"))) | |
(map :text (:text_spans (first (:pages test)))) | |
;;=> | |
;; N.B. all spans are re-sorted from the (often random) PDF file order | |
;; to the top down/left-right order suggested by how they're displayed | |
;; when the PDF is rendered. | |
("BC–24" |
This file contains hidden or 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
;;assumes that this package is available: | |
;;[org.wikidata.wdtk/wdtk-wikibaseapi "0.7.0"] | |
(import org.wikidata.wdtk.datamodel.interfaces.EntityDocument) | |
(import org.wikidata.wdtk.datamodel.interfaces.ItemDocument) | |
(import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue) | |
(import org.wikidata.wdtk.wikibaseapi.WikibaseDataFetcher) | |
(import org.wikidata.wdtk.wikibaseapi.apierrors.MediaWikiApiErrorException) | |
;; Trying to automatically build a list of the presidents of the US |
This file contains hidden or 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 make-prism [sides radius segments] | |
(let [points (->> (for [i (range (inc sides))] | |
[(* radius (cos (* TWO-PI (/ i sides)))) | |
(* radius (sin (* TWO-PI (/ i sides))))]) | |
(partition 2 1 ))] | |
(begin-shape :triangles) | |
(doseq [[z1 z2] (partition 2 1 (map (partial * radius) (range (inc segments))))] | |
(doseq [[[x1 y1] [x2 y2]] points] ; segments | |
(vertex x1 y1 z1) ; tri A | |
(vertex x2 y2 z1) |
This file contains hidden or 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
(def shader-spec | |
{:vs "void main() { | |
vUV = uv; | |
gl_Position = proj * view * model * vec4(position, 1.0); | |
}" | |
:fs "void main() { gl_FragColor = texture2D(tex, vUV); }" | |
:uniforms {:model [:mat4 M44] | |
:view :mat4 | |
:proj :mat4 | |
:displace :sampler2D |