Skip to content

Instantly share code, notes, and snippets.

/* So how does this work?
I'm using ANSI escape sequences to control the behavior of the terminal while
cat is outputting the text. I deliberately place these control sequences inside
comments so the C++ compiler doesn't try to treat them as code.*/
//
/*The commands in the fake code comment move the cursor to the left edge and
clear out the line, allowing the fake code to take the place of the real code.
And this explanation uses similar commands to wipe itself out too. */
//
#include <cstdio>
@skwerner
skwerner / pmg02.cpp
Created February 22, 2019 20:40
Progressive Multijittered (0, 2) Sequence
#include <iostream>
#include <random>
/* This implements the pseudo-code from http://graphics.pixar.com/library/ProgressiveMultiJitteredSampling/
*/
/* replace with your desired random number generator */
static std::random_device rd;
static std::mt19937 rng(rd());
static std::uniform_real_distribution<> dis(0, 1);
@jappa
jappa / integer_sequence.hpp
Last active February 5, 2023 00:24
A C++11 implementation of std::integer_sequence from C++14
#ifndef ___KOS_UTILITY_INTEGER_SEQUENCE__82DDD139689B8D73C15C6165472A8E14_HPP__
#define ___KOS_UTILITY_INTEGER_SEQUENCE__82DDD139689B8D73C15C6165472A8E14_HPP__
#include <type_traits>
#include <kos/namespaces.hpp>
KOS_BEGIN_HEADER
KOS_BEGIN_NAMESPACE
// A C++11 implementation of std::integer_sequence from C++14
template <typename T, T... N>