Skip to content

Instantly share code, notes, and snippets.

View jbenner-radham's full-sized avatar

James Benner jbenner-radham

View GitHub Profile
@jbenner-radham
jbenner-radham / benchmark.js
Last active October 13, 2025 17:01
Two TS unique functions to compare and benchmark later... (now benchmarked!)
import { Suite } from 'bench-node';
function uniqueA(array) {
return array.filter((item, index) => array.indexOf(item) === index);
}
function uniqueB(array) {
return [...new Set(array)];
}
@jbenner-radham
jbenner-radham / detect-eslint-quote-style.js
Created September 29, 2025 19:22
Detect ESLint w/Stylistic quote style (untested)
import multimatch from 'multimatch'
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import { tsImport } from 'tsx/esm/api';
const QUOTE_STYLES = ['double', 'single', 'backtick'];
function isJavaScriptFileGlob(globs) {
return Boolean(multimatch('test.js', globs).length);
/**
* @see https://prettier.io/docs/configuration
* @type {import('prettier').Config}
*/
const config = {
arrowParens: 'avoid',
quoteProps: 'as-needed',
singleQuote: true,
trailingComma: 'none'
};
@jbenner-radham
jbenner-radham / release-notes.md
Last active August 4, 2025 21:21
Notes regarding random thoughts about GitHub releases and the retrieval of them via POSIX script.

Get the Latest Release Tag (Without the GitHub API)

# Yes, I know that cURL isn't part of POSIX but it's pretty ubiquitous. Maybe see if a Wget fallback would be possible? (note: Apparently Wget is not installed on macOS by default)
# The alternative to use cURL (or possibly Wget) is to use the Git "sparse checkout" technique I'm currently utilizing. Yet again, not POSIX. And probably pre-installed on less UNIX-like operating systems than cURL or Wget.
LATEST_RELEASE=$(basename $(curl --head --location --output /dev/null --silent --write-out %{url_effective} https://github.com/jbenner-radham/node-readme-md-cli/releases/latest))

# After messing around with it for a bit, here's a potential Wget (and grep and sed) based alternative.
# So why is `grep` in there you ask? Well apparently `sed` cannot do multiline regex (at least through pipes). So it's just there to get that "Location" header line for `sed` to extract from.
# Also, `sed` uses "basic regular expressions" (apparently "modern regular ex
@jbenner-radham
jbenner-radham / plugins.toml
Last active August 2, 2025 03:45
Sheldon config file.
# `sheldon` configuration file
# ----------------------------
#
# You can modify this file directly or you can use one of the following
# `sheldon` commands which are provided to assist in editing the config file:
#
# - `sheldon add` to add a new plugin to the config file
# - `sheldon edit` to open up the config file in the default editor
# - `sheldon remove` to remove a plugin from the config file
#
@jbenner-radham
jbenner-radham / .zprofile
Last active August 3, 2025 17:53
Zsh Config Based Off of a Thinned Down Oh-My-Zsh
eval "$(/opt/homebrew/bin/brew shellenv)"
# Added by Toolbox App
export PATH="$PATH:/Users/jamesbenner/Library/Application Support/JetBrains/Toolbox/scripts"
@jbenner-radham
jbenner-radham / readme-md.1
Created October 20, 2024 23:03
Manpage for my readme-md-cli Node.js app
.Dd $Mdocdate$
.Dt README-MD 1
.Os
.\"
.Sh NAME
.\" ====
.Nm readme-md
.Nd Automatically generate a readme for your project from the CLI.
.\"
.Sh SYNOPSIS
@jbenner-radham
jbenner-radham / measure-text.ts
Last active June 4, 2025 17:37
JS/TS Snippets
const get2dCanvasContext = (): CanvasRenderingContext2D | null => {
const canvas = document.createElement('canvas')
const context = canvas.getContext('2d')
if (!context) return context
const { fontWeight, fontSize, fontFamily } = window.getComputedStyle(document.body)
context.font = `${fontWeight} ${fontSize} ${fontFamily}`
return context
@jbenner-radham
jbenner-radham / d&d-5e-cheat-sheet.md
Last active August 3, 2024 23:30
D&D 5e Cheat Sheet

D&D 5e Cheat Sheet

Terms

AC
Armor Class
DC
@jbenner-radham
jbenner-radham / fullscreen-centered.css
Created November 6, 2023 20:04
Fullscreen centering (e.g., for a loading spinner)
.fullscreen-centered {
position: fixed;
inset: 0;
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}