This file contains hidden or 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
const Pcg32 = struct { | |
state: u64, | |
fn next_u32(self: *Pcg32) u32 { | |
const s = self.state; | |
self.state = s *% 0x5851f42d4c957f2d +% 0x14057b7ef767814f; | |
const xorshifted: u32 = @truncate((s ^ (s >> 18)) >> 27); | |
const rot: u5 = @intCast(s >> 59); | |
return (xorshifted >> rot) | (xorshifted << -% rot); |
This file contains hidden or 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 <stdint.h> | |
static inline uint64_t multiply_mix(uint64_t x, uint64_t y) { | |
__uint128_t m = (__uint128_t)x * (__uint128_t)y; | |
uint64_t hi = m >> 64; | |
uint64_t lo = m; | |
return lo ^ hi; | |
} |
This file contains hidden or 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
const std = @import("std"); | |
const seeder = @import("seeder.zig"); | |
const Xoshiro256 = struct { | |
s: [4]u64, | |
pub fn next(self: *Xoshiro256) u64 { | |
const S = struct { | |
inline fn rotl(data: u64, rot: u6) u64 { |
This file contains hidden or 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
import asyncio | |
from base64 import urlsafe_b64encode | |
from hashlib import sha384 | |
import os | |
import aiofiles | |
from aiohttp.client import ClientSession | |
# Fake user agent to trick the google font api to give us the .woff2 fonts | |
# Retrive one by typing `navigator.userAgent` in the browser's console |
This file contains hidden or 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 <cstdint> | |
#include <string_view> | |
#include <memory> | |
constexpr uint32_t fnv_1a(std::string_view sv) { | |
uint32_t hash = 0x811c9dc5; | |
for (char c : sv) { | |
hash ^= (uint8_t)c; | |
hash *= 0x01000193; | |
} |
This file contains hidden or 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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
char *read_line_malloc(void) { | |
size_t sz = 64; | |
char *buf = malloc(sz); | |
if (!fgets(buf, sz, stdin)) { | |
*buf = '\0'; |
This file contains hidden or 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 <cstdint> | |
#include <cstring> | |
#include <charconv> | |
#include <iostream> | |
template<const int N> | |
struct BigInt { | |
static constexpr size_t digit_count = 9; | |
static constexpr uint32_t base = 1000000000; | |
uint32_t limbs[N]; |
This file contains hidden or 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 <stdlib.h> | |
#include <stdint.h> | |
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) | |
typedef enum { | |
SIDE_LEFT = 0, | |
SIDE_RIGHT, | |
SIDE_COUNT, | |
} AVL_Side; |
This file contains hidden or 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
template<class> | |
class Function {}; | |
template<class R, class ...Args> | |
class Function<R(Args...)> { | |
private: | |
template<class F> | |
static R type_erase(const void *fn, Args... args) { | |
return (*(const F*)fn)(args...); | |
} |
This file contains hidden or 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
/* | |
arena.h - Zap's personal approach to arena allocation | |
USAGE | |
This is an STB-style single-header library. | |
#define ARENA_IMPLEMENTATION // (in *one* C file) | |
#include "arena.h" | |
#define ARENA_ALLOC and ARENA_DEALLOC to avoid using malloc/free and create a | |
custom backend for the allocator. |
NewerOlder