I’m Blake. I write about probability, stochastic processes, Python tooling, and the practical side of building things with code. More about me →

  • Recipe: Bolognese sauce
    • Chop 1 onion, 2 carrots, 2 celery stalks

    • Make a sofrito with the chopped veg

      • Heat gently in a large pot (lid on) with olive oil and a pinch of salt
      • 10 – 15 mins
    • Grate 2 zucchini into a tea towel with a fistful of salt

      • Wring the fluid out of the zucchini by twisting it in the tea towel
    • Chop 3 – 4 cloves of garlic

    • Once finished with the sofrito, increase to medium-high heat

    • Add 2 tablespoons of tomato paste

      • Stir and cook for a couple mins (or until the paste starts to darken)
    • Add 500g of ground beef

      • Break up with wooden spoon and cook until browned
    • Add garlic and zucchini

      • Stir and cook for a couple mins until you can smell the garlic
    • Add lots of black pepper and chopped rosemary (5 fresh sprigs)

    • Boil kettle and make a cup of stock (beef or chicken)

    • Add tin of peeled tomatoes to pot

      • Use wooden spoon to break up the tomatoes
      • Pour stock into tin and swirl to get the remaining tomato into the pot
    • Add remaining stock to pot

    • Add 1.5 tablespoons of balsamic vinegar

    • Simmer the sauce for approx 20 mins

      • de-glaze the pot with more balsamic vinegar if any meat catches on bottom
    • Cook pasta

      • Boil a pot of water, add a couple of fistfuls of salt
      • Cook the pasta for half the time noted on the packet
      • For the remaining time, remove pot from the heat
      • If the sauce is looking dry, scoop a bit of pasta water in
    • Once the sauce is done, add 2 – 3 pinches of raw sugar to taste

    • Drain pasta, serve pasta with sauce with plenty of grated parmesan on top!

  • Automating PR descriptions with the LLM CLI

    Writing PR descriptions has always been the most tedious part of working with git for me. After expending a lot of effort on the change, reviewing the diff carefully, writing good commits throughout the process, the PR description feels like I’m backtracking.

    A good PR description should tell the reviewer at a glance what the change entails, what to look out for, provide some justification for major choices made, and provide a bit of testing evidence. This is a crucial part of the process when working with git across a team.

    The only part of this process that I get stuck on is writing the dang summary. As remarked by Blaise Pascal:

    I have made this longer than usual because I have not had time to make it shorter.

    A quote which is often paraphrased as

    If I had more time, I would have written a shorter letter.

    Sometimes all you need is a good draft to edit. Yet another application of the llm CLI, this alias in my ~/.gitconfig is one of my regular uses for LLMs:

    [alias]
        genpr = "!f() { \
            target_branch=\"${1:-main}\"; \
            template_file=\".github/PULL_REQUEST_TEMPLATE.md\"; \
            template_arg=\"\"; \
            prompt='Generate a concise PR description from this diff.'; \
            if [ -f \"$template_file\" ]; then \
                template_arg=\"-f $template_file\"; \
                prompt=\"Fill in the PR template using this diff. Keep descriptions concise. \
                If template sections aren't applicable, leave blank\"; \
            fi; \
            git diff \"$target_branch\" | llm $template_arg \"$prompt\"; \
        }; f"

    Usage:

    git genpr           # vs main
    git genpr develop   # vs develop
    git genpr | pbcopy  # ready to paste into github

    One command, ready-to-submit PR descriptions. What’s not to like?

  • Setting LLM ClI default template with a wrapper

    The LLM tool is easily one of my

    favourite CL’S in the past year. In my regular usage, I often bust it out to just get a quick response for a short query.

    Most LLMs can’t help themselves and insist on being overly verbose. I noticed that all of my queries contained the phrase “be short” or “be direct” or some other variation therein. This is precisely what llm template addresses

    Here’s what I entered into the yaml created by llm template edit default:

    name: default
    
    system: |
      Be as short, direct and concise as possible. Do not make any further
      suggestions --- I'll ask exactly what I need and nothing more. If I need some
      coding help, just return the required code with minimal explanation. Again ---
      I will ask you if I need you to explain it further. Lists are preferred

    But now to use this, I need to add the flag -t default to every llm call. There’s support to configure a default model, but not a default template. Instead of dealing with the extra error-prone keystrokes, I’ve got this script at ~/.local/bin/lm:

    #!/usr/bin/env bash
    
    subcommands="prompt aliases chat collections embed embed-models embed-multi \
    fragments install keys logs models openai openrouter plugins \
    schemas similar templates tools uninstall"
    
    if [[ "$1" == -* ]] || [[ " $subcommands " == *" $1 "* ]]; then
        command llm "$@"
    else
        command llm -t default "$@"
    fi

    And now, if I call lm instead of llm, it’ll add the flag -t default unless I’ve specifically invoked a subcommand of the CLI!

  • Keeping Directories and editing gitignores: A Handy Alias

    Git only tracks files, not directories, but sometimes you need to “track” a directory to ensure it exists in fresh clones, like an output folder.

    A common pattern seen is using an empty .gitkeep file in this directory — but this requires editing two places (the .gitkeep and your main .gitignore), and if you rename the directory it’s easy to forget to update the ignore rules.

    The approach I use instead is summarised nicely here by Adam Johnson: use a .gitignore file inside the directory itself, containing * to ignore everything, then !.gitignore to un-ignore the file so it gets committed. This keeps the directory tracked with a single standard file that survives renames.

    Here’s a nice little alias I threw together in my ~/.gitconfig for this:

    [alias]
        ignore = "!f() { \
            dir=\"${1:-.}\"; \
            if [ ! -d $dir ]; then \
                echo directory $dir not found ; \
                exit 1; \
            fi; \
            gitignore=\"$dir/.gitignore\"; \
            echo $gitignore; \
            if [ ! -f $gitignore ]; then \
                touch $gitignore; \
                if [ $dir != '.' ]; then \
                    echo '*\n!.gitignore' >> $gitignore; \
                fi; \
            fi; \
            $EDITOR $gitignore; \
        }; f"

    Usage

    # Create .gitignore in current directory
    git ignore
    
    # Create .gitignore in a specific directory
    git ignore build/

    It creates the file with the two-line pattern from Adam’s post, then opens it in your editor so you can make any adjustments