Skip to content

Instantly share code, notes, and snippets.

import { getCloudflareAccountId } from '@repo/alchemy-helpers/cloudflare'
import { postgresql, pulumi } from '@repo/pulumi'
import * as planetscale from '@repo/pulumi-planetscale' // added via `pulumi package add terraform-provider planetscale/planetscale`
import { HyperdriveConfig } from '@pulumi/cloudflare'
import { validateResourceName } from '../lib/schema.ts'
import type { CloudflareAccountId } from '@repo/alchemy-helpers/cloudflare'
import type { HyperdriveConfigArgs } from '@pulumi/cloudflare'
@jahands
jahands / prompt-shortcuts.ts
Created April 10, 2026 13:10
opencode prompt shortcuts plugin
import { fmt } from 'llm-tools'
import type { Plugin } from '@opencode-ai/plugin'
const PROMPT_SHORTCUTS = {
'#explore': fmt.oneLine(`
Use explore agents to get a better understanding of
relevant systems before you dive into the details yourself.
`),
'#plan': fmt.oneLine(`
@jahands
jahands / script_dir.sh
Created October 13, 2025 09:48
Resolve absolute path to script dir
#!/bin/sh
set -eu
# Returns the absolute directory of this script, resolving file-level symlinks.
# Usage:
# script_dir="$(get_script_dir)" || exit 1
# printf 'script_dir=%s\n' "$script_dir"
get_script_dir() {
# Ensure readlink exists (portable use; no -f).
@jahands
jahands / zoxide-wrapper.sh
Last active September 9, 2025 10:27
zoxide wrapper to prevent leaving current repo (add to .zshrc)
# alias to jump to repo root
alias zz='cd $(git rev-parse --show-toplevel)'
# global cache for repo root
typeset -A _ZO_REPO_CACHE
# custom zoxide wrapper to prevent leaving the repo
function z() {
# special cases: use regular zoxide behavior
# "-" = jump to previous dir, $HOME = unlikely to be a git repo
@jahands
jahands / context.ts
Last active October 30, 2024 21:13
Workflows auto capture to Sentry inside step.do() callback
import { NonRetryableError } from 'cloudflare:workflows'
import { initWorkflowSentry } from '../helpers/sentry'
import type { WorkflowEvent, WorkflowStep, WorkflowStepConfig } from 'cloudflare:workers'
import type { Toucan } from 'toucan-js'
import type { Bindings } from '../types'
/** Workflow context (similar to Hono context) */
export class WorkflowContext<Params = unknown> {
@jahands
jahands / Earthfile
Created February 14, 2024 14:57
Go multiplatform docker builds
VERSION 0.8
PROJECT jahands/docker
# Local targets:
tidy:
LOCALLY
RUN go mod tidy
build-local:
LOCALLY
@jahands
jahands / repeat.ts
Last active January 8, 2023 17:08
Repeat.dev to Notion Dashboard https://repeat.dev
import { Client as NotionClient } from '@notionhq/client';
import formatISO from 'date-fns/formatISO'
import { utcToZonedTime } from 'date-fns-tz'
import { ThrottledQueue, auth } from '@jahands/msc-utils';
let notion: NotionClient;
function setup(env: Repeat.Env) {
if (!notion) {
notion = new NotionClient({
@jahands
jahands / repeat.ts
Last active January 7, 2023 21:20 — forked from Erisa/repeat.ts
Repeat for clearing out Pages deployments (https://repeat.dev)
// https://gist.github.com/jahands/c68b4786d1cea696e61714354c1d3019
import { ThrottledQueue } from '@jahands/msc-utils';
import PQueue from 'p-queue';
// ===== SETUP ===== //
// Required ENV vars:
// CLOUDFLARE_ACCOUNT_ID
// CLOUDFLARE_API_TOKEN
// WEBHOOK_KEY
@jahands
jahands / statsGraph.ts
Last active November 22, 2022 23:11
Serving a graph from Google Sheets, cached via Cloudflare R2 + Edge Cache for maximum uptime
async function statsGraph(params: Params, request: any, env: Env, ctx: ExecutionContext): Promise<Response> {
const graphKey = 'uuid.rocks/stats/graph.png'
const defaults = {
contentType: 'image/png',
cacheControl: 'public, max-age=1800',
} as const
const r2CacheTime = '2 hours' // itty-time format
// First check edge cache
// @ts-ignore
const cache = caches.default
@jahands
jahands / ConvertTo-WslPath.ps1
Created May 1, 2022 21:41
A PowerShell function to convert a path to WSL format
Function ConvertTo-WslPath {
Param(
[Parameter(Mandatory = $true, ValueFromPipeline)]
[string]$Path
)
$p = Get-Item $Path
$wslPath = "/mnt/$($p.PSDrive.Name.ToLower())$($p.FullName.Substring($p.FullName.IndexOf(':')+1).Replace('\','/'))"
$wslPath
}