Skip to content

Instantly share code, notes, and snippets.

View Artoria2e5's full-sized avatar
💤
Functionally asleep

Mingye Wang Artoria2e5

💤
Functionally asleep
View GitHub Profile
@Artoria2e5
Artoria2e5 / README.md
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
Artoria2e5 / fish.sh
Created March 15, 2023 17:42
Make fishingbot turn. Lol.
#!/bin/bash
# companion script to fishingbot -- automatically turn
# Use the MiniHUD mod to get the yaw and pitch values
# Yaw wraps around at -180
YAW_MIN=135
YAW_MAX=-135
YAW_STEP=5
PITCH_MIN=-1
@Artoria2e5
Artoria2e5 / devise.zh-CN.yml
Last active December 5, 2023 04:35
Devise 4.2.6 zh files
# Chinese (China) translations for Devise 4.2.1
# 4.2.0: By HealthGrid at https://gist.github.com/HealthGrid/2d702b38aa6ffe0233f27d3d5be9250f
# 4.2.1: By Artoria2e5 (this file)
# - Fixes pluralization problems (zh only takes "other")
# - Misc translation improvements, you know what these grammar things are.
# - Should be minor enough to claim CC0 for my changes.
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
zh-CN:
devise:
@Artoria2e5
Artoria2e5 / 00_main.md
Last active September 5, 2023 05:05
can we backport librsvg to buster?

Environment

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

Dependencies

apt install librsvg2-dev build-essential fakeroot devscripts
apt build-dep librsvg2-dev
@Artoria2e5
Artoria2e5 / 00_README.md
Last active May 24, 2023 14:35
Want a C version of bits/stdc++.h? Now you have it.

bits/stdc.h

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.

LOICENSE

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

@Artoria2e5
Artoria2e5 / viks.md
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
Artoria2e5 / bd_mercator.js
Last active July 14, 2021 08:14
Baidu's Twist on Web Mercator (as shown at https://github.com/GeeBar/coord/pull/3)
// Reference value:
// http://lbsyun.baidu.com/index.php?title=webapi/guide/changeposition
// type 5 (lon,lat) -> type 6 (x,y)
// js source, presumably same as ref?
// https://github.com/GeeBar/coord/blob/master/mercator.js
var BD_EXTENT_LON = 20037726.372144807 // ? - lon only; lat goes less
var BD_EXTENT_LAT = 12474104.1741418
// Their js truncated at 74, but included taylor terms up to 75~90 (82.5).
// These terms are severly screwed thanks to their misunderstanding of taylor.
@Artoria2e5
Artoria2e5 / cursed_wav.py
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
Artoria2e5 / addendum_italics.md
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
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"