Skip to content

Instantly share code, notes, and snippets.

View joncardasis's full-sized avatar
Hold on a sec. My pour over is on its second bloom.

Jon Cardasis joncardasis

Hold on a sec. My pour over is on its second bloom.
View GitHub Profile
@joncardasis
joncardasis / README.md
Last active March 4, 2026 13:57
Claude Code Statusline - Show tok and cost info

Claude Code Status Line

Example: [Opus 4.6 (1M context)] Context: 0% (↑339 ↓7.9k) | $0.53

  1. Place the above script in ~/.claude/statusline.sh

  2. Edit ~/.claude/settings.json to include a new key:

"statusLine": {

@joncardasis
joncardasis / inline-blame-settings.md
Created February 12, 2026 14:06
Better VSCode Inline Git Blame

The GitLens VSCode extension for inline git blames can eat IDE performance in large repos. I was able to significant improve it by removing the extension and using VSCode built-ins to achieve the same functionality.

"git.blame.editorDecoration.enabled": true,
"git.blame.editorDecoration.template": "${authorName}, ${authorDateAgo} • ${subject} (${hashShort})",
"git.blame.statusBarItem.enabled": true,
"git.blame.statusBarItem.template": "${authorName} (${authorDateAgo}) ${subject}"
@joncardasis
joncardasis / worktrees.md
Last active March 3, 2026 17:26
Organizing Git Worktrees

Organizing Git Worktrees with Colocation

Colocated (or "bare repo + worktrees") pattern is one of the most popular and cleanest way to organize git worktrees. Here's how it works:

The Structure

myproject/              # Parent directory (not a checkout itself)
├── .bare/              # The bare git repo (the actual .git data)
├── .git                # A file (not dir) pointing to .bare
@joncardasis
joncardasis / memoizePromise.ts
Created December 10, 2025 21:36
Memoize an async function, caching the resolved value and deduplicate concurrent calls
/** Memoizes an async function, caching the resolved value and deduplicating concurrent calls */
export const memoizePromise = <T>(fn: () => Promise<T>): (() => Promise<T>) => {
let cached: T
let hasCached = false
let pending: Promise<T> | null = null
return () => {
if (hasCached) {
return Promise.resolve(cached)
}
@joncardasis
joncardasis / print-rive.ts
Created November 4, 2025 23:00
Parse and print contents of a rive file
import fs from 'fs'
import Rive, {
Alignment,
Fit,
Layout,
Rive,
RiveFile,
FileAsset,
useStateMachineInput,
} from '@rive-app/react-webgl2'
@joncardasis
joncardasis / cursor-disable-cmd-k.md
Created October 31, 2025 16:39
Disable Cursor overriding cmd+k clear

cmd+k is a normal keybindings in shells to clear. Cursor highjacks this keybindings for their generation in terminal. Update keybindings JSON to include the following to disable this behavior from Cursor.

{
    "key": "shift+cmd+k",
    "command": "cursorai.action.generateInTerminal",
    "when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
  },
  {
 "key": "cmd+k",
@joncardasis
joncardasis / makePresignedUrl.ts
Last active August 24, 2025 01:23
Calculate presigned S3 url locally and synchronously in Node.js (no async/await)
import crypto from 'crypto'
import {parseResourceUrl} from './utils/parseResourceUrl'
interface PresignedUrlOptions {
/** Url in the format `https://${bucket}.s3.${region}.amazonaws.com/${key}` */
awsResourceUrl: string
expiresIn?: number
}
/** Creates a locally presigned AWS resource url */
import {pseudoLocalizeString} from 'utils/pseudoLocalize'
describe('pseudoLocalizeString', () => {
it.each([
['Hello, world!', 'Ħḗḗḗŀŀǿǿǿ, ẇǿǿřŀḓ!'],
['Get help online.', 'Ɠḗḗḗŧ ħḗḗŀƥ ǿǿƞŀīīƞḗḗ.'],
[
'The quick brown fox jumps over the lazy dog',
'Ŧħḗḗḗ ɋŭŭŭīīīƈķ ƀřǿǿǿẇƞ ƒǿǿǿẋ ĵŭŭḿƥş ǿǿṽḗḗř ŧħḗḗ ŀȧȧẑẏ ḓǿǿɠ',
],
@joncardasis
joncardasis / usePromise.ts
Created September 21, 2021 16:33
usePromise React hook with TypeScript. React-ify promise resolutions
import { useCallback, useState, useRef, useEffect } from 'react';
const usePromise = <T, U extends any[]>(operation: (...args: U) => Promise<T>) => {
const [data, setData] = useState<T>();
const [error, setError] = useState<Error>();
const [loading, setLoading] = useState(false);
const mounted = useRef<boolean>(true);
useEffect(
() => () => {
@joncardasis
joncardasis / SkeletonView.tsx
Last active July 20, 2022 23:38
Simple SkeletonView react-native component (react-native-reanimated v1.9.0)
import React, { useCallback, useMemo, useRef, useState } from 'react';
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import Animated, {
block,
Clock,
cond,
Easing,
eq,
set,