Skip to content

Instantly share code, notes, and snippets.

@henryw374
henryw374 / git-analyze-clojure.clj
Last active January 6, 2025 16:48
get clojure data on what files have changed in a git repo and when
(ns git-analyze
(:require [clojure.java.process :as process]
[clojure.string :as string]
[com.widdindustries.tempo :as tempo]))
(defn changed-files []
(->>
(process/exec "git" "log" "--pretty=%x0a%cI" "--name-only" "--date=iso")
(string/split-lines)
(remove string/blank?)
@henryw374
henryw374 / flexi_clock.clj
Created October 17, 2024 16:11
clojure java.time clock
(ns flexi-clock
(:import (java.time Clock Duration Instant ZonedDateTime)))
(defn clock
"potential library function (e.g. in tick or tempo).
This just implements the platform Clock - which works because non-test code only uses that API.
Any manipulation of time (which happens in testing code) is done via changing
what get-instant and get-zone return"
[get-instant get-zone]
@henryw374
henryw374 / mutable_clock.clj
Last active July 1, 2024 14:08
mutable-clock java.time clock clojure
(ns mutable-clock
(:import (java.time Clock Duration Instant ZoneId)))
(definterface MutableClock
(setZone [zone])
(setInstant [instant]))
(defn mutable-clock [_instant _zone]
(let [instant-atom (atom _instant)
zone-atom (atom _zone)]
@henryw374
henryw374 / tanstack-importmap-demo.js
Created November 7, 2023 16:50
tanstack react-router no build step
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>demo</title>
</head>
<body>
<div id="app" style="min-height:100%">
Hello world!
@imthenachoman
imthenachoman / Developing a GAS Powered Google Workspace Add-on And Launching It To The Marketplace.md
Last active April 4, 2025 23:42
Developing a GAS Powered Google Workspace Add-on And Launching It To The Marketplace
(ns com.widdindustries.kaocha-cljs2-ns-pattern-hook
"the only way I can find to filter kaocha-cljs2 tests by pattern. see comment block for usage"
(:require [kaocha.core-ext :as core-ext]
[kaocha.load :as load]))
(defn ns-filter [plan]
;(def plan plan)
;(println "About to start loading!")
(update plan :kaocha.test-plan/tests
(ns protocol-proxy
"for when you have an object foo, which satisfies some protocols and you want to make adhoc changes to
one or more of the protocol methods, but just on foo.
Can be handy for testing.
"
(:refer-clojure :exclude [proxy])
(:require [clojure.string :as string]))
;(remove-ns 'protocol-proxy)
(ns contiguous-spans
"takes pre-sorted dates and returns contiguous periods contained therein.
see comment block for demo
"
(:require [tick.core :as t]))
(defn contiguous-spans
"takes pre-sorted dates and returns contiguous periods contained.
dates a and b are contiguous if a plus span-length is equal to b "

hardware & os

  • dotfiles?
  • terminal & shell
  • editor
  • env setup - dbs, etc
  • how do you start you REPL?
  • deps or leningen?
  • new project template?
  • tasks automation - babashka?
  • how do you navigate in project?
@henryw374
henryw374 / kroki-read.bb
Last active July 4, 2022 17:50
encode and decode files as kroki url diagrams https://kroki.io/#try
#!/usr/local/bin/bb
(import '[java.io ByteArrayOutputStream])
(import '[java.util Base64]) ;
(import '[java.util.zip Inflater]) ;
(defn uncompress [source-bytes]
(let [inflater (doto (Inflater.)
(.setInput source-bytes))
outputStream (new ByteArrayOutputStream (count source-bytes))