Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Oakman oakmac

View GitHub Profile
@oakmac
oakmac / random_date.clj
Last active Aug 13, 2021
find random date between two ranges in Clojure
View random_date.clj
;; 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 / crunker-interop.cljs
Last active Apr 9, 2021
Crunker.js to ClojureScript Interop Example
View crunker-interop.cljs
;; 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 / dom.cljs
Last active Mar 31, 2021
dom helpers functions
View dom.cljs
;; 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 / parinfer-smart-mode-thoughts.md
Last active Feb 21, 2021
Parinfer Smart Mode Thoughts
View parinfer-smart-mode-thoughts.md

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 / deps.edn
Created Dec 3, 2020
skija deps.edn
View 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"}}
View clojure-10182201394873438874.edn
{: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 / cljs-follow-up-questions.md
Last active Oct 6, 2020
ClojureScript Questions Follow-Up
View cljs-follow-up-questions.md

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
oakmac / clojurescript-questions.md
Created Sep 27, 2020
ClojureScript Questions + Answers
View clojurescript-questions.md

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
oakmac / easy-instructions.md
Last active Mar 30, 2020
instructions to help with CheckForCorona translations
View easy-instructions.md

Instructions for non-technical users to assist with CheckForCorona.com translations

  1. Create a GitHub account: https://github.com/join
  2. Go to https://gist.github.com
  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: https://raw.githubusercontent.com/LuminareMed/quickscreen-translations/master/en.edn
    • this is the latest English dictionary file
  5. Click "Create public gist" button
  6. You should see a page like: https://gist.github.com/YOUR_USERNAME/<long hash>
View keybase.md

Keybase proof

I hereby claim:

  • I am oakmac on github.
  • I am oakmac (https://keybase.io/oakmac) on keybase.
  • I have a public key ASBq3O96XUXHblMPchU-ST63SOPAvBVkY_7X1GubvsVLuwo

To claim this, I am signing this object: