Skip to content

Instantly share code, notes, and snippets.

@rstacruz
rstacruz / aider-plan.md
Last active April 22, 2025 14:16
Stop letting Aider code blindly - try this first

Stop letting Aider code blindly - try this first

Using Aider's /ask and /architect commands to approach larger tasks.

Aider is one of the best AI coding tools available today (in my opinion!). It's a brilliant AI coding assistant that integrates with any LLM, in any code editor.

However, Aider can often feel very eager to make changes. It jumps right into coding after I type anything. I noticed a pattern:

  • I would describe what I wanted
  • Aider would start coding right away
@rstacruz
rstacruz / gist:4e301b59a1c9642ecdca1e63dc210bfd
Last active April 7, 2025 02:03
Test storybook stories in Vitest + React testing library

Test storybook stories in Vitest + React testing library

Let's say you have these files:

  • Chat.tsx
  • Chat.stories.tsx
  • Chat.test.tsx

The test file can be written to use Storybook stories:

@rstacruz
rstacruz / prompt-pr.sh
Created March 3, 2025 06:00
Use LLMs to generate a PR summary
#!/usr/bin/env bash
# Generates a prompt for a PR summary and copies it to clipboard.
#
# Usage: prompt-pr.sh 1234
#
# Paste into Claude and watch it generate a PR summary.
#
# Try following up with these questions:
#
# - given the PR description and this plan, is there anything in this PR that may need changing?
@rstacruz
rstacruz / launcher.lua
Last active January 23, 2025 04:41
Rico's hammerspoon launcher config
-- Rico's hammerspoon launcher config
--
-- usage:
-- * press `ctrl-cmd-w` to switch-or-launch Firefox
-- * update the shortcuts below to your liking
--
-- installation:
-- * save as ~/.hammerspoon/mods/launcher.lua
-- * add this to ~/.hammerspoon/init.lua: `require("mods.launcher").setup()`
--
@rstacruz
rstacruz / get_kv.ts
Created March 6, 2023 06:59
Using miniflare for Cloudflare Worker KV in Astro
import { getRuntime } from "@astrojs/cloudflare/runtime";
import type { KVNamespace } from "@cloudflare/workers-types";
/** The KV key (eg, env["KV"]) */
const KV_KEY = "KV" as const;
/**
* Returns a Cloudflare Worker KV store.
* In dev, it returns a mock one based on Miniflare.
*/
@rstacruz
rstacruz / vim-visual-cheatsheet.md
Last active March 16, 2023 05:18
Vim visual cheatsheet
──────────────────────────────────────────────────────────────────────
Insert mode
──────────────────────────────────────────────────────────────────────

             insert  [i] ┄┄┐ ┌── [a]  append
    (left of cursor)       ┆ ┆        (right of cursor)
                           ┌─┐       
                    Hello e│v│eryone. ┆
                           └─┘        └┄┄┄ [A]  append

JavaScript without npm?
A dive into Rails 7's importmap approach

Using JavaScript in Rails has a very long history. With Rails 7, the latest approach has been to move away from the tools from the JavaScript community like npm, yarn, and Webpack. Instead, Rails 7 introduces importmap-rails as a solution that “embraces the platform” and uses native JavaScript modules (also known as “ES Modules” or “ESM”).

What’s Importmap-rails?

Importmap-rails is touted as a gem that “let you import JavaScript modules directly from the browser” 1. The documentation claims that “this frees you from needing Webpack, Yarn, npm, or any other part of the JavaScript toolchain.”

At first, I felt like those claims are a bit ambiguous and a bit of marketing hype. After exploring importmap-rails a bit more, I think I have another way of looking at it. importmap-rails is a replacement for npm for app builders. That is: take away npm’s authoring tools (like `

@rstacruz
rstacruz / miryoku.md
Last active March 4, 2025 16:40
Miyoku diagram

Miryoku layout diagram

An ASCII diagram of the Miryoku layout based on this image.

miryoku

base       ┌────┬────┬────┬────┬────┐   ┌────┬────┬────┬────┬────┐
           │ q  │ w  │ f  │ p  │ b  │   │ j  │ l  │ u  │ y  │ '  │
           ├────┼────┼────┼────┼────┤   ├────┼────┼────┼────┼────┤
           │ a ⌥│ r ⌘│ s ^│ t ⇧│ g  │   │ m  │ n ⇧│ e ^│ i ⌘│ o ⌥│

Make WSL2 faster by removing /mnt/c in the PATH variable

Turning off appendWindowsPath (the feature that adds /mnt/c paths to $PATH) can make WSL faster.

For Ubuntu on WSL

For most distros, it can be done by editing /etc/wsl.conf. These instructions were taken from https://gist.github.com/ilbunilcho/4280bd55a10cefef75e74986b6bff936

$ sudo vi /etc/wsl.conf