Skip to content

Instantly share code, notes, and snippets.

View BurntNail's full-sized avatar

Jack Maguire BurntNail

View GitHub Profile
@BurntNail
BurntNail / queue.c
Last active February 4, 2025 07:10
Very basic double-ended queue in C99
//
// Created by jack on 03/02/25.
//
#include <stdlib.h>
#include <string.h>
typedef struct Queue {
int* allocation_start;
int* start;
@BurntNail
BurntNail / main.rs
Last active November 25, 2024 04:09
Basic single-threaded async executor
use std::future::Future;
use std::sync::mpsc::{Sender, channel};
use std::pin::Pin;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::task::{RawWaker, Waker, Context, Poll};
use std::thread::JoinHandle;
use std::time::{Instant, Duration};
use waker::{WakerData, VTABLE};
@BurntNail
BurntNail / main.rs
Created November 19, 2024 12:27
Solution to riteangle problem
use itertools::Itertools;
use std::time::Instant;
fn main() {
time("elegant", maybe_more_elegant);
time("bf", bruteforce);
}
fn time(name: &'static str, method: impl Fn()) {
let start = Instant::now();
@BurntNail
BurntNail / lib.rs
Created October 30, 2024 01:23
Unsigned Integer Compressed Serialisation
const MAX_BYTES: usize = u128::BITS as usize / 8;
const ONE_BYTE_MAX_SIZE: usize = u8::MAX as usize - MAX_BYTES;
struct Integer {
content: [u8; MAX_BYTES],
bytes_used: usize
}
impl From<usize> for Integer {
fn main() {
let target = Film {
horror: 5.0,
thriller: 4.0,
romance: 0.0,
comedy: 0.0,
};
let films = [
(

Keybase proof

I hereby claim:

  • I am burntnail on github.
  • I am burntnail (https://keybase.io/burntnail) on keybase.
  • I have a public key ASA5XVQnbE3TONXSmIrASxReJFPkge5JGgaYdRCIQcEqCwo

To claim this, I am signing this object:

@BurntNail
BurntNail / main.rs
Last active January 13, 2024 14:15
An allocator for all sizes & types, backed by UnsafeCell<[u8; 1_000_000_000]>
use std::alloc::{GlobalAlloc, Layout};
use std::cell::UnsafeCell;
use std::sync::atomic::{AtomicBool, Ordering};
mod printing {
use super::get_thread_id;
use std::alloc::Layout;
const STDOUT_FILENO: i32 = 1;
@BurntNail
BurntNail / main.rs
Created January 10, 2024 22:39
Serialising Rust structs to and from binary directly
use std::{
alloc::Layout,
fs::File,
io::{Read, Write},
};
#[derive(Debug, Copy, Clone)]
struct ExampleData {
a: u8,
b: u64,
@BurntNail
BurntNail / main.rs
Created January 10, 2024 22:36
Allocator that only deals with 4-4 layouts, and only has 64 slots for concurrent allocations
use std::sync::atomic::{AtomicBool, Ordering::SeqCst};
use std::cell::UnsafeCell;
use std::alloc::{GlobalAlloc, Layout};
pub struct FourAllocator {
is_allocating: AtomicBool,
tracker: UnsafeCell<usize>,
spaces: UnsafeCell<[u8; usize::BITS as usize * 4]>
}
@BurntNail
BurntNail / TrueTaper.py
Created January 13, 2021 11:22
Blender Addon to truly taper a face.
import bpy
from bpy.utils import register_class, unregister_class
from bpy.props import FloatProperty
class TrueTaperOperator (bpy.types.Operator):
bl_idname = "ops.true_taper"
bl_label = "True Taper a face"
bl_options = {'REGISTER', 'UNDO'}
thicc: FloatProperty(name="Taper Size", default=0.1)