Zach Peters Homepage

A collection of projects, random musings and handy information

Coding for One

Saturday, Mar 2, 2024

There is something satisfying about creating tools with a single user in mind. It’s not because I think I can write better code than what is already out there. The motivation comes from the simplicity of creating exactly what I need - no more, no less.

Being able to create something at my own pace with only my own requirements to abide by helps me to think more creatively and use this as a vehicle to learn new techniques. Some of my deepest learning and understanding comes from building.

The other piece that brings me joy is that I never share these creations. This allows me to focus on the joy of just building and not worry about how polished the final product will look. To me, this is the difference between fretting about taking the perfect photo and being able to just enjoy the scenery.

Case Studies

Ok

Ok - The Git Helper

This is my oldest “handmade tool”. In a Ship of Theseus way, I constantly rebuild it every few months piece by piece. This is one of my favorite ways to learn more techniques or programming languages. The scope is very small and pretty well-defined at this point.

Off the top of my head I’ve probably rewritten this in: Haskell, Go, Rust, and half a dozen other languages. This also gives me a good way to compare the strengths and weaknesses of new languages. When I started this exercise over a decade ago, I would often find myself trying to write in the same style every time. As I gained experience and dare I say wisdom I learned to “write to the language” and try to take advantage of each languages unique qualities.

Here is an example of the latest incarnation. There are really only two commands: list will scan all of the directories in my $HOME for any git repos that have changes and lists them, go will autocommit all of them, or it will match a partial string. That’s it!

❯ zachpeters.org (main) ✘ k
Usage:
  k [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  go          Auto-commit changes in all or specified directores
  help        Help about any command
  list        List all directories that have changed

Flags:
  -h, --help   help for k

Use "k [command] --help" for more information about a command.
❯ zachpeters.org (main) ✘ k list
 Changed Directories in '~/Projects/, ~/':
/Users/zachpeters/Projects/zachpeters.org
❯ zachpeters.org (main) ✘ k go zachpeters
 Auto-committing for matched directories:
 SUCCESS  Auto-commit completed
❯ zachpeters.org (main) ✔

Q - My Personal Stack

Q (“queue”)

To be clear this really is a stack and not a queue. The reason it’s called q is just because that is very short to type. This is a newer tool that is still very much a work in progress.

I really hate cloud storage. I can’t stand having yet another drive to copy files back and forth from. Even worse, I spend most of my time in the command line, so copying to a special folder to sync to a drive is usually a pain. My use case is probably different than most. I rarely use cloud storage to share files, its more often about getting a file from point a to point b.

Instead of “going to” the data but finding the cloud storage or shared drive, I want to bring the “storage” to me! The basic concept is that i can run my q command to push a file onto a stack. This stack is a remote store on a server. Then, on a different system, I can do a simple pop to drop the file in the current directory.

I plan to support many of the basic stack like commands, as well as text and binary data. Just thinkig about this it seems like somethign I’d use pretty frequently. Even on the same computer I could see having a handy “scratch” space with files I’m frequently using. Or by just adding text, you could use this as a basic shared clipboard.

Planned commands:

A Fast and Flexible Stack CLI built with love by [your name] in Go.
Complete documentation is available at http://example.com

Usage:
  q [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  list        List all items in your stack
  peek        Peek at the top item of your stack without removing it
  pop         Pop the top item from your stack
  push-file   Push a file to your stack
  push-text   Push a text note to your stack

Flags:
  -h, --help   help for q

Notes application

Notes

This might be my least creatively named app. Notes is just what it sounds like it is an app for taking notes. I hesitate to even call it it app. Really this is just a collection of fish shell scripts. But with a few bodged together scripts, I a tool that fits my needs closer than any other note taking tool I have ever used.

Don’t get me wrong, the design and egronomics are not great, but it gets the job done. The motivation behind this is that I wanted to be able to write and search notes without breaking my flow. This does exactly that. All commands are from the shell and everything uses some form of “quick search” (aka type to search) so it feels blazing fast.

Another benefit is that its all plain text, so when i get the itch to move on there is nothing stopping me. When i want to rewrite this from shell to Go, it will be ready. This is a good reminder to me to start simple and small and only build up when you need it. This is software that will evolve


This website was last updated on Sunday, March 10th 2024, using the Go programming language and styled with Tufte CSS (Dave Liepmann).