220 results for "":
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”:
Declarative memory management
It feels like an eternity since I’ve started using Rust, and yet I remember vividly what it felt like to bang my head against the borrow checker for the first few times.
I’m definitely not alone in that, and there’s been quite a few articles on the subject! But I want to take some time to present the borrow checker from the perspective of its benefits, rather than as an opponent to fend with.
Profiling linkers
In the wake of Why is my Rust build so
slow?, developers from the mold and
lld linkers reached
out,
wondering why using their linker didn’t make a big difference.
Of course the answer was “there’s just not that much linking to do”, and so any
difference between mold and lld was within a second. GNU ld was lagging way
behind, at four seconds or so.
The case for sans-io
The most popular option to decompress ZIP files from the Rust programming language is a crate simply named zip — At the time of this writing, it has 48 million downloads. It’s fully-featured, supporting various compression methods, encryption, and even supports writing zip files.
However, that’s not the crate everyone uses to read ZIP files. Some applications benefit from using asynchronous I/O, especially if they decompress archives that they download from the network.
Day 11 (Advent of Code 2020)
Another day, another problem.
This time the problem looks suspiciously like Conway’s Game of Life, or, I guess, any old Cellular automaton.
We have a map like so:
L.LL.LL.LL
LLLLLLL.LL
L.L.L..L..
LLLL.LL.LL
L.LL.LL.LL
L.LLLLL.LL
..L.L.....
LLLLLLLLLL
L.LLLLLL.L
L.LLLLL.LL
And for each iteration:
Lsymbols turn into#if there’s no#in any of the 8 adjacent cells
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.
Serving ASCII cats over HTTP
Our catscii program does everything we want it to do, except that it’s a
command-line application rather than a web server. Let’s fix that.
Enter axum
The documentation for the axum crate tells us how to make a basic web server, and we honestly don’t need much more than that.
So let’s add axum:
amos@miles:~/catscii$ cargo add axum@0.6
Updating crates.io index
Adding axum =0.6 to dependencies.
Features:
+ form
+ http1
+ json
+ matched-path
+ original-uri
+ query
+ tokio
+ tower-log
- __private_docs
- headers
- http2
- macros
- multipart
- w
Reading files the hard way - Part 2 (x86 asm, linux kernel)
Looking at that latest mental model, it’s.. a bit suspicious that every program ends up calling the same set of functions. It’s almost like something different happens when calling those.
Are those even regular functions? Can we step through them with a debugger?
If we run our stdio-powered C program in gdb, and break on read, we can
confirm that we indeed end up calling a read function (which is called
__GI___libc_read here, but oh well):
ELF relocations
The last article, Position-independent code, was a mess. But who could blame us? We looked at the world, and found it to be a chaotic and seemingly nonsensical place. So, in order to blend in, we had to let go of a little bit of sanity.
The time has come to reclaim it.
Short of faulty memory sticks, memory locations don’t magically turn from
0x0 into valid addresses. Someone is doing the turning, and we’re going to
find out who, if it takes the rest of the series.