220 results for "":

Thumbnail for Catching up with async Rust

Catching up with async Rust

In December 2023, a minor miracle happened: async fn in traits shipped.

As of Rust 1.39, we already had free-standing async functions:

pub async fn read_hosts() -> eyre::Result<Vec<u8>> { // etc. }

…and async functions in impl blocks:

impl HostReader { pub async fn read_hosts(&self) -> eyre::Result<Vec<u8>>
Thumbnail for Printing ASCII cats to the terminal

Printing ASCII cats to the terminal

Now that our development environment is all set up, let’s make something useful!

Creating the catscii crate

From a VS Code window connected to our VM (as we just set up), let’s make a new Rust project:

amos@miles:~$ cargo new catscii Created binary (application) `catscii` package

And open it in a new VSCode window:

amos@miles:~$ code catscii
Thumbnail for Just paying Figma $15/month because nothing else fucking works

Just paying Figma $15/month because nothing else fucking works

My family wasn’t poor by any stretch of the imagination, but I was raised to avoid spending money whenever possible.

I was also taught “it’s a poor craftsman that blames their tools”, which apparently means “take responsibility for your fuckups”, but, to young-me, definitely sounded more like “you don’t deserve nice things”.

I was also taught from an early age that I was born a sinner, incapable of doing good by myself, and that all the earthly things were temptations, sent by the devil to corrupt me (further I guess?) but also temporary, and that I shouldn’t attach myself.

Thumbnail for Day 11 (Advent of Code 2022)

Day 11 (Advent of Code 2022)

It’s a new day, it’s a new advent of code puzzle.

In that one, we have to apparently cosplay as an IBM mainframe and just.. crunch them numbers. This doesn’t look fun, and I can’t think of a clever twist to make it fun, so let’s try to make it short and sweet.

Parsing

Our input looks like this:

Monkey 0: Starting items: 79, 98 Operation new = old divisible by true throw to monkey false throw to monkey items new = old + divisible by true throw to monkey false throw to monkey etc
Thumbnail for Day 17 (Advent of Code 2022)

Day 17 (Advent of Code 2022)

Advent of Code gets harder and harder, and I’m not getting any smarter. Or any more free time. So, in order to close out this series anyway, I’m going to try and port other people’s solutions from “language X” to Rust. That way, they already figured out the hard stuff, and we can just focus on the Rust bits!

Sounds good? Good. Let’s proceed.

Thumbnail for Porting poppler to meson

Porting poppler to meson

It took a hot minute.

Cool bear

Try several weeks.

Well, yeah. I got to contribute to a bunch of open-source projects in the meantime though, so I’m fairly pleased with it!

  • libffi (for static linking)
  • cairo (more static linking!)
  • proxy-libintl (more static linking!)
  • expat (static linking strikes again)
  • poppler (for file descriptor stuff not properly gated on Windows, closed in favor of a similar MR)
Thumbnail for A static poppler build: the easy way

A static poppler build: the easy way

So! Now our asset processing pipeline is almost complete. But we’ve just traded dependencies against CLI tools, for dependencies against dynamic libraries:

$ ldd ./target/debug/pdftocairo linux-vdso.so.1 (0x00007ffd615be000) libpoppler-glib.so.8 => /lib64/libpoppler-glib.so.8 (0x00007f2ba1bb4000) libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007f2ba1b59000) libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f2ba1a1e000) libcairo.so.2 => /lib64/libcairo.so.2 (0x00007f2ba1902000) libcairo-gobject.so.2 => /lib64/libcairo-gobject.so.2 (0x00007f2ba18f6000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f2ba18dc000) libm.so.6 => /lib64/libm.so.6 (0x00007f2ba17fe000) libc.so.6 => /lib64/libc.so.6 (0x00007f2ba15f4000) /lib64/ld-linux-x86-64.so.2 (0x00007f2ba216c000) libpoppler.so.112 => /lib64/libpoppler.so.112 (0x00007f2ba1288000) libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f2ba11bd000) libgio-2.0.so.0 => /lib64/libgio-2.0.so.0 (0x00007f2ba0fe4000) libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f2ba0dc5000) libffi.so.6 => /lib64/libffi.so.6 (0x00007f2ba0db8000) libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f2ba0d40000) libpixman-1.so.0 => /lib64/libpixman-1.so.0 (0x00007f2ba0c94000) libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f2ba0c45000) libpng16.so.16 => /lib64/libpng16.so.16 (0x00007f2ba0c0c000) libxcb-shm.so.0 => /lib64/libxcb-shm.so.0 (0x00007f2ba0c07000) libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f2ba0bda000) libxcb-render.so.0 => /lib64/libxcb-render.so.0 (0x00007f2ba0bca000) libXrender.so.1 => /lib64/libXrender.so.1 (0x00007f2ba0bbd000) libX11.so.6 => /lib64/libX11.so.6 (0x00007f2ba0a75000) libXext.so.6 => /lib64/libXext.so.6 (0x00007f2ba0a60000) libz.so.1 => /lib64/libz.so.1 (0x00007f2ba0a46000) libjpeg.so.62 => /lib64/libjpeg.so.62 (0x00007f2ba09c2000) libopenjp2.so.7 => /lib64/libopenjp2.so.7 (0x00007f2ba0968000) liblcms2.so.2 => /lib64/liblcms2.so.2 (0x00007f2ba0903000) libtiff.so.5 => /lib64/libtiff.so.5 (0x00007f2ba087c000) libsmime3.so => /lib64/libsmime3.so (0x00007f2ba0850000) libnss3.so => /lib64/libnss3.so (0x00007f2ba0712000) libplc4.so => /lib64/libplc4.so (0x00007f2ba0709000) libnspr4.so => /lib64/libnspr4.so (0x00007f2ba06c6000) libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f2ba06b3000) libharfbuzz.so.0 => /lib64/libharfbuzz.so.0 (0x00007f2ba05dd000) libbrotlidec.so.1 => /lib64/libbrotlidec.so.1 (0x00007f2ba05cf000) libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f2ba05c8000) libmount.so.1 => /lib64/libmount.so.1 (0x00007f2ba0581000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f2ba0556000) libxml2.so.2 => /lib64/libxml2.so.2 (0x00007f2ba03cd000) libXau.so.6 => /lib64/libXau.so.6 (0x00007f2ba03c7000) libwebp.so.7 => /lib64/libwebp.so.7 (0x00007f2ba0358000) libzstd.so.1 => /lib64/libzstd.so.1 (0x00007f2ba0260000) libjbig.so.2.1 => /lib64/libjbig.so.2.1 (0x00007f2ba0252000) libnssutil3.so => /lib64/libnssutil3.so (0x00007f2ba021f000) libplds4.so => /lib64/libplds4.so (0x00007f2ba021a000) libgraphite2.so.3 => /lib64/libgraphite2.so.3 (0x00007f2ba01f9000) libbrotlicommon.so.1 => /lib64/libbrotlicommon.so.1 (0x00007f2ba01d4000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f2ba019c000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f2ba0105000) liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f2ba00d9000)

Efficient game updates

A little while ago, I wrote an article on things that can go wrong when downloading, it listed a series of reasons, from network problems to invalid content to imperfect hardware that may occur when initially installing a game.

This article discusses what methods we can use to upgrade a game to a later version, when an older version has been successfully installed.

Thumbnail for A simple ping library, parsing strings into IPv4 address

A simple ping library, parsing strings into IPv4 address

We’ve just spent a lot of time abstracting over LoadLibrary, but we still have all the gory details of the Win32 ICMP API straight in our main.rs file! That won’t do.

This time will be much quicker, since we already learned about carefully designing an API, hiding the low-level bits and so on.

Let’s add an icmp module to our program. Actually, we’ve been dealing with an IPAddr all this time, it also sounds like it could use its own package:

Three gamedev surprises

Despite their peaceful appearance, game developers actually lead thrilling lives! Here are three things I learned (or re-learned) about yesterday that I’d like to share with you, in the form of assumptions that revealed false.

VSync is relatively straightforward. Right?

As an obsessive-compulsive, bipolar, perfectionist game dev, getting your game to run smoothly on all kinds of operating systems, graphics cards, and drivers combination is something of a holy grail. Many look for it, but let’s be honest here, it never really turns out as expected.