Skip to content

Instantly share code, notes, and snippets.

View mhuebert's full-sized avatar

Matt Huebert mhuebert

View GitHub Profile
@mhuebert
mhuebert / example.clj
Last active May 16, 2022 15:16 — forked from jvtrigueros/example.clj
Choosing a directory and setting setting a text label
(ns example
(:require
[cljfx.api :as fx])
(:import
(javafx.stage DirectoryChooser)))
(def *state (atom {:directory nil}))
(defmulti event-handler :event/type)
@mhuebert
mhuebert / depgen.md
Created August 7, 2019 17:48 — forked from raymcdermott/depgen.md
Adhoc CLJS dependency generation

Introduction

A conversation started at the Heart of Clojure conference in Belgium on Friday August 2nd 2019.

The group represented project owners from Maria.Cloud, Next.Journal, Klipse and Replete-Web. The projects make significant use of self-hosted CLJS.

This is a proposal to have a service that generates and caches JS files for a specific CLJS dependency (name & version).

Background

The ClojureScript compiler generates JS files for each of an apps stated CLJS dependencies. The runtime environment then loads each of the needed JS files to satisfy the dependency at runtime.

(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))))
(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))
@mhuebert
mhuebert / localstorage.cljs
Last active July 11, 2017 14:24 — forked from daveliepmann/localstorage.cljs
HTML5 localStorage utility functions for ClojureScript. I find it makes for cleaner code when I wrap the native JS.
(ns localstorage)
#_[]
[1
2
3
4]
@mhuebert
mhuebert / pyrgiometry.clj
Created July 10, 2017 21:57 — forked from daveliepmann/pyrgiometry.clj
"Πυργεωμετρία ('Pyrgi-ometry')", a Processing sketch using Clojure and Quil. Inspired by artwork in the village of Pyrgi on the Greek island Chios: https://daveliepmann.exposure.so/pyrgi
;; "Πυργεωμετρία ('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]