Skip to content

Instantly share code, notes, and snippets.

@Polkm
Polkm / minal_pico8_raytracer.lua
Last active April 9, 2019 03:23
A minimal implementation of a distance field ray marching in pico 8. Has color dithering and soft shadows.
--math
local function length(x, y, z) return sqrt(x*x + y*y + z*z) end
local function norm(x, y, z) local l = length(x,y,z) return x/l, y/l, z/l end
local function dot(xa, ya, za, xb, yb, zb) return xa*xb + ya*yb + za*zb end
--globals
local ex, ey, ez = 0, 1, -1.5 --camera position
local fov = 90 --camera FOV
local tmin, tmax = .1, 100 --minimum and maximum distance from camera
local maxSteps = 45 --maximum number of steps to take
@paniq
paniq / twistpool.c
Last active August 28, 2019 22:17
Twisting Pool Allocator
/*
Twisting Pool Allocator
=======================
written by Leonard Ritter (leonard.ritter@duangle.com)
This file is in the public domain
I don't know if I was the first one to stumble upon this technique, so
I can't guarantee there's no patent on it, but let's hope there's not,
@sacko87
sacko87 / Base.cpp
Last active December 10, 2023 09:14
Factory Pattern in C++ with templates (using the confusingly recurring template and registry patterns)
#include "Base.h"
Base::Base() :
IsRegistered_(false)
{ }
Base::Base(bool isRegistered) :
IsRegistered_(isRegistered)
{ }
@morgoth
morgoth / deployer.rake
Created January 27, 2012 20:03
Rake task to copy local files to remote server via FTP
# Rake task to copy local files to remote server via FTP
# required credentials.yml file, that contains keys:
# server, username, password
require "net/ftp"
require "yaml"
class FTPClient
attr_reader :remote_path
@noonat
noonat / gist:1649543
Created January 20, 2012 21:02
Rake Quick Reference
# Rake Quick Reference
# by Greg Houston
# http://ghouston.blogspot.com/2008/07/rake-quick-reference.html
# -----------------------------------------------------------------------------
# Running Rake
# -----------------------------------------------------------------------------
# running rake from the command-line:
# rake --help