A Justfile for my blog

For a while now, I’ve been using make as my task runner for my blog. make run to run locally, make deploy to build and push to GitHub pages.

But… the syntax isn’t great for some things and I’ve been working a lot with Rust. So let’s see what just can do!

read more...


Proc Macro Workshop: derive(Builder) [Part 1]

While continuing to learn a bit more about macros in Rust (previous post), I really want to move beyond the simple declarative macros and get into something a bit more interesting. Enter procedural macros. In a nutshell, procedural macros in Rust, rather than relying entirely on pattern matching and expansion are fully Rust functions.

They take a specific input (a stream of tokens) and output a specific output (a new stream of tokens), but in between they can do just about anything a full Rust function can do. And what’s better yet… they operate at compile time. And because they operate on tokens (rather than a full AST), you can do things that just aren’t syntactically valid in normal Rust. Things like… variadic functions (a la print! or var!) or even crazier things like embedding Python in Rust for … reasons.

Today specifically, I’ve started working through the prod-macro-workshop repo. It’s a series of five examples macros with test cases and some guidance set up to help you get up to speed. I’m going to be working through the first of these: derive(Builder). Now don’t get me wrong. I really have no idea what I’m doing, so don’t take this as an example of how to write a macro. But perhaps by writing this out, it will help me learn it better… and if you happen to learn something as well, all the better!

read more...


Writing a curry! macro for MacroKata

Recently I’ve been wanting to learn more about macros in Rust. It was always one of my favorite parts of Racket, so let’s see what we can do.

In order to do that, I’ve been following the excellent MacroKata series. It goes all the way through, starting with the very basics, adding in literals and expressions, handling repetition, nesting, and finally recursion.

What I really want to talk about those is the one that I found most interesting: curry!.

read more...


AoC 2022 Day 23: Elf Scattinator

Source: Unstable Diffusion

Part 1

Implement a cellular automaton with the following rules:

  • If you have no neighbors, don’t move (important, I forgot this one for a while)
  • Otherwise:
    • Calculate a potential move:
      • If you have no neighbors to the north, move north
      • If not, check likewise for south, then west, than east
    • If no other agent is moving to the same space, move to your potential move
    • Otherwise, don’t move
  • On each frame, rotate the order the directions are checked in (NSWE, SWEN, WENS, ENSW, NSWE, …)

read more...


AoC 2022 Day 22: Wonderator

Source: Monkey Map

Part 1

Given a map and a series of instructions formatted as distance + turn (L or R), find the final position. Any time you would walk off the edge of the map, wrap to the opposite edge.

read more...


AoC 2022 Day 20: Deencryptinator

Source: Grove Positioning System

Part 1

Given a list of numbers mix them by moving each number forward/backward in the list based on it’s value. For example, in 4, -2, 5, 6, 7, 8, 9 moving the -2 will result in 4, 5, 6, 7, 8, -2, 9. Each number should be moved exactly once in the original order they appeared in the list.

read more...


AoC 2022 Day 19: Blueprintinator

Source: Not Enough Minerals

Part 1

Given a series of given a series of blueprints, each of which gives instructions for how to build a single robot from a collection of materials that in turn will produce one of a given material per turn, determine the best order of builds to maximize your geode (the most valuable material) production for each blueprint given a time limit of 24 minutes.

read more...