Skip to content

June 2023#

Friday, 30#

Kirk#

Have been reading the GTK documentation today.

Thursday, 29#

Kirk#

Fixed build dependencies for the blueprints, set up the package in the Nix flake.

Wednesday, 28#

dotfiles#

Changed my Neovim config, making it so that LSP clients (managed both via nvim-lspconfig and null-ls) are attached after a Direnv environment is exported. This is something that bothered me for a long time, and I finally fixed it (took me the whole day!).

Also, nuked the default S and s keybindings, those were rather annoying.

Tuesday, 27#

Kirk#

Added a configuration header. Read the Blueprint‘s documentation. The tool is pretty neat! Waiting on the bump in the Nixpkgs, though.

Monday, 26#

Kirk#

Set up a basic skeleton for the project, including the build scripts for common types of resources. Also, finally tried out Blueprint.

Sunday, 25#

C#

Went through the C reference on cppreference.com.

Kirk#

Moved my build system setup from the playground to the repository. Next up: reading into Gtk, GLib, GObject (and maybe more). I also found Devhelp to be useful for having these references offline and of the same version as the libraries in the current Nix environment.

Friday, 23#

Documentation#

I’ve been looking for options to implement the documentation system for my future C project. Here are the variants so far:

Thursday, 22#

C#

Finished reading the C programming language book.

I’m up for reading the cppreference.com now for the up-to-date state of the language. By the way, while reading the aforementioned book, I’ve been using Zeal for having this reference offline and having a proper search engine for it.

glibc#

Holy moly, the GNU C Library (glibc) manual is 1228 pages long in the PDF form… Anyhoo, coming from Zig, I’m used to being able to read the source code of the standard library, and it’s somewhat convoluted to do since GNU folks prefer to use a stack of old technologies like gitweb for Git web interface, Mailman for electronic mail discussion and e-newsletter lists, Bugzilla for tracking issues. I don’t mind that, though, so I just cloned their repo locally.

GR#

Worked on the PR review remarks, including creating a PR to the upstream.

Wednesday, 21#

C#

Read more of the C programming language book.

Reading the chapter about the UNIX System Interface, getting some Fortran flashbacks.

Private torrent trackers#

I’m using 3 private trackers right now, and it’s getting somewhat cumbersome managing the profiles on them. Today I finally found a torrent that doesn’t exist on public trackers.

Tuesday, 20#

C#

Read more of the C programming language book.

Played around more with the styles of the code (via ClangFormat). I’m one of those AlwaysBreakAfterReturnType: AllDefinitions type of guys…

Zigmod#

Worked on making builds via my buildZigmodPackage function avoid unnecessary builds of the fixed-output derivations for dependencies while making the build more deterministic (by requiring a lock file). This pull request is one of my earliest contributions to Nixpkgs, and it’s still work-in-progress!

Monday, 19#

C#

Started playing around with structs. Added cpplint to the Meson build file in my playground.

GR#

Spent a lot of time figuring out how to make the Nix derivation work on Darwin. Even tried enabling Objective-C compilation by patching the CMake build file. Turns out the fixes are pretty simple: don’t build the QtWayland module and use the Darwin specific stdenv.

Sunday, 18#

C#

Okay, I got it: you get a *char if you just return an array, and you get a char (*)[SIZE] if you return a pointer to an array with a known size. Here’s a revised version of the yesterday’s snippet:

Explanations
#include <stdio.h>

// Constant `char`
const char x1 = 'a';

// Function returning a `char`
char x2() { return x1; }

// Pointer to a function returning a `char`
char (*x3)() = &x2;

// Array of `char`s
char x4[] = {'b', x1};

// Array of pointers to constant `char`s
const char(*x5[]) = {&x1};

// Array of pointers to functions returning a `char`
char (*x6[])() = {&x2};

// Function returning a pointer to an array of
// pointers to functions returning a `char`
char (*(*x7())[])() { return &x6; }

// Function returning a pointer to an array of `char`s
char *x8() { return x4; }

// Array of pointers to functions returning
// a pointer to an array of `char`s
char *(*x9[])() = {x8};

// Function returning a pointer to a fixed size array of `char`s
char (*x10())[2] { return &x4; }

// A fixed size array of pointers to functions returning
// a pointer to a fixed size array of `char`s
char (*(*x11[1])())[2] = {x10};

