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
Atrix256 / gist:eb42ceec4ab6826aa1086d1b810ab93c
Created August 14, 2023 17:50
stylized and non realistic rendering resources
• https://minionsart.github.io/tutorials/
• https://www.alanzucconi.com/tutorials/
• https://www.youtube.com/@DanMoranGameDev
• https://catlikecoding.com/unity/tutorials/
• How to get the spider verse look in blender: https://garagefarm.net/blog/recreating-the-spider-verse-look-in-the-blender-node-editor
• GuiltyGearXrd’s art style: The X Factor Between 2D and 3D (GDC) https://www.youtube.com/watch?v=yhGjCzxJV3E
• Genshin Impact: Crafting an Anime-Style open world (GDC) https://www.youtube.com/watch?v=-JFyAdI_rO8
• https://ameye.dev/
• Toon shader using unity: https://roystan.net/articles/toon-shader/
• Mange stylized rendering in VR (SIGGRAPH) https://dl.acm.org/doi/10.1145/3277644.3277768
@o11c
o11c / every-vm-tutorial-you-ever-studied-is-wrong.md
Last active March 26, 2024 02:31
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: https://www.reddit.com/r/ProgrammingLanguages/comments/up206c/stack_machines_for_compilers/i8ikupw/ 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
paniq / slice_hashing.md
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 (it.next()) |entry| {
if (entry) |e| {
@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
@mitchellh
mitchellh / Atlas.zig
Last active March 8, 2024 03:10
Bin-packed texture atlas implementation in Zig. https://en.wikipedia.org/wiki/Texture_atlas
//! Implements a texture atlas (https://en.wikipedia.org/wiki/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: https://github.com/juj/RectangleBinPack
//!
//! Limitations that are easy to fix, but I didn't need them:
//!
@reillyeon
reillyeon / async_function_return.md
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() {
  a();
  await b();
  return c();
}
import smartpy as sp
class SpectrumColors(sp.Contract):
def __init__(self):
self.init(
# 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{
EndOfStream,
Utf8InvalidStartByte,
} || std.fs.File.ReadError || std.fs.File.SeekError || std.mem.Allocator.Error;
pub fn Parser(comptime Value: type, comptime Reader: type) type {
return struct {