219 results for "":
Cracking Electron apps open
I use the draw.io desktop app to
make diagrams for my website. I run it on an actual desktop, like Windows or
macOS, but the asset pipeline that converts .drawio files, to .pdf, to
.svg, and then to .svg again (but smaller) runs on Linux.
So I have a Rust program somewhere that opens headless chromium, and loads just the HTML/JS/CSS part of draw.io I need to render my diagrams, and then use Chromium’s “print to PDF” functionality to save a PDF.
Pin and suffering
Disclaimer:
async fn in trait has shipped in Rust 1.75, about 2.5 years after
this article was written.
I’d like to think that my understanding of “async Rust” has increased over the past year or so. I’m 100% onboard with the basic principle: I would like to handle thousands of concurrent tasks using a handful of threads. That sounds great!
Porting poppler to meson
It took a hot minute.
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)
Day 4 (Advent of Code 2022)
Part 1
Let’s tackle the day 4 challenge!
In this one, we get an input like this:
2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8
Each line has two ranges: the first line has ranges containing 2, 3, 4, and 6, 7, 8. We must count how many pairs have ranges where one fully contains the other.
In Rust, we can express this with “inclusive ranges”
(std::ops::RangeInclusive),
and those implement Iterator, so we can do:
Thread-local storage
Welcome back and thanks for joining us for the reads notes… the thirteenth installment of our series on ELF files, what they are, what they can do, what does the dynamic linker do to them, and how can we do it ourselves.
I’ve been pretty successfully avoiding talking about TLS so far (no, not that one) but I guess we’ve reached a point where it cannot be delayed any further, so.
Everything but ELF
And we’re back!
In the last article, we thanked our old code and bade it adieu, for it did not spark joy. And then we made a new, solid foundation, on which we planned to actually make an executable packer.
As part of this endeavor, we’ve made a crate called encore, which only
depends on libcore, and provides some of the things libstd would give us,
but which we cannot have, because we do not want to rely on a libc.
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.
Fine, we'll relocate our own binary!
Welcome back to the eighteenth and final part of “Making our own executable packer”.
In the last article, we had
a lot of fun. We already had a “packer” executable, minipak, which joined
together stage1 (a launcher), and a compressed version of whichever executable
we wanted to pack.
What we added, was a whole bunch of abstractions to parse ELF headers using
deku, which we used from stage1 to be able to
launch the guest executable from memory, instead of writing it to a file and
using execve on it.
Making our own spectrogram
A couple months ago I made a loudness meter and went way too in-depth into how humans have measured loudness over time.
Today we’re looking at a spectrogram visualization I made, which is a lot more entertaining!
We’re going to talk about how to extract frequencies from sound waves, but also how my spectrogram app is assembled from different Rust crates, how it handles audio and graphics threads, how it draws the spectrogram etc.
Having fun with ooc
Unfortunately, the ooc language could have better documentation. In the meantime, I’d like to blog about about some features that might not be very well-known.
Nested functions
Here’s a program that prints 1, 3, 5, 7, 9:
import structs/ArrayList
main: func {
list := ArrayList<Int> new()
addIfOdd := func (i: Int) {
if (i % 2 != 0) list add(i)
}
for (i in 0..10) {
addIfOdd(i)
}
list map(|i| i toString()) join(", ") println()
}