Skip to content

Instantly share code, notes, and snippets.

View delitescere's full-sized avatar

Josh Graham delitescere

View GitHub Profile
@delitescere
delitescere / BaseTest.kt
Created September 28, 2022 09:07
A JUnit5 base test class for Kotlin that includes TestInfo values for data partitioning and Clock manipulation for time-sensitive tests
package test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.TestInfo
import org.junit.jupiter.api.TestInstance
import java.time.Clock
import java.time.Instant
import java.time.ZoneId
import java.util.*
import kotlin.math.absoluteValue
@delitescere
delitescere / init-local-stack.sh
Last active June 27, 2021 04:40
Pulumi `local` stack for using with localstack https://localstack.cloud
#!/bin/sh -e
PULUMI_STACK=local
STACK_CONFIG_FILE=Pulumi.${PULUMI_STACK}.yaml
LOCALSTACK_ENDPOINT=http://localhost:4566
pulumi stack init ${PULUMI_STACK}
[ -e ${STACK_CONFIG_FILE} ] && printf "\e[0;31merror:\e[0m stack config file '${STACK_CONFIG_FILE}' already exists\n" && exit 1
cat > ${STACK_CONFIG_FILE} <<_END_
@delitescere
delitescere / brew-update.plist
Last active February 15, 2021 22:49
Update homebrew periodically on macOS - place in ~/Library/LaunchAgents/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- `brew update` every 6 hours -->
<plist version="1.0">
<dict>
<key>EnableGlobbing</key>
<false/>
@delitescere
delitescere / pwned-passwd.sh
Last active April 10, 2018 04:04
Check a pwned password from the macOS / bash command line
pwned-passwd ()
{
history -d $((HISTCMD - 1));
sha=$(printf $1 | sha1sum | cut -d' ' -f1 | tr [:lower:] [:upper:]);
prefix=${sha:0:5};
suffix=${sha:5};
count=$(curl -Ss https://api.pwnedpasswords.com/range/$prefix | grep $suffix | cut -d':' -f2);
[ -n "$count" ] && echo $count >&2 && return 1;
return 0;
@delitescere
delitescere / index
Last active August 6, 2017 14:52
JSON Home file 3
{"api":{"title":"Scan Data","links":{"describedBy":"https://mport.com/api-docs/scan-data","author":"mailto:api@mport.com?subject=scan-data+json-home"}},"resources":{"tag:https://mport.com/api-docs/scan-data/resource/scans":{"hints":{"formats":{"application/edn":{},"application/json":{}},"allow":["GET"],"authSchemes":[{"scheme":"Bearer"}]},"href":"/scan/"},"tag:https://mport.com/api-docs/scan-data/resource/scan":{"hints":{"formats":{"application/edn":{},"application/json":{}},"acceptRanges":["items"],"acceptPut":["application/json","application/edn"],"acceptPost":["application/json","application/edn"],"allow":["GET","POST","PUT","DELETE"],"authSchemes":[{"scheme":"Bearer"}]},"hrefVars":{"scan-id":"https://mport.com/api-docs/scan-data/param/scan-id"},"hrefTemplate":"/scan/{scan-id}"}}}
@delitescere
delitescere / index.html
Created May 23, 2017 23:01
Handlebars client-side templates
<!DOCTYPE html>
<html>
<head>
<title>Greeting</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.10/handlebars.min.js"></script>
</head>
<body>
<h1>Greetings!</h1>
@delitescere
delitescere / bootstrap.md
Last active February 18, 2021 10:21
Portola (OpenJDK using musl) on Alpine

Get the JDK source (per the OpenJDK instructions):

hg clone http://hg.openjdk.java.net/portola/portola
cd portola
bash ./get_source.sh

You need an existing Alpine with an already-built JDK. I have a Docker image of Alpine with glibc-based Zulu JDK:

@delitescere
delitescere / README.md
Last active August 29, 2015 14:17
Zulu 8 on busybox (with OpenSSL). Leiningen on busybox (with bash).
@delitescere
delitescere / cd-lessfuss.sh
Last active November 12, 2018 04:57
cd .. with less fuss
# cd .. with multiple jumps or jump up to name
..() {
if [ "-" = "$1" ]; then cd -; return; fi; # return to previous directory
if [ "/" = "$1" ]; then cd /; pwd; return; fi; # jump to root
if [ -z "$1" ]; then cd ../; pwd; return; fi; # jump up one
declare -i count=$1; # get a jump count
if [ $count -eq 0 ]; then # wasn't a number, look for name
local go=$(while [ "/" != "$PWD" ] && [ "$(basename $PWD)" != "$1" ]; do cd ..; done; pwd);
# jump up to named directory, or don't move if name wasn't found
if [ "/" != "$go" ]; then cd $go; else return; fi;