Skip to content

Instantly share code, notes, and snippets.

//! Heavily based on <https://youtu.be/qnGoGq7DWMc> and <https://github.com/TanTanDev/binary_greedy_mesher_demo>
//! See that video and repo for more information
//!
//! # Finding what faces to draw
//!
//! For more information, see:
//! - <https://www.youtube.com/watch?v=qnGoGq7DWMc>
//!
//! First we build an bitmask of all [`Occupied<_>`] blocks for all 3 directions [`X`], [`Y`], and [`Z`]. We do this for each [`BlockId`].
//!

Base grid cell

grid.trains.mp4
0eNqlXe1u20gMfBf9tgvtLvcrr3IoCicRUgGObThOcUWRdz/JtlLHJpMZ3Z/rJZWnJGfJXXIp+k9zv37tdvt+c2ju/jQvm9Vuedgun/b94/jzv81dbRfN7/GPt0Wzun/Zrl8P3XJ8btdvnpq7w/61WzT9w3bz0tz9MyD0T5vVevzs4feua+6a/tA9N4tms3oef9qv+nUzIPWbx24Ad2/fF023OfSHvjt9/vjD7x+b1+f7bj888P7J+/5p2a27h8O+f1jututuAN1tX4ZPbjdnUf1RUj/AD+Jshkf7o1R/Gjf+Z989Xv4Lo4Lytvjws5M0CvS077oN9Ozb8G9tuv7p5/32dT8qIIvh998vHp0U8e+KvBwGIzz9PCyPtrhRIh6VcG8KRvhrxu39drfdHxQb1LMRlM8LY8xAW9NdWSiatlSevLGkW0TNjpHRIf3vFVHg9VDU1VA0HRLAY4o2jxldS6Xai6kwhqy0IeO1u0RnmlJ99saYcTH8XjNn5VwraNZw7YcQtXz4ueo3y3MwuyXn2xnq2yB689jvTwb5uCjeoR0DXfIFtobmSfJ1dQOK4o4gV2p6DVJQyABDRo5ZBDKxkBoI7IAZlqugkBWG/OsXD6/7X92jxfDJt9NHxKTtYS28auBl4x2MCa8bD/uIgxeOD6A1C2xN2GEcvIw87DEOXkcedhmPsw57kMdZh13I46zDe4uHOQqwF3mYowB7UYA5CrAXBZijAO87AeYo4BsPzhHsRwHnCPYjwTmC/UhwjgoW6SRpkS5oiLAXCcy6wF4kMOsCe5HArAue+MGsC+xFEWZdYC+KOEf4+Q3nCD/A4RzBXpRwjuDdKOEcwX6UYI4i7EcJ5ijCfpRgjiLsRxnmKMJ+lGGOIuxHGecI9qOMcwT7UcY5ytjOUTy6c0TYiwrOOuxFBWY
@VictorKoenders
VictorKoenders / JwtHelper.cs
Last active November 29, 2023 11:03
JWT helper function for encoding/decoding + validating JWT tokens
public static class JwtHelper
{
static ECDsa? ECDsaKey { get; set; }
public static string InitializeWithRandomKey()
{
ECDsaKey = ECDsa.Create(ECCurve.CreateFromFriendlyName("nistP521"));
return StringKey;
}
@VictorKoenders
VictorKoenders / Military outpost.md
Last active November 26, 2023 11:24
Factorio blueprints

Military outpost:

Make sure the trains get in from the far side. If they come in from the side they will get stuck.

Point the station side at the biters.

The outpost:

@VictorKoenders
VictorKoenders / Startup.cs
Created November 21, 2023 10:28
Dump C# provider info
var configuration = //... ;
foreach (IConfigurationProvider provider in configuration.Providers)
{
DumpProviderSource(dbg, "", provider);
}
//
private void DumpProviderSource(StringBuilder dbg, string indent, IConfigurationProvider provider)
{
@VictorKoenders
VictorKoenders / Attribute.cs
Created November 16, 2023 07:55
[JsonMerge] attribute
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class JsonMergeAttribute : Attribute
{
public JsonMergeAttribute(string propertyName)
{
PropertyName = propertyName;
}
public string PropertyName { get; }
@VictorKoenders
VictorKoenders / DataContext.cs
Last active November 17, 2023 07:13
C# EF timescale
public class DataContext : DbContextBase<DataContext>
{
protected override string Schema => "Foo";
public DbSet<TimescaleEntry> TimescaleEntries { get; set; }
public DataContext(DbContextOptions<DataContext> options) : base(options)
{
}
}
trait ReceiverTask {
type Message;
async fn invoke(&mut self, message: Self::Message);
}
enum ReceiverTaskMessage<M> {
Shutdown,
Timeout,
Message(M),
}
@VictorKoenders
VictorKoenders / atomic_mutex.rs
Last active June 1, 2022 09:36
Atomic mutex
use core::{sync::atomic::{AtomicBool, Ordering}, cell::UnsafeCell, ops::{Deref, DerefMut}};
pub struct AtomicMutex<T> {
locked: AtomicBool,
data: UnsafeCell<T>,
}
impl<T> AtomicMutex<T> {
pub const fn new(val: T) -> Self {
Self {
ENTRY(_start)
SECTIONS
{
. = 0x0;
.text : { *(.text) }
.rodata : { *(.rodata) }
}