Skip to content

Instantly share code, notes, and snippets.

@seece
seece / dod.md
Created September 13, 2020 22:24
Data-Oriented Design Book Review

Data-Oriented Design Book Review

Pekka Väänänen, Sep 14 2020

59b4f66b3c27439a8dd629ade17d65f8

Data-Oriented Design (2018) by Richard Fabian

Computers keep getting faster but the future ain't what it used to be. Instead of higher clock rates we get deeper pipelines, higher latencies, more cores. Programming these systems requires paying attention to how we structure and access our data. In Data-Oriented Design Richard Fabian—who has worked at Frontier Developments, Rockstar Games, and Team17—presents us an approach to reason about these issues from a C++ game developer's perspective.

Data-oriented design is about caches and decoupling meaning from data. The former implies laying out your data so that they're compact and predictably accessed. The latter means exposing the raw transforms from one sequence of bits to another. For example, finding the pla

@seece
seece / LAAMATUT.TXT
Created May 26, 2016 18:40
Laaman tie DJGPP-peliohjelmointiin versio 2.10. By Jokke / BAD KARMA
▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄
█▓▒░ ░█ █▓▒░ ░▒▓▒█ █▒░ ░▒▓▒░ █ █░ ░▒▓▒░█ █▓▒░ ░▒▓█ █ ░▒▓▒░ ░▒█
█▒░ ░▒█ █▒░ ░▒▓▒░█ █░ ░▒▓▒░ ░█ █ ░▒▓▒░ █ █▒░ ░▒▓▒█ █░▒▓▒░ ░▒▓█
█░ ░▒▓█ █▒░ ░▒▓▒░ ░█ █░ ░▒▓▒░ ░▒▓█ █░▒▓▒░ ░▒█▒░ ░▒▓▒░█ █▒▓▒░ ░▒▓▒█
█ ░▒▓▒█ █░ ░▒▓▒░ ░▒█ █ ░▒▓▒░ ░▒▓▒█ █▒▓▒░ ░▒▓▒░ ░▒▓▒░ █ █▒▓▒░ ░▒▓▒░ █
█░▒▓▒░█ █ ░▒▓██ ░▒▓█ █░▒▓▒░██▒▓▒░█ █▓▒░ ░▒▓▒░ ░▒▓▒░ ░█ █▓▒░ ░██▒░ ░█
█▒▓▒░ █ █░▒▓▒██░▒▓▒█ █▒▓▒░ ██▓▒░ ░██▒░ ░▒█▒░ ░▒█▒░ ░▒█ █▒░ ░▒██░ ░▒█
█▓▒░ ░█ █░▒▓▒░██▒▓▒░ █▒▓▒░ ░██▒░ ░▒██░ ░▒▓█░ ░▒▓█░ ░▒▓█ █░ ░▒▓██ ░▒▓█
█▒░ ░▒█▄▄▄█▒▓▒░ ░▒▓▒░ ░█▓▒░ ░▒▓▒░ ░▒▓██ ░▒▓▒█ ░▒▓▒█ ░▒▓▒██░ ░▒▓▒░ ░▒▓▒░█
█░ ░▒▓▒░ ░▒▓▒░ ░▒▓▒░ ░▒▓▒░ ░▒▓▒░ ░▒▓▒░ ░▒▓▒░██▒▓▒██░▒▓▒░██ ░▒▓▒░ ░▒▓▒░ █
@seece
seece / mikroblog.bat
Last active January 25, 2023 02:15
This batch script creates an RSS 2.0 XML-file called posts.xml in the current directory, and prompts the user for a message. The message is added to the XML file as a news-feed item. When placed in a Dropbox public folder it can act as a minimal blogging platform, since the feed file can be read with a standard RSS reader application.
@echo OFF
setlocal EnableDelayedExpansion
set "xml_template=^^<?xml version="1.0" encoding="windows-1252"?^^>^^<rss version="2.0"^^>^^<channel^^>^^<title^^>microblog title^^</title^^>^^<description^^>My mikroblog of excellence!^^</description^^>^^</channel^^>^^</rss^^>"
set post_file=posts.xml
if exist %post_file% (
echo Post database %post_file% found.
) else (
@seece
seece / extending csv.md
Last active November 13, 2022 01:07
A Straightforward Way To Extend CSV With Metadata

A Straightforward Way To Extend CSV With Metadata

Pekka Väänänen, Aug 19 2021.

This proposal is a response to It's Time to Retire the CSV by Alex Rasmussen and the discussion on lobste.rs. Don't take it too seriously.

CSV files (comma-separated values) are great but sometimes difficult to parse because everybody seems to have a slightly different idea what CSV means. The obvious solution is to transmit some metadata that tells what to expect but where do you put it? Well, how about a ZIP archive?

An archive with two files. The first file, say format.txt, has the metadata inside and the second one is the original CSV file unchanged. This is still readable by non-technical users because ZIP files are natively supported by both Windows and macOS. People can double click on them like a directory and then double click again on the CSV to open it up in Excel.

@seece
seece / do.bat
Created October 27, 2015 19:55
ffmpeg and imagemagick - split video to frames and back
rem see https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/image_sequence
ffmpeg -i "video.mp4" -vf -fps=14.985015 captures\out%04d.png
REM scale the frames and quantize to 24 color palette
for %%f in (%1\*.png) do ( E:\tools\imagemagick\convert.exe "%%f" -resize x144 -unsharp 0x1 -crop 160x144+48+0 -dither None -colors 24 -scale 300%% "%2\%%~nf.png" )
ffmpeg -framerate 14.985015 -i scaled\out%04d.png -crf 18 video.mp4
@seece
seece / triangle.py
Last active March 15, 2022 14:31
NumPy triangle rasterizer
import numpy as np
import matplotlib.pyplot as plt
from numpy import array
width = 100
height = 80
# The triangle
d = np.array([ [ [0.9, 0.5], [0.5, 0.8], [0.1, 0.15] ] ])
@seece
seece / pytorchraster.py
Last active March 15, 2022 14:31
A dumb triangle rasterizer with PyTorch.
import numpy as np
import matplotlib.pyplot as plt
from numpy import array
import torch
from torch import Tensor
"""
A dumb triangle rasterizer with PyTorch.
It evaluates the barycentrics for all image pixels for each triangle
and then picks the "colors" (just barycentrics again) for each pixel
@seece
seece / ConeTraceAnalytic.txt
Created November 6, 2021 12:39 — forked from sebbbi/ConeTraceAnalytic.txt
Cone trace analytic solution
Spherical cap cone analytic solution is a 1d problem, since the cone cap sphere slides along the ray. The intersection point to empty space sphere is always on the ray.
S : radius of cone cap sphere at t=1
r(d) : cone cap sphere radius at distance d
r(d) = d*S
p = distance of current SDF sample
SDF(p) = sdf function result at location p
x = distance after conservative step
@seece
seece / nes_controller.pde
Created January 13, 2016 13:42
How to read NES controller button presses with an Arduino
/* This code is released into the public domain.
* Pekka Väänänen, 2016 */
/*
http://www.mit.edu/~tarvizo/nes-controller.html
+----> Power +5V (white)
|
5 +---------+ 7
| x x o \
@seece
seece / fpaq0.py
Last active April 19, 2020 18:39
An arithmetic coder
"""
A pretty terrible arithmetic coder with a 0th order model.
Based on Matt Mahoney's fpaq0 implementation available at
http://mattmahoney.net/dc/#fpaq0
"""
import sys