This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdbool.h> | |
#include <stdint.h> | |
struct map { // single threaded use only | |
const void** p; // p[n] | |
size_t n; | |
uint32_t m; // mask 0xFFFFFF for 3 bytes and 0xFFFFFFFFu for 4 bytes | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Linear Congruential Generator (LCG) and an XOR-based generator (XBG) | |
// like xoroshiro or xoshiro | |
static uint64_t random64(uint64_t* state) { | |
// Linear Congruential Generator with inline mixing | |
thread_local static bool initialized; | |
if (!initialized) { initialized = true; *state |= 1; }; | |
*state = (*state * 0xD1342543DE82EF95uLL) + 1; | |
uint64_t z = *state; | |
z = (z ^ (z >> 32)) * 0xDABA0B6EB09322E3uLL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef ft_header_included | |
#define ft_header_included | |
// Copyright (c) 2024, Leo Kuznetsov | |
// This code and the accompanying materials are made available under the | |
// terms of the BSD-3 license, which accompanies this distribution. The full | |
// text of the license may be found at https://opensource.org/license/bsd-3-clause | |
#include <assert.h> | |
#include <stdbool.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef rc_header_included | |
#define rc_header_included | |
// Copyright (c) 2024, "Leo" Dmitry Kuznetsov | |
// https://github.com/leok7v/rc | |
// This code and the accompanying materials are made available under the terms | |
// of BSD-3 license, which accompanies this distribution. The full text of the | |
// license may be found at https://opensource.org/license/bsd-3-clause | |
#include <stdint.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://chatgpt.com/share/696284b8-02bd-4651-a094-40feff0157ab | |
// https://en.wikipedia.org/wiki/Binary_heap | |
// J. W. J. Williams 1964 | |
enum { alphabet = 32 }; // > 2 and power of two | |
enum { max_nodes = alphabet * 2 }; | |
static_assert(alphabet > 2 && (alphabet & (alphabet - 1)) == 0, | |
"alphabet must be 2^n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct functor_s functor_t; | |
typedef struct functor_s { | |
void (*callback)(functor_t* f); | |
// other fields here | |
} functor_t; | |
typedef struct functor_ex_s { | |
union { | |
functor_t base; | |
struct functor_s; // open unnamed struct to push field names up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef vigil_h | |
#define vigil_h // https://github.com/munificent/vigil | |
// exports: trace_line_va() trace_line() traceln() swear() wrong() fatal_if_error() | |
#include <stdbool.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <windows.h> | |
#include <winternl.h> | |
#include <ntstatus.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef enum colors_t { | |
/* Main Panel Backgrounds */ | |
charcoal = 0x36454F, | |
onyx = 0x353839, | |
gunmetal = 0x2A3439, | |
jet_black = 0x343434, | |
outer_space = 0x414A4C, | |
eerie_black = 0x1B1B1B, | |
oil = 0x3B3C36, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <ctype.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <time.h> | |
typedef struct { | |
char* text; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// polyfit | |
// Created by leo on 6/25/22. | |
// Copyright © 2022 leok7v.github.io. All rights reserved. | |
#include <stdbool.h> | |
#include <assert.h> | |
#include <math.h> | |
#include <float.h> | |
// by Legendre in 1805: |
NewerOlder