216 results for "":
Cleaning up and upgrading third-party crates
The bleeding edge of rustc and clippy
Typically, you’d want a production application to use a stable version of Rust. At the time of this writing, that’s Rust 1.65.0, which stabilizes a bunch of long-awaited features (GATs, let-else, MIR inlining, split debug info, etc.).
For every Rust release, Mara makes a wonderful recap thread on Twitter, on top of the official announcement.
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.
Day 10 (Advent of Code 2022)
Onwards! To the day 10 puzzle.
I don’t see a way to make part 1 especially fun — so let’s just get to it.
Parsing
As usual, let’s reach for the nom crate…
$ cargo add nom@7
(cut)
…to parse the input into nicely-organized Rust data structures:
// in `src/main.rs`
use nom::{
branch::alt,
bytes::complete::tag,
combinator::{map, value},
sequence::preceded,
IResult,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum Instruction {
Noop,
Addx(i32),
}
impl Instruction {
fn parse(i: &str) -> IResult<&str, Self> {
let noop = tag("noop");
let addx = preceded(tag("addx "), nom::character::complete::i32);
alt((value(Self::Noop, noop), map(addx, Self::Addx)))(i)
}
fn cycles(self) -> u32 {
match self {
Self::Noop => 1,
Self::Addx(_) => 2,
}
}
}
NeverJam: the game jam jam game
Our January project was ambitious: a 2D puzzle game, a-la lemmings with a twist, with big and numerous levels. And of course, all using our homegrown tools, from the compiler to the level editor to the UI system and game framework.
However, January ended too soon, and, sleepless nights notwithstanding, I had to resolve to publish something completely different. It was a good occasion to get to know Twine.
Peeking inside a Rust enum
During a recent Rust Q&A Session on my twitch
channel, someone asked a question that
seemed simple: why are small string types, like SmartString
or SmolStr
,
the same size as String
, but small vec types, like SmallVec
, are larger
than Vec
?
Now I know I just used the adjective simple, but the truth of the matter is: to understand the question, we’re going to need a little bit of background.
And now for a bit of an announcement
Hey all, thanks for checking in!
After much soul searching, I have arrived to the following conclusion:
- Teaching folks about stuff is my jam.
I’ve been writing multiple articles that sort of read like course material, if there was no dress code, maybe?
In 2013, I organized a 1st year Computer Science student project. Instead of making them implement “control tower software” for a fictional airline, I decided to go for something real - the BitTorrent protocol.
Crafting ICMP-bearing IPv4 packets with the help of bitvec
So. Serializing IPv4 packets. Easy? Well, not exactly.
IPv4 was annoying to parse, because we had 3-bit integers, and 13-bit integers, and who knows what else. Serializing it is going to be exactly the same.
Right now, we don’t have a way to serialize that.
Let’s take the version
and ihl
fields, both of which are supposed
to take 4 bits, together making a byte. We could serialize them like this:
Face cams: the missing guide
I try to avoid doing “meta” / “behind the scenes” stuff, because I usually feel like it has to be “earned”. How many YouTube channels are channels about making YouTube videos? Too many.
Regardless, because I’ve had the opportunity to make my own mistakes now for a few years (I started doing the video thing in earnest in 2019), and because I’ve recently made a few leaps in quality-of-life re: shooting and editing video, I thought I’d publish a few notes, if only for reference for my future self.
The quest for ooc.vim
I’ve spent the past few weeks after rock 0.9.8’s release working on some of the neglected aspects of ooc, namely tooling support and performance.
My kingdom for a vim plug-in!
Well, technically, ooc.vim is a few years old, and it was even updated a few times to match new ooc features. But unfortunately, so far, it was limited to syntax highlighting.