Skip to content

Instantly share code, notes, and snippets.

View Kamillaova's full-sized avatar
🏳️

Kamilla 'ova Kamillaova

🏳️
View GitHub Profile
@manveru
manveru / base64.nix
Created September 6, 2023 03:19
Encode to base 64 in pure Nix
{lib, ...}: {
toBase64 = text: let
inherit (lib) sublist mod stringToCharacters concatMapStrings;
inherit (lib.strings) charToInt;
inherit (builtins) substring foldl' genList elemAt length concatStringsSep stringLength;
lookup = stringToCharacters "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
sliceN = size: list: n: sublist (n * size) size list;
pows = [(64 * 64 * 64) (64 * 64) 64 1];
intSextets = i: map (j: mod (i / j) 64) pows;
compose = f: g: x: f (g x);
@udf
udf / write_up.md
Last active November 13, 2024 05:44
A Trick To Use mkMerge at The Top Level of a NixOS module

The Setup

I wanted to write a module that generates multiple systemd services and timers to scrub some zfs pools at certain intervals. The default scrub config does not support individual scrub intervals for each pool.

I want the config to look like this:

{
  services.zfs-auto-scrub = {
 tank = "Sat *-*-* 00:00:00";
@HolyMonkey
HolyMonkey / GravityScale.cs
Last active August 7, 2021 04:22 — forked from Priler/CubeController.cs
JumpManager.cs
using UnityEngine;
//Внезапно хауди списывая код с уроков забыл послушать что он означал
//В конечном итоге у него получился просто постоянный скейлинг гравитации
[RequireComponent(typeof(Rigidbody))]
class GravityScale : MonoBehaviour
{
[SerializeField] private float _scale = 10f;
private Rigidbody _self;
@HexedHero
HexedHero / mc_client_performance_guide.md
Last active October 18, 2024 08:50
Performance guide for Minecraft 1.20.6+ Clients

Performance guide for Minecraft 1.20.6+ Clients

📜 Fabric

Fabric is the "modern" Minecraft modding software that is very modular.
We use Fabric in this guide so install it by going to https://fabricmc.net/use/ Download the .jar or .exe and run it.

Below is a list of performance and utility mods to make your Minecraft experience better and most importantly smooth.
The list is in order of most importance and they all work together including what they do with why to use them.

@gdamjan
gdamjan / README.md
Last active October 11, 2024 06:36
libvirt with ipvtap over wifi

ipvtap over wifi for libvirt

ipvtap is similar to macvtap, but works over wifi too, since it uses the same mac address as the wifi interface.

libvirt doesn't support ipvtap, so we have to configure everything manually. Important data we need before we start:

  • the name of the wifi interface, wlan0 in my case (it's already connected - use NM or networkd+iwd).
  • the mac address of the wifi interface (it must be the same in the guest too)

On the host:

@kvverti
kvverti / module.md
Last active June 24, 2023 01:48
The Fabric API Problem

Fabric API

Fabric API is supposed to be modular. This means that mod devs should be able to pick and choose which Fabric API modules to depend on in their mods, both in the development environment and in production.

Fabric API is also supposed to be just another mod. Fabric API should not have special support in Fabric tooling, nor should it be a required install for players. Basically, Fabric API is simply a collection of mostly independent modules that happen to be maintained by the same organization that maintains Fabric tooling.

The Problem

The fabric example mod contains a hard dependency on the entire Fabric API. Since most mod devs do not remove this dependency, most players have to download an additional mod (Fabric API) in order to play a Fabric mod, which many players do not expect. This means mod devs often assume that players have installed Fabric API in the production evnironment.

@ccbrown
ccbrown / DumpHex.c
Last active October 16, 2024 07:37
Compact C Hex Dump Function w/ASCII
#include <stdio.h>
void DumpHex(const void* data, size_t size) {
char ascii[17];
size_t i, j;
ascii[16] = '\0';
for (i = 0; i < size; ++i) {
printf("%02X ", ((unsigned char*)data)[i]);
if (((unsigned char*)data)[i] >= ' ' && ((unsigned char*)data)[i] <= '~') {
ascii[i % 16] = ((unsigned char*)data)[i];
@mosra
mosra / README.md
Last active April 11, 2023 03:16
Most Obscure Features of C++