218 results for "":

Reading files the hard way

Everybody knows how to use files. You just open up File Explorer, the Finder, or a File Manager, and bam - it’s chock-full of files. There’s folders and files as far as the eye can see. It’s a genuine filapalooza. I have never once heard someone complain there were not enough files on their computer.

But what is a file, really? And what does reading a file entail, exactly?

Day 6 (Advent of Code 2022)

Today I am joining you from the relative discomfort of my living room (since my better half has commandeered the home office due to Way Too Many Calls) to tackle the day 6 challenge, which I’m excited about: maybe despite, maybe because of, the low-grade fever I’m under.

Part 1

Our input is a jumble of letters, and we’re supposed to find the position of the first substring that’s “four different characters”.

Cross-platform game distribution

ooc makes it easy to compile your application on all major platforms (Windows, OSX, Linux) - the compiler itself runs there, and the SDK supports all these platforms with basic functionality: data structures, file handling, time handling, networking, etc.

But between getting your application running on your dev environment with all the libraries installed, and getting it into a neat package for your users to run without having to install any dependencies by hand, there’s a bag of tricks. Fortunately, I have found the time to figure most of them out. I’ll try to explain these in detail here as clearly as possible, here in this article.

So you want to live-reload Rust

Good morning! It is still 2020, and the world is literally on fire, so I guess we could all use a distraction.

This article continues the tradition of me getting shamelessly nerd-sniped - once by Pascal about small strings, then again by a twitch viewer about Rust enum sizes.

This time, Ana was handing out free nerdsnipes, so I got in line, and mine was:

The simplest shared library

In our last article, we managed to load and execute a PIE (position-independent executable) compiled from the following code:

; in `samples/hello-pie.asm` global _start section .text _start: mov rdi, 1 ; stdout fd lea rsi, [rel msg] mov rdx, 9 ; 8 chars + newline mov rax, 1 ; write syscall syscall xor rdi, rdi ; return code 0 mov rax, 60 ; exit syscall syscall section .data msg: db "hi there", 10

Remote development with Rust on fly.io

Disclaimer:

At the time of this writing, I benefit from the fly.io “Employee Free Tier”. I don’t pay for side projects hosted there “within reasonable limits”. The project discussed here qualifies for that.

Why you might want a remote dev environment

Fearmongering aside — and Cthulhu knows there’s been a bunch, since this unfortunate tweet — there’s a bunch of reasons to want a remote dev environment.

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

Even though we’re running this “code” command in the VM guest, VSCode set up enough plumbing that it communicates back to the host, telling it to open another VSCode window, connected to the same SSH remote, in the right folder.

When rustc explodes

One could say I have a bit of an obsession with build times.

I believe having a “tight feedback loop” is extremely valuable: when I work on a large codebase, I want to be able to make small incremental changes and check very often that things are going as expected.

Especially if I’m working on a project that needs to move quickly: say, the product for an early-stage startup, or a side-project for which I only ever get to do 1-hour work bursts at most.

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)

oocdoc, Part 4 — sourcepath

In , We’ve built a nagaqueen-based tool that can parse one ooc file, detect class declarations and print its doc strings. Today, we’re making a bit of infrastructure for our app to support more sizable projects.

Source path and lib folders

Parsing a single file was a nice milestone, but it’s not nearly enough. We want to generate documentation for a whole project at a time: and since we’ll want to cross-link the various bits of documentation we generate, we’ll also need to parse the various dependencies (such as the ooc sdk, and any used library) so that we can resolve argument types and link them properly.