// Print 'a' thrice
int main() {
    char x = (*x7())[0]();
    printf("%c\n", x);
    x = x9[0]()[1];
    printf("%c\n", x);
    x = (*x11[0]())[1];
    printf("%c\n", x);
}

GR#

Added a package for the GR framework to Nixpkgs. It’s my preferred plotting backend for quick plots via the Plots package for Julia (I prefer PGFPlotsX for quality plots, though). With this package you will be able to easily use GR (just set the GRDIR variable) without having to resort to patchelf hacks.

Saturday, 17#

C#

Here are a couple of scary looking type definitions in C (from K&R):

  • char (*(*x())[])()
  • char (*(*x[3])())[5]

I couldn’t figure out (yet) how to make my compiler happy about the last one (ain’t a fan of pointers to fixed size arrays, seems like), but here are my explanations so far:

Explanations
#include <stdio.h>

// Constant `char`
const char x1 = 'a';

// Function returning a `char`
char x2() { return x1; }

// Pointer to a function returning a `char`
char (*x3)() = &x2;

// Array of `char`s
char x4[] = {x1, x1};

// Array of pointers to constant `char`s
const char(*x5[]) = {&x1};

// Array of pointers to functions returning a `char`
char (*x6[])() = {&x2};

// Function returning a pointer to an array of
// pointers to functions returning a `char`
char (*(*x7())[])() { return &x6; }

// Function returning a pointer to an array of `char`s
char *x8() { return x4; }

// Array of pointers to functions returning
// a pointer to an array of `char`s
char *(*x9[])() = {x8};

// Print 'a' twice
int main() {
    char x = (*x7())[0]();
    printf("%c\n", x);
    x = *(x9[0])();
    printf("%c\n", x);
}

Also, check out this pretty cool example of how to construct such definitions easily.

TorrentLeech#

Okay, here’s a hot tip if you’re a TorrentLeech user: add 100 torrents slightly more than 10 MB and let the flow of TL Points commence!

Also, according to my testing, the points are updated at 40-20 minutes intervals. Specifically, at every 23d and 42d minute of each hour.

Friday, 16#

C#

Finished reading the 60 terrible tips for a C++ developer article, and it’s pretty good. Although, I still don’t like that OOP abominations (especially those implemented in C++) are still pushed nowadays. Really, programs are just data structures and algorithms.

Mouse pad#

Ordered a mouse pad today. Turns out there is some distinction in quality, and since I need it to be small, I’m forced to use cloth as the top material (which is not necessarily bad, but might be a problem if it gets dirty). And you still sorta inevitably have to overpay for a brand logo.

Objectivism#

Watched the Top 10 (+1) Things Leonard Peikoff Did For Me (and You) and it was really pleasant to listen to Robert Nasir genuinely and passionately explaining how the man, the myth, the legend affected his life. It also made me think about how all-encompassing and enduring, yet close to the ground Objectivism can be, and I definitely need to pick it up sooner than later.

Thursday, 15#

Apartment#

Spent some time looking into how adults buy/rent apartments and stuff.

I think it’s better to get a decent (some?) income first, though.

Static analyzer#

Was reading the 60 terrible tips for a C++ developer article today (and still haven’t finished it). I’m not planning to touch C++ in the foreseeable future, but I’m planning to switch to C as my primary language, and this article is still quite useful. Ended up setting cppcheck as a custom target in the Meson build file in my playground project for K&R. I already had set up ASan and UBSan (which I find to be better than dynamic analysis via Valgrind), and I guess I will be able to fit some more analyzers.

Wednesday, 14#

C#

Read more of the C programming language book.

MTU#

Now that I’m home, I was wondering whether there are issues with my home network configuration. I found out that my whole MTU configuration was inefficient. Here’s what I did.

Before going forward, it makes sense to check what value of MTU your ISP is recommending. For example, for PPPoE v2 it’s 1492, but for DS-Lite over PPPoE (which is what my ISP uses) it’s 1452.

To find out the optimal MTU value for your currently active wireless network (assuming the interface is wlo1), disable VPN and run

ping -s $(( $(cat /sys/class/net/wlo1/mtu) - 28)) -M do "8.8.8.8" -c 1
The 28 bytes are subtracted because of the ping itself (see explanation here). If your MTU is too high, you will see an error similar to

