212 results for "":
Async fn in trait, for real this time
async_trait
’s one weird type ascription trick
Now that I got the Log in with GitHub feature working, let’s explore
what this would’ve looked like with the async_trait
crate.
First up, the trait definition:
/// Something that can refresh credentials
#[async_trait::async_trait]
pub trait CredentialsRefresher {
async fn refresh(&self, creds: &FutileCredentials) -> eyre::Result<FutileCredentials>;
}
Making a dev shell with nix flakes
In the previous chapter, we’ve made a nix “dev shell” that contained the fly.io command-line utility, “flyctl”.
That said, that’s not how I want us to define a dev shell.
Our current solution has issues. I don’t like that it has import <nixpkgs>
.
Which version of nixpkgs
is that? The one you’re on? Who knows what that is.
Also, we haven’t really seen a mechanism to use .nix
files from elsewhere.
That health is mental
Disclaimer:
Trigger warning: depression, talk of suicide.
It’s been a while since I wrote a mental health piece — but I think it’s important to occasionally stop, take a breather, and think about how we feel.
So.
deep breath
I’m okay, I think? Just a little restless.
A bit of personal context
For those keeping score, I went through major life events in 2023 — a divorce, a move, and the news that I might need a second round of jaw surgery.
The best way to learn
Day 2 (Advent of Code 2022)
Part 1
In the day 2 challenge, we’re playing Rock Papers Scissors.
We’re given a strategy guide like so:
A Y
B X
C Z
Left column is “their move”: A means Rock, B means Paper, C means Scissors. Right column is “our move”: X means Rock, Y means Paper, Z means Scissors.
Each line corresponds to a turn, and we must calculate the total score we get. Picking “Rock” gives 1 point, “Paper” gives 2 points, and “Scissors” gives 3. Losing the round gives 0 points, drawing gives 3, winning it gives 6.
The simplest shared library
In our last article, we managed to load and execute a PIE (position-independent executable) compiled from the following code:
; in `samples/hello-pie.asm`
global _start
section .text
_start: mov rdi, 1 ; stdout fd
lea rsi, [rel msg]
mov rdx, 9 ; 8 chars + newline
mov rax, 1 ; write syscall
syscall
xor rdi, rdi ; return code 0
mov rax, 60 ; exit syscall
syscall
section .data
msg: db "hi there", 10
The HTTP crash course nobody asked for
HTTP does a pretty good job staying out of everyone’s way.
If you’re reading this article, there’s a solid chance it was delivered to you over HTTP. Even if you’re reading this from an RSS reader or something. And you didn’t even have to think about it!
“Not having to think about it” is certainly a measure of success for a given technology. By contrast, I think about Bluetooth a lot. I wish I didn’t.
Celebrating Mario Maker
I’ve been watching a lot of Super Mario Maker videos this past month. Probably a hundred hours! This game is like a world onto itself, and it was fascinating to learn its design language and patterns.
With Super Mario Maker 2 coming out soon, I thought I’d show off some of the cool stuff I’ve seen, to celebrate Mario Maker.
We’ll start with some basic elements of Mario Maker (with screenshots), and then move on to a lot of video clips showing cool stuff.
Developing over SSH
With the previous part’s VM still running, let’s try connecting to our machine over SSH.
Network addresses, loopback and IP nets
Normally, to connect to a machine, you’d find its IP address. On Linux, a decade
ago, you would’ve used ifconfig
. Nowadays you can use ip addr
:
The loopback interface (lo
) is local, so it’s not useful to reach the box from
the outside: you can see it can be accessed over IPv4 at address 127.0.0.1 but
not just! What we’re reading here is 127.0.0.1/8, which corresponds to the range
127.0.0.1 - 127.255.255.255
A new website for 2020
Hi everyone. Has it been two months since I last posted something? Yes it has!
That seems like a nice round duration, so let’s break the silence with a few announcements.
I have a new website
If everything goes well, you’re on it right now.
Does it feel okay? Take a minute to accustom yourself to your new surroundings. Identify potential sources of fresh water. Gather some supplies with which to fashion a makeshift shelter.