Bits and bytes of code

Bytes is my collection of short-form posts, tips, and things I learn as I build software.

There has been a lot of talk lately in the web dev world about #nobuild, the idea of going back to the world before compiling or bundling your code. Svelte has removed TypeScript from the Svelte library, DHH has posted extensively about it with ONCE and HEY. As much as I love TypeScript, I have to agree with them.

1Password SSH

At work, engineers are strongly encouraged to use an additional factor of authentication for SSH keys, rather than the traditional passwordless approach. While Yubikey's work well for this type of thing, I found that 1Password's SSH support is actually much more ergonomic.

Neovim's vim.keymap.set and similar utilities are very useful for creating and managing keymaps, however they lack some ergonomics when building more complex keymaps that require setting and deleting the keymaps periodically. A simply utility function makes this really clean and easy to do.

ast-grep is a brilliant tool for code search and transformation that I've written about in a previous byte. Finding function calls with specific arguments is an area where ast-grep shines and makes it much easier to understand usage of a specific function invocation throughout your codebase.

I frequently create new GitHub PRs and when contributing to projects I don't often use, especially open source projects, I like to create them using the web to make sure I fill out the PR template properly. Sadly, gh pr create -w just doesn't have the right defaults, so I turned a different way...

In the world of differently named default Git branches (e.g., master, main, trunk, etc.), writing commands that reference the default branch and work everywhere is a pain. Thankfully, we can solve this with a single Git alias.

The nvim_create_augroup and nvim_create_autocmd APIs in Neovim work great for creating auto commands, however they sometimes are a bit cumbersome to use compared to the old Vimscript style augroup command where auto commands inside the augroup block were automatically grouped. Let's recreate this same type of experience in Lua!

URL Encode Text In Bash

In an upcoming Byte I'll be sharing a script that I built which opens pull request URLs based on Git branch names. However to do this correctly, we need to URL encode the input data. With the help of jq and 5 lines of code, we can URL encode any text we need.

Next page