ping: local error: message too long, mtu=1452

where the specified value is the optimal MTU. Set it for your network (if you’re using NetworkManager, you can do so via nmtui). Make sure you reconnect to the network, so the interface is recreated. You can check the current value of MTU by running ip a. Run the following command and make sure you receive a response:

ping -s $(( $(cat /sys/class/net/wlo1/mtu) - 28)) -D "8.8.8.8" -c 1

The overhead of the Wireguard protocol is 60 bytes if you’re using IPv4 only or 80 bytes if you’re using IPv6. Subtract the appropriate value and use the result as MTU in your Wireguard configs.

It also makes sense to benchmark your upload and download speeds after the changes on sites like speedtest.net (use the closest server to your actual physical location for reliability) and compare them to the ones claimed by your ISP.

Tuesday, 13#

C#

Read some more of the C programming language book. Playing around with pointers arithmetic right now.

Monday, 12#

BookBrainz#

I will be switching to BookBrainz for linking to books going forward. Even though it’s very much a work-in-progress, it seems to be the only viable open source bibliographical database. I’ve been using Goodreads before, but it’s proprietary and owned by Amazon (big yikes). Open Library is fine, but I much prefer MetaBrainz‘s products as a happy MusicBrainz and ListenBrainz user.

C#

Read more of the C programming language book. I learned today that the C2x standard will introduce traditional one-byte booleans, and that using gotos is okay to break out of a nested loop or to handle cleanup code from multiple locations.

Zigmod#

Spent some time refining the derivation for Zigmod.

Sunday, 11#

Nix#

Was researching ways of sandboxing Nix applications today (again). Aside from Flatpak (which I use now) and firejail (which I tried last time), I looked into bubblewrap, bubblejail, nixpak, AppArmor. All of these new ones pretty much expect you to write your own profiles when necessary, which is rather inconvenient. Compared to others, AppArmor doesn’t require you to wrap the binaries and works as a kernel module based on system policies, which is very close to what I’d like. And yet, I missed easily declaring Spotify in conjunction with spicetify (via spicetify-nix); having better plugin support (e.g., for mpv, OBS and VLC); having KeePassXC‘s browser integration working. So I nuked all Flatpaks and switched back to native packages. This is probably gonna bite me someday, but hey, whatever.

Saturday, 10#

Meson#

Finished reading the manuals and playing around with Meson, Ninja and Ccache. Ready for some blazingly fast builds!

Friday, 9#

Meson#

Home at last. Reading into Meson.

Tuesday, 6#

PMG#

Defended my diploma today and received an “excellent” rating! This work is finally finished.

Dobby is free!

Monday, 5#

PMG#

We gathered with groupmates today to discuss the presentations. Applied some stylistic changes as a result.

Sunday, 4#

PMG#

Aight, done did it: compressed the presentation under 10 minutes.

My legs hurt from walking in circles so much (pretty much the whole day on feet).

Saturday, 3#

PMG#

Committed the code of the presentation, rehearsed and reduced the text more (turns out there’s really not that much you can fit under 10 minutes). I might reduce it even more, will do some more timing tomorrow.

Friday, 2#

PMG#

Spent most of the day just walking outside in circles, preparing the speech for the presentation. It’s kinda chilly out there.

Thursday, 1#

PMG#

Worked on the presentation a bit more.

Private torrent trackers#

Yesterday RARGB was discontinued. That’s rather sad since it was one of the best public torrent trackers out there. TorrentLeech, one of the popular private trackers, gives away invites on the occasion, and today I got one. This is my first private tracker (and I’ve been torrenting for more than 10 years), so I learned about ratios, hit-and-runs, and more.

Here’s my opinion so far: it doesn’t make any sense to download releases that are not marked as FREELEECH (releases that don’t count into the downloading count, meaning they don’t affect the ratio, which is the division of uploaded to downloaded), since the pool of people is much smaller than on public trackers, and everyone downloading is obliged to be seeding, too. I can’t really compete with people using seedboxes. Since FREELEECH releases are always seeded, you can get high-quality content (which is what is usually marked with this tag) quite easily.

TL Points are a joke, though, not gonna lie. I counted that it will take me about a year (without bonuses) of seeding to repay for the 3 GB I’ve downloaded today.