Skip to content

Instantly share code, notes, and snippets.

View graffhyrum's full-sized avatar

Joshua Pendragon graffhyrum

View GitHub Profile
@graffhyrum
graffhyrum / _idx.md
Last active October 22, 2025 18:59
AI summarize my day

This is a short LLM prompt to have the tool read your git history and summarize what you did in the project. It's nice to have. With something like Claude custom slash commands you can map these to an alias for easy use.

Read through my git commit history for today and summarize what I did in a file with the filename `${yyyy-mm-dd}_Summary.md`. 
Create a 'worklog' folder in the root of this project, and save the markdown there.
@graffhyrum
graffhyrum / _Summary.md
Last active July 17, 2025 16:07
Typescript Clean Architecture Filtering Layer

Clean Architecture Filtering Layer: Design Patterns and Implementation

Overview

This code sample demonstrates a complete filtering layer implementation that adheres to clean architecture principles. The system provides type-safe, configurable filtering for business entities while maintaining strict separation of concerns and dependency inversion.

Architecture Layers

Domain Layer (Innermost)

The domain layer contains pure business entities and value types with no external dependencies:

/**
* Creates a typed key-value pair object to work around TypeScript issue #13948.
* This function preserves the literal type of the key in the resulting object type.
*
* @see [source](https://github.com/microsoft/TypeScript/issues/13948#issuecomment-1333159066)
*
* @example
* const obj = createTypedKeyValue('userId', 123);
* // obj has type: { userId: number } with literal key preservation
*

This script is a vetting tool designed to automate the process of running tests, retrying failures if necessary, and saving the results of each test cycle to a session-specific directory. Here's a summary of its functionality:

Key Features and Workflow:

  1. Session Setup:

    • Creates a session-specific directory based on the current timestamp and Git branch name.
    • Ensures the base directory (vetting-results) exists and creates the session directory recursively.
  2. User-Specified Test Parsing:

    • Parses command-line arguments to extract user-specified tests to run.
@graffhyrum
graffhyrum / LoggingWrapper.ts
Last active May 23, 2025 17:50
A proxy wrapper for services to allow logging functionality for requests, responses, and errors.
import { file } from 'bun'
import { mkdirSync, existsSync } from 'node:fs'
import { join } from 'node:path'
const logFolder = 'LogFolder'
const logFilePath = join(process.cwd(), logFolder, 'proxy.log')
// Ensure the log folder exists
if (!existsSync(logFolder)) {
mkdirSync(logFolder)
/**
* ProcessEnvFacade is an object that provides methods to interact with environment variables.
* It provides methods to get, set, and validate environment variables.
*/
const ProcessEnvFacade = {
getValueOrThrow: (key: keyof NodeJS.ProcessEnv): string => {
const maybeKey = process.env[key];
if (!maybeKey) {
throw new Error(`Environment variable ${key} is not set`);
}
@graffhyrum
graffhyrum / find-my-file.yaml
Created November 1, 2024 16:46
A Github Action that provides debug information about file paths.
name: 'Find My File'
description: 'Action that provides debug information about file paths'
inputs:
runnerOs:
description: 'The runner operating system'
required: true
filename:
description: 'The filename to search for'
required: true
@graffhyrum
graffhyrum / modify.md
Created October 9, 2024 20:05
Swaps the type of a parameter to something else
/**
 * Modify a type `T` by replacing properties with the properties of type `R`.
 *
 * @template T - The original type.
 * @template R - The type with properties to replace in `T`.
 */
type Modify<T, R> = Omit<T, keyof R> & R;
@graffhyrum
graffhyrum / browserWrapper.ts
Last active July 26, 2024 20:18
Wrap some callback action in a new browser instance with setup and teardown handled
import {
BrowserContextOptions,
BrowserType,
LaunchOptions,
Page,
} from '@playwright/test';
function doWithNewBrowser(
callback: (page: Page, ...args: any[]) => Promise<any>,
browser: BrowserType,
@graffhyrum
graffhyrum / playwright.yaml
Created July 10, 2024 21:55
A good github action template for running playwright tests using Bun
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest