216 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>;
}
A terminal case of Linux
Has this ever happened to you?
You want to look at a JSON file in your terminal, so you pipe it into jq so you can look at it with colors and stuff.
That’s a useless use of cat.
…oh hey cool bear. No warm-up today huh.
Sure, fine, okay, I’ll read the darn man page for jq
… okay it takes
a “filter” and then some files. And the filter we want is.. .
which, just
like files, means “the current thing”:
Fast font packing for fun and profit
Being creative is hard work, let’s go optimizing instead! My graphics engine dye was pretty naive about displaying text, and it was wasteful. Let’s see how I made it all better with this one weird tip.
Disclaimer: Even after a few years I’m still very much an OpenGL newbie. Please don’t hit me with crowbars.
Once upon a time, OpenGL was easy to use - and also falling out of relevancy as far as high-performance 3D graphics were concerned. But it wasn’t all bad! You could basically pick up any library out there and integrate it with your existing GL project. Not that it’s a good idea, but it usually just worked.
Next power of two
While looking to write a pure ooc version of ftgl, I was reading the source of ftgl-gl3 and I stumbled upon this piece of code:
static inline GLuint NextPowerOf2(GLuint in)
{
in -= 1;
in |= in >> 16;
in |= in >> 8;
in |= in >> 4;
in |= in >> 2;
in |= in >> 1;
return in + 1;
}
This is needed because dealing with power-of-two textures (32x32, 64x64, 128x128, etc.) is more efficient with OpenGL (some implementations don’t even support non-power-of-two textures!).
itch.io app timeline 2016
I’ve been working on the itch.io desktop app for about a year now, so I thought I’d make a quick recap:
At the time of this writing, the app has been downloaded about 460K times (including updates). Not counting the back-end, the app and its various components are made up of around 100K lines of code (mostly javascript and golang), most of which is open-source.
Understanding Rust futures by going way too deep
So! Rust futures! Easy peasy lemon squeezy. Until it’s not. So let’s do the easy thing, and then instead of waiting for the hard thing to sneak up on us, we’ll go for it intentionally.
That’s all-around solid life advice.
Choo choo here comes the easy part 🚂💨
We make a new project:
$ cargo new waytoodeep
Created binary (application) `waytoodeep` package
And then there were fewer bugs
Intro
This deals with rock internals, so fasten your seatbelts and expect many weird things along the way. I’m not necessarily proud of the state of the implementation, I’m just rolling with it and trying to improve it gradually rather than throw everything away.
An error out of nowhere
While working on my current game, John Q. Adamant, I was looking to extract a class into another module - this is routine refactoring and shouldn’t be too hard.
Day 5 (Advent of Code 2022)
Part 1
The day 5 challenge actually looks fun!
Our input looks like this:
[D]
[N] [C]
[Z] [M] [P]
1 2 3
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2
Which is a visual representation of stacks, and so, for once, we have some serious parsing to do, and that means I finally have a good reason to bust out the nom crate.
Request coalescing in async Rust
As the popular saying goes, there are only two hard problems in computer science: caching, off-by-one errors, and getting a Rust job that isn’t cryptocurrency-related.
Today, we’ll discuss caching! Or rather, we’ll discuss… “request coalescing”, or “request deduplication”, or “single-flighting” - there’s many names for that concept, which we’ll get into fairly soon.
Day 4 (Advent of Code 2020)
It’s time for Day 4 of the Advent of Code 2020!
Now, I’ve already had a look at the problem statement, at least for part 1, and I’m not particularly excited.
But it will allow me to underline some of the points I’ve recently been *trying to make about types and correctness.
Ah, yes, the novel.
The problem is to parse passports, with fields like these: