Skip to content

Instantly share code, notes, and snippets.

View postspectacular's full-sized avatar
Celebrating 24 years of building open source tools

Karsten Schmidt postspectacular

Celebrating 24 years of building open source tools
View GitHub Profile
Atrix256 / gist:eb42ceec4ab6826aa1086d1b810ab93c
Created August 14, 2023 17:50
stylized and non realistic rendering resources
• How to get the spider verse look in blender:
• GuiltyGearXrd’s art style: The X Factor Between 2D and 3D (GDC)
• Genshin Impact: Crafting an Anime-Style open world (GDC)
• Toon shader using unity:
• Mange stylized rendering in VR (SIGGRAPH)
o11c /
Last active July 17, 2024 19:08
Every VM tutorial you ever studied is wrong (and other compiler/interpreter-related knowledge)

Note: this was originally several Reddit posts, chained and linked. But now that Reddit is dying I've finally moved them out. Sorry about the mess.

URL: Summary: stack-based vs register-based in general.

There are a wide variety of machines that can be described as "stack-based" or "register-based", but not all of them are practical. And there are a lot of other decisions that affect that practicality (do variables have names or only address/indexes? fixed-width or variable-width instructions? are you interpreting the bytecode (and if so, are you using machine stack frames?) or turning it into machine code? how many registers are there, and how many are special? how do you represent multiple types of variable? how many scopes are there(various kinds of global, local, member, ...)? how much effort/complexity can you afford to put into your machine? etc.)

  • a pure stack VM can only access the top elemen
paniq /
Last active May 25, 2023 10:19
Hash Integrals: Slice Hashing below O(log n)

Hash Integrals: Slice Hashing below O(log n)

Update: the technique employed here is called a polynomial rolling hash as I have recently learned.

Some notes on how to enable fast computation of hashes of slices of vectors (below complexity O(log n)), as well as hashes of joined vectors.

We start from first principles. To simplify matters, a vector has the same element type as our hash, which stands in for the actual data element we wish to hash.

Each vector v is paired with a secondary summed-hash vector h of which each element i stores hash(v[0..i]) to form a tuple of vectors (v,h). Appending a new element p to v is then performed in O(1) as follows, with a simple auxiliary linear operation:

const std = @import("std");
const fs = std.fs;
const log = std.log;
const os = std.os;
fn walk(dir: fs.Dir) anyerror!void {
var it = dir.iterate();
loop: {
while ( |entry| {
if (entry) |e| {
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
mitchellh / Atlas.zig
Last active March 8, 2024 03:10
Bin-packed texture atlas implementation in Zig.
//! Implements a texture atlas (
//! The implementation is based on "A Thousand Ways to Pack the Bin - A
//! Practical Approach to Two-Dimensional Rectangle Bin Packing" by Jukka
//! Jylänki. This specific implementation is based heavily on
//! Nicolas P. Rougier's freetype-gl project as well as Jukka's C++
//! implementation:
//! Limitations that are easy to fix, but I didn't need them:
reillyeon /
Last active February 22, 2022 16:05
When does an async function return?

When does an async function return?

Someone recently asked me when an async function in JavaScript "returns". This is an interesting question because while a function like f() below has a return statement in it, f() actually returns much earlier than that. To understand how this works, let's take a look at an example function. Here, a() and c() are normal synchronous functions and b() is another asynchronous function.

async function f() {
  await b();
  return c();
import smartpy as sp
class SpectrumColors(sp.Contract):
def __init__(self):
# fixed dimensions of the board
columns = 16,
rows = 16,
# limit to the total number of colors possible
max_colors = 12,
const std = @import("std");
const Allocator = std.mem.Allocator;
pub const Error = error{
} || std.fs.File.ReadError || std.fs.File.SeekError || std.mem.Allocator.Error;
pub fn Parser(comptime Value: type, comptime Reader: type) type {
return struct {