Skip to content

Instantly share code, notes, and snippets.

View MrSmith33's full-sized avatar

Andrey Penechko MrSmith33

View GitHub Profile
@kprotty
kprotty / lz4_block.zig
Last active January 2, 2024 11:14
Simple LZ4 block enc/dec in 100 LOC
const assert = @import("std").debug.assert;
fn compressBlock(writer: anytype, src: []const u8) !void {
var table = [_]u32{0} ** 4096; // size is pow2. bump to match more. ideal = (0xffff+1) / sizeof(u32)
var anchor: u32 = 0;
if (src.len > 12) { // LZ4 spec restriction: last match must start 12b before end of block.
var pos: u32 = 0;
while (pos + 4 < src.len - 5) { // LZ4 spec restriction: last 5b are always literal.
const blk: u32 = @bitCast(src[pos..][0..4].*);
@ekzhang
ekzhang / Buildcarte.ipynb
Last active March 29, 2024 16:02
Build Systems à la Carte — Python edition
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Symbol Representation

Field Value
DIP:
Author: Richard (Rikki) Andrew Cattermole (firstname@lastname.co.nz)
Implementation:
Status: Draft

Abstract

Wonder Boy: The Dragon's Trap
-----------------------------
Quick Guide for programmers
Last updated October 2018
Contact: Omar Cornut <XXXXXX
===============================================
INDEX
===============================================
@lleyton
lleyton / translation.md
Last active January 23, 2024 16:53
(ENG) Open Source Business Challenges and Reality, Rui Ueyama

Open Source Business Challenges and Reality

Original Japanese note here.

Original Author: Rui Ueyama (creator of the mold linker)

Translated by @windowsboy111

Minimally edited by @lleyton

Data oriented UI (part 1)

Some time ago I read the @lisyarus' post about his UI library. In his blog post he compares existing UI frameworks, analyses reasons why they don't work to them, and shows how he created his own library to build in-game UI.

His blog post immediately inspired me: how would I build my UI library?

Data Oriented Design vs OOP?

@lithdew
lithdew / lexicographic_hash_map.zig
Created August 31, 2022 11:06
zig: lexicographic hash map
const std = @import("std");
pub fn LexicographicHashMap(comptime V: type, comptime capacity: u32) type {
const shift = @bitSizeOf(u64) - 1 - std.math.log2_int(u64, capacity) + 1;
const overflow = capacity / 10 + (@bitSizeOf(u64) - 1 - shift + 1) << 1;
const num_entries = capacity + overflow;
return struct {
pub const Entry = packed struct {
key: u32 = 0,
@lithdew
lithdew / sparse.zig
Created June 26, 2022 09:26
zig: generational paged sparse set
const std = @import("std");
const sparse = @This();
/// This is an implementation of a paged sparse set that stores the payload in
/// the sparse array.
//
/// A sparse set has a dense and a sparse array. The sparse array is directly
/// indexed by a 64 bit identifier. The sparse element is linked with a dense
/// element, which allows for liveliness checking. The liveliness check itself
@swatson555
swatson555 / compile.ss
Created June 22, 2022 13:13
nanopass compiler for r0 language
#!/usr/bin/env scheme --script
(import (nanopass))
(define unique-var
(let ()
(define count 0)
(lambda (name)
(let ([c count])
(set! count (+ count 1))
#include <bench_path.h>
#include <stdio.h>
#include <stdlib.h>
#include "entt.hpp"
#define MILLION (1000 * 1000)
#define BILLION (1000 * MILLION)
#define ENTITY_COUNT (255)
#define COMPONENT_COUNT (10)