Writing
I write short notes on tools and habits that help with day-to-day engineering.
2023
- Array.sort sorts numbers as stringsWithout a comparator, sort() compares numbers as text, so 100 lands before 9. Pass (a, b) => a - b and copy the array first.
- Find heavy dependencies with a Vite treemapAdd rollup-plugin-visualizer to a Vite build, read the treemap, and shrink the biggest rectangle by changing one import.
- Fix stale closures in intervals with refsLet a React interval read the latest state through a ref without resetting the timer on each edit.
- Rebase stacked branches with --update-refsRebase the top of a branch stack with --update-refs to move branch tips that point into the rewritten commits.
- Why async forEach never waitsAn async callback inside forEach runs, but nothing waits for it. Use for...of to run calls in order or Promise.all to run them together.
- Branded types to stop mixing up IDsBrand string IDs so TypeScript rejects a UserId passed to a function that expects an OrderId.
2022
- Open your dev server on another deviceBind your development server to the local network and open it from another device on the same Wi-Fi.
- How Node treats .js and .mjs filesUse file extensions and the package type to choose between CommonJS and ES modules in Node.
- Save a JWT automatically in PostmanSave the JWT from a login response to a Postman environment and send it with later requests.
- Git and GitHub for beginnersUse Git to save versions of your project and GitHub to share those versions with your team.
- Absolute imports in React projectsUse imports relative to src in Create React App or configure an @ alias in Next.js.
- Useful commands for Git and GitHubSet up Git, publish your first commit to GitHub, and clone an existing repository to make changes.
2021
- Common Acronyms Every Software Engineer Should KnowThe full forms of 45 common software engineering acronyms, from URL and CORS to ORM, DRY and CTO, grouped by topic.
- Basic command-line commandsUse a terminal to list files, change directories, and create, rename or remove files and folders.
- Make a button that dodges the pointerBuild a small browser game with a button that moves when the mouse reaches it.
- Subscribe to Mailchimp from Next.jsBuild a Next.js Pages Router endpoint that sends newsletter signups to Mailchimp without exposing your API key.
- Share your local server with ngrokUse ngrok to give someone a temporary public URL for a local development server.
- Markdown basics for plain-text filesUse Markdown to write headings, emphasis, lists, links, images and code blocks in a plain-text file.
- Hello, world! 👋Welcome to my personal blog about what I learn and build as a developer.