Skip to content

Instantly share code, notes, and snippets.

View Artoria2e5's full-sized avatar
not focusing!

Mingye Wang Artoria2e5

not focusing!
View GitHub Profile
Artoria2e5 /
Last active May 24, 2023 14:35
Want a C version of bits/stdc++.h? Now you have it.


People worry about the lack of an everything include file for stdc like libstdc++ had for C++. Worry no more! Now you can also mindlessly use one pch for C!

Honestly, just std C headers is no where near big (and slow) enough to make people want to use pch. At least we should drag POSIX in.


This stuff is GPL 3+ with the GCC Runtime Library Exception 3.1. What does it mean?

Artoria2e5 /
Last active September 5, 2023 05:05
can we backport librsvg to buster?


I took a WSL1 environment containing Bullseye and performed a downgrade to Buster per Apt isn't complaining at all, so it's probably a good enough buster.


apt install librsvg2-dev build-essential fakeroot devscripts
apt build-dep librsvg2-dev
Artoria2e5 /
Created March 15, 2023 17:42
Make fishingbot turn. Lol.
# companion script to fishingbot -- automatically turn
# Use the MiniHUD mod to get the yaw and pitch values
# Yaw wraps around at -180
Artoria2e5 /
Last active March 2, 2023 13:50
Victoria 3 savefile format
  • Files always start with AD 55 01 00 03 00
  • Strings are coded as length (uint16 LE), followed by bytes
  • 0F 00 is... something
  • meta is just the head portion of gamestate (country name, country flag, mods, game flags/rules)
Artoria2e5 /
Created May 19, 2021 02:48
glob(3) for winpaths

Instead of writing stuff I decided to chicken out and talk.

Anyways, Windows paths use \ as the path separator. You might see it as horrible (it is), but for globbing it is actually fine since ? and * are disallowed in filenames. You will still need to escape [ and the extglob (, but recall that | is disallowed too so you can just use that as the escape character.

You may or may not need to have a compile step to convert this glob into actual glob(7). For that you just replace all instances of \ with /, and all

Artoria2e5 /
Last active May 4, 2021 08:34
Pretend that your 32-bit floating-point WAV is 32-bit integer
#!/usr/bin/env python3
This cursed piece of shit lets you pretend your 32-bit floating-point
WAV is actually 32-bit integer, so FLAC may take it. Now the only encoder
that does 32-bit integer is some SVN build of FLAKE I have no intention
of compiling, so I can't test how badly it compresses.
What I can tell you is that WavPack hates it. It compressess down to about
84% of the original, which is worse than 7-zip. On the other hand the original
f32 version goes down to 58%. The test file is decoded from Open Goldberg,
Artoria2e5 /
Created March 8, 2021 10:18
Addendum to "Italics and colour in manual pages on a nosh user-space virtual terminal"

Addendum to Italics and colour in manual pages on a nosh user-space virtual terminal

This is an addendum to Jonathan de Boyne Pollard's Italics and colour in manual pages on a nosh user-space virtual terminal.

FreeBSD and other mandoc deployments

FreeBSD et al. has switched to mandoc as their main manpage formatter. This formatter is faster, but is only capable of emitting overstrike for bold and underline. The only way to see italicized text is by telling less to make italics when it wants underline:

export LESS_TERMCAP_us=$(tput sitm || tput us) LESS_TERMCAP_ue=$(tput ritm || tput ue) 2>/dev/null
Artoria2e5 / sun_getopt.c
Last active October 5, 2020 01:06
getopt(3) in the Solaris way, as a wrapper around getopt_long(3)
* sun_getopt - Solaris-style getopt(3), as a wrapper around getopt_long(3).
* Written by Mingye Wang (Artoria2e5). Dedicated to the public domain under
* Creative Commons Zero.
* Untested. Like not even fed to a compiler once.
#include "sun_getopt.h"
Artoria2e5 /
Last active July 4, 2020 20:15
Copy a minecraft directory with some symlinks
# duplicate-minecraft-dir: copies a minecraft directory with some symlinks.
# Requires uname and GNU coreutils.
# Requires admin priv under Windows.
# Dedicated to the public domain under Creative Commons Zero. Do what the heck you wanna do with it.
die(){ printf '%s: %s\n' "$SELF" "$1">&2; exit "${2-2}"; }
log() { local level=$1; if ((VERBOSE >= level)); then printf '%s: %s\n' "$SELF" "$2">&2; fi; }
nolink=(config options\*.txt launcher_profiles.json servers.dat config baritone Impact mods)