Skip to content

Instantly share code, notes, and snippets.

View sodiboo's full-sized avatar

sodiboo

View GitHub Profile
# this is a home-manager module
{lib, options, ...}: let
settings-binds-type = let
traverse = v:
if (v ? _type && v._type == "option")
then
{
${lib.concatStringsSep "." v.loc} = v;
}
// traverse (v.type.getSubOptions v.loc)
@sodiboo
sodiboo / flake.nix
Created September 16, 2024 15:04
minimal flake.nix for use with iced
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
@sodiboo
sodiboo / optchild.rs
Created February 27, 2024 08:14
single-child parsing knuffel
use knuffel::{errors::DecodeError, traits::ErrorSpan};
#[derive(knuffel::Decode, Debug)]
enum Width {
Fixed(#[knuffel(argument)] u64),
Proportion(#[knuffel(argument)] f64),
}
#[derive(Debug)]
enum OptChild<T>
@sodiboo
sodiboo / Fixing Math.md
Last active September 23, 2022 20:16
Let's Fix Math (but only for the worst number type)

So, recently, i wrote a couple tweets where i explored how to theoretically overwrite the division implementation for C# numbers.

In short:

  • C# doesn't really have "primitives" but .NET does.
  • For primitives, division works with the div instruction. You can't edit this
  • C# does have first-class support like .NET's primitives (i.e. numeric literals, a keyword) for the decimal type
  • decimal corresponds to System.Decimal which is not a primitive type. Let's break it! i mean, uhh, fix math!
  • The goal is to make 0 / 2 == 0.5, or since we're doing decimals only, 0m / 2m == 0.5m. M for money i guess? i don't really know why that's the suffix C# uses, d was already taken for double i guess.
@sodiboo
sodiboo / emogex.md
Last active May 22, 2024 09:42
Emogex reference document

Emogex

Hi, emogex is an esoteric regular expression language based entirely on emojis. It was originally created as a joke at the @happyautomata twitter bot under this thread.

I've ended up actually using it regularly because i solve those FSMs to regexes on my phone, and it's more convenient to use emoji-based syntax because it's on the same keyboard as the language characters.

I've also noticed that other people (well, it's just this one guy so far at least two people) are now using emogex unironically to solve them, so i thought it's about time to write it all in a single document so you can more conveniently reference all the features of the language with

@sodiboo
sodiboo / CrossPlatformMuck.md
Last active July 25, 2021 23:25
Cross-Platform modding guide for Muck

Cross-Platform modding for Muck.

Even though this guide is specifically for Muck, most of it applies to any Unity game.

Muck is compiled using Mono, which is cross-platform. I did notice that the hashes of the assemblies for the Linux version are not the same as the Windows version, but my mods seemed to work regardless.

Because assemblies are cross-platform, if your mod only applies code patches with no additional assets, you don't need to do anything about the AssetBundles. However, if your mod reads or writes any files to the disk, make sure not to hardcode backslashes! To work with the filesystem, use .NET's Path helpers, they will make sure you write to the desired location!

BAD: