Skip to content

Instantly share code, notes, and snippets.

View wdhowe's full-sized avatar

Bill Howe wdhowe

  • United States
View GitHub Profile
@wdhowe
wdhowe / shutdown-hook.clj
Last active August 4, 2025 17:45
Clojure shutdown hook
(ns myapp.shutdown-hook
(:gen-class))
(defn add-shutdown-hook!
"Adds a shutdown hook that executes the given function when the JVM is shutting down."
[f]
(.addShutdownHook
(Runtime/getRuntime)
(new Thread ^Runnable f)))
@wdhowe
wdhowe / hello-world-cljs.md
Last active March 28, 2025 02:38
Clojurescript Hello World (shadow-cljs+reagent)

Clojurescript Hello World

A hello world with Clojurescript+shadow-cljs+reagent.

  • shadow-cljs: A developer tool that provides development builds, hot loading dev web server, and more.
  • reagent: An interface to react. Create complicated react components with less verbosity and using mostly just Clojurescript functions.

Pre-reqs

@wdhowe
wdhowe / s3_sync.py
Created December 18, 2024 22:41
s3 sync in native python
# Until boto3 adds sync capability, we are stuck with subprocess or module hacks like this.
# original author: https://github.com/boto/boto3/issues/358#issuecomment-372086466
import os
from awscli.clidriver import create_clidriver
def aws_cli(*cmd):
old_env = dict(os.environ)
try:
# Environment
env = os.environ.copy()
@wdhowe
wdhowe / update_seqs_to_latest.sql
Created October 24, 2024 13:36
Postgresql: Update all Sequences to Latest
DO $$
DECLARE
i TEXT;
BEGIN
FOR i IN (
SELECT 'SELECT SETVAL('
|| quote_literal(quote_ident(PGT.schemaname) || '.' || quote_ident(S.relname))
|| ', COALESCE(MAX(' ||quote_ident(C.attname)|| '), 1) ) FROM '
|| quote_ident(PGT.schemaname)|| '.'||quote_ident(T.relname)|| ';'
FROM pg_class AS S,
@wdhowe
wdhowe / list_seqs.sql
Created October 24, 2024 13:35
Postgresql: List All Sequences
-- List all sequences and their current values, excluding system schemas
SELECT
n.nspname as schema,
s.relname as sequence_name,
t.relname as table_name,
a.attname as column_name,
pg_sequence_last_value(s.oid) as last_value
FROM pg_class s
JOIN pg_namespace n ON n.oid = s.relnamespace
JOIN pg_depend d ON d.objid = s.oid
@wdhowe
wdhowe / git-pr-cli.md
Created October 24, 2024 13:29
Git: Pull Request CLI

Git: Pull Request CLI

Some github cli example commands to open pull requests.

Remove --dry-run to create.

With a Template

Opens a pull reqest to merge SOURCEBRANCH into DESTBRANCH, using a markdown formatted template for the body.

@wdhowe
wdhowe / git-single-dir-checkout.md
Created October 24, 2024 13:24
Git: Checkout a single directory from a git repo

Git: Checkout a single directory from a git repo

Setup Directory

mkdir myrepo && cd myrepo
git init

Configure Repo

@wdhowe
wdhowe / repo-move.md
Created October 24, 2024 13:20
Git: Move files and history from oldrepo to newrepo

Git: Move files and history from oldrepo to newrepo

Example commands show moving the "data" directory from oldrepo to newrepo and includes all history.

oldrepo (the source)

  • Clone a fresh copy of oldrepo.

git clone git@github.com:USERHERE/oldrepo.git

@wdhowe
wdhowe / .bashrc
Last active August 27, 2025 18:24
bashrc/profile
##-- PATH and Aliases --##
export PATH="/opt/homebrew/bin:/opt/homebrew/opt/openjdk/bin:$PATH:$HOME/bin"
alias ll='ls -l'
alias k='kubectl'
alias ke='kubectl exec -it'
alias kc='kubectx'
alias kn='kubens'
##-- Completions --##
# Installed via "brew install bash-completion"
@wdhowe
wdhowe / local-clj-docs.md
Last active February 3, 2024 18:22
Analyze Clojure Docs Locally

Analyze Clojure Docs Locally

Analyzing your project via the cljdoc-analyzer locally will ensure that when your project is pushed to clojars, the API docs will have a much better chance of successfully generating.

Install the cljdoc-analyzer.

clojure -Ttools install io.github.cljdoc/cljdoc-analyzer '{:git/tag "RELEASE"}' :as cljdoc