Skip to content

Instantly share code, notes, and snippets.

View oakmac's full-sized avatar

Chris Oakman oakmac

View GitHub Profile
@oakmac
oakmac / clojure-10182201394873438874.edn
Created December 3, 2020 04:38
skija Clojure Example error
{:clojure.main/message
"Execution error (UnsatisfiedLinkError) at org.lwjgl.system.Library/loadSystem (Library.java:162).\nFailed to locate library: liblwjgl.so\n",
:clojure.main/triage
{:clojure.error/class java.lang.UnsatisfiedLinkError,
:clojure.error/line 162,
:clojure.error/cause "Failed to locate library: liblwjgl.so",
:clojure.error/symbol org.lwjgl.system.Library/loadSystem,
:clojure.error/source "Library.java",
:clojure.error/phase :execution},
:clojure.main/trace
@oakmac
oakmac / deps.edn
Created December 3, 2020 17:47
skija deps.edn
{:deps {
; org.jetbrains.skija/skija-native {:mvn/version "0.0.0-SNAPSHOT"}
org.jetbrains.skija/skija-linux {:mvn/version "0.6.21"}
org.lwjgl/lwjgl {:mvn/version "3.2.3"}
org.lwjgl/lwjgl$natives-macos {:mvn/version "3.2.3"}
org.lwjgl/lwjgl-glfw {:mvn/version "3.2.3"}
org.lwjgl/lwjgl-glfw$natives-macos {:mvn/version "3.2.3"}
org.lwjgl/lwjgl-opengl {:mvn/version "3.2.3"}
org.lwjgl/lwjgl-opengl$natives-macos {:mvn/version "3.2.3"}
nrepl/nrepl {:mvn/version "0.8.3"}}
@oakmac
oakmac / parinfer-smart-mode-thoughts.md
Last active February 21, 2021 15:17
Parinfer Smart Mode Thoughts

Parinfer Smart Mode Thoughts

21 Feb 2021 - I woke up this morning with these thoughts about Parinfer and wanted to document them.

Smart Mode is a nice enhancement on top of Indent Mode, but many editor APIs do not support the "buffer change" information needed to make Smart Mode work correctly.

What if instead of passing in any buffer change to Smart Mode, we only run Smart Mode on the following keystrokes:

  • space bar
@oakmac
oakmac / dom.cljs
Last active March 31, 2021 00:43
dom helpers functions
;; this code licensed as CC0 1.0 Universal (SPDX: CC0-1.0)
(ns ^{:doc "DOM helpers"
:author "Chris Oakman"}
com.oakmac.some-project.util.dom
(:require
[goog.dom :as gdom]
[goog.dom.forms :as gforms]))
;; TODO: this could be variadic with some options
@oakmac
oakmac / crunker-interop.cljs
Last active April 9, 2021 02:06
Crunker.js to ClojureScript Interop Example
;; this is a ClojureScript interop example I put together for a student in
;; the Professional ClojureScript course (https://cljs.pro)
(defn fetch-and-merge-files
"Fetches two mp3 files and merges them using the Crunker.js library.
Returns a JavaScript Promise object."
[file1 file2]
(let [js-crunker (new Crunker)]
(-> js-crunker
(.fetchAudio file1 file2)
@oakmac
oakmac / random_date.clj
Last active August 13, 2021 06:33
find random date between two ranges in Clojure
;; question: i want to generate a random date between 2018 and 2020. how can i do it in clojure?
(require [java-time :as jt])
(defn date-range
"returns a sequences of dates between start and end (exclusive)"
[start-date end-date]
(let [dates-from-start (jt/iterate jt/plus start-date (jt/days 1))]
(take-while #(jt/before? % end-date) dates-from-start)))
@oakmac
oakmac / test-failures.txt
Created June 10, 2023 23:17
humanize test failures
➜ humanize git:(hls/31-move-to-java-time) ✗ clj -M:cljs-test
Testing clj-commons.cljc-test
Testing clj-commons.humanize-test
FAIL in (filesize-test) (:)
expected: (= "3.005MB" (f 3005000 nil "%.3f"))
actual: (not (= "3.005MB" "3.0MB"))