Skip to content

Instantly share code, notes, and snippets.

View jacobemcken's full-sized avatar

Jacob Emcken jacobemcken

View GitHub Profile
jacobemcken / optimize_img.clj
Last active May 23, 2024 19:18
Generate optimized and responsive images using TinyPNGs API
#!/usr/bin/env bb
(ns optimize-img
(:require [babashka.fs :as fs]
[babashka.http-client :as http]
[cheshire.core :as json]
[ :as io]
[clojure.string :as str]
[ :as cli]))
(def cli-options
jacobemcken / upload_to_sharepoint.clj
Created April 7, 2024 15:51
Upload file to SharePoint with app-only principal using Babashka
#!/usr/bin/env bb
(ns upload-to-sharepoint
(:require [babashka.http-client :as http]
[cheshire.core :as json]
[ :as io]
[clojure.string :as str]
[ :as cli])
(:import ( URLEncoder URLConnection)))
(def cli-options
jacobemcken /
Created December 21, 2023 18:49
Script helping to install newer Java versions on Netlify required by Shadow-cljs
rm -rf $HOME/.m2/
cp -a $NETLIFY_BUILD_BASE/cache/.m2/ $HOME/.m2/
JAVA_RELEASE=jdk-17.0.2 # Must match directory inside archive in JAVA_DOWNLOAD_URL
currentver="$(java -version 2>&1 |head -n1 | cut -d'"' -f2 |cut -d'.' -f1)"
jacobemcken / jwt.cljs
Last active January 15, 2024 16:23
Generate dummy JWT using ClojureScript in browser
(ns jwt
"Generate JTW using ClojureScript in browser.
**WARNING** Never store signing key / secret client side (in browser).
It isn't safe.
Play around with different tokens scenarios in a local environment,
without round-tripping 3. party services like Auth0 for every combination.
Implementation reference:
Decode tokens in browser:"

Keybase proof

I hereby claim:

  • I am jacobemcken on github.
  • I am jacobemcken ( on keybase.
  • I have a public key ASCtFqvnYH8NCQckSRsSdM91ySGnEYOJtfXIY-17ErYNTgo

To claim this, I am signing this object:

jacobemcken / transit_format.cljs
Last active January 3, 2022 22:52
ClojureScript (cljs) Transit Day.js
(ns app.transit-format
(:require ["dayjs" :as dayjs]
["dayjs/plugin/duration" :as duration]
[cognitect.transit :as transit]
[haslett.format :as fmt]))
;; Extend Day.js with more functionality
(.extend dayjs duration)
(def duration-type
jacobemcken / gist:b78785bf862cb9c680b9
Created August 11, 2015 20:56
Stacktrace after updating cljx to version 0.5.0 (from 0.4.0 which didn't cause the issue)
22:49:19,353 INFO [] (MSC service thread 1-6) JBAS015876: Starting deployment of "vendix.clj" (runtime-name: "vendix.clj")
22:49:19,535 WARN [org.hornetq.journal] (MSC service thread 1-2) HQ142000: You have a native library with a different version than expected
22:49:19,541 WARN [] (MSC service thread 1-2) JBAS011600: AIO wasn't located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal
22:49:22,475 ERROR [] (MSC service thread 1-6) MSC00001: Failed to start service jboss.deployment.unit."vendix.clj".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."vendix.clj".STRUCTURE: JBAS018733: Failed to process phase STRUCTURE of deployment "vendix.clj"
at [jboss-as-server-7.2.x.slim.incremental.19.jar:7.2.x.slim.incremental.19]
jacobemcken / core.cljs
Last active August 29, 2015 14:12
Example thats triggers bug (?) in Weasel 0.5.0 upon namespace change
(ns rfgs.core
(:require [weasel.repl :as ws-repl]
[clojure.string :as string]))
(defonce game-state (atom {})) ; Atom to store the game state
(if-not (ws-repl/alive?)
(do (print "Open REPL")
jacobemcken / MyValidator.php
Last active August 29, 2015 14:10
Unit test for Laravel custom validator
use Illuminate\Validation\Validator;
class MyValidator extends Validator {
public function validateMutuallyExclusiveWith($attribute, $value, $parameters) {
$allEmpty = true;
foreach ($parameters as $key)
jacobemcken / hello.cljs
Last active August 29, 2015 14:04
Example to trigger compile warning
(ns example.hello)
;; This function will cause compilation got give the following warning:
;; WARNING: cljs.core/<, all arguments must be numbers, got [js/Date js/Date] instead.
(defn test-lt-operator
[^js/Date t]
(< t (js/Date.)))