Skip to content

Instantly share code, notes, and snippets.

View oakmac's full-sized avatar

Chris Oakman oakmac

View GitHub Profile
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"))
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 / 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 (
(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 / 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"}
[goog.dom :as gdom]
[goog.dom.forms :as gforms]))
;; TODO: this could be variadic with some options
oakmac /
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 / 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 / clojure-10182201394873438874.edn
Created December 3, 2020 04:38
skija Clojure Example error
"Execution error (UnsatisfiedLinkError) at org.lwjgl.system.Library/loadSystem (\nFailed to locate library:\n",
{:clojure.error/class java.lang.UnsatisfiedLinkError,
:clojure.error/line 162,
:clojure.error/cause "Failed to locate library:",
:clojure.error/symbol org.lwjgl.system.Library/loadSystem,
:clojure.error/source "",
:clojure.error/phase :execution},
oakmac /
Last active October 6, 2020 04:03
ClojureScript Questions Follow-Up

ClojureScript Follow Up Questions + Answers

Some follow-up questions and answers from this gist. -- C. Oakman, 05 Oct 2020

when I said CDN/server I meant are you keeping the compiled javascript artifacts in your UI server OR do you keep them on something like S3 and then

oakmac /
Created September 27, 2020 18:33
ClojureScript Questions + Answers

ClojureScript Questions + Answers

A friend emailed me some questions related to ClojureScript for discussion. I thought these answers might be helpful in a public forum. -- C. Oakman, 27 Sep 2020

Do you serve your CLJS/html from CDN or from same domain as application server?

In general I serve static assets from the same domain as the application server.

oakmac /
Last active March 30, 2020 18:13
instructions to help with CheckForCorona translations

Instructions for non-technical users to assist with translations

  1. Create a GitHub account:
  2. Go to
  3. In the Filename including extension... field, put your language name plus .edn.
    • example: ja.edn for Japanese
  4. Copy this file into the main input area:
    • this is the latest English dictionary file
  5. Click "Create public gist" button
  6. You should see a page like: