Skip to content

Instantly share code, notes, and snippets.

View sftrabbit's full-sized avatar

Joseph Mansfield sftrabbit

View GitHub Profile
@sftrabbit
sftrabbit / beta_distribution.hpp
Last active February 13, 2024 13:50
A beta distribution random number distribution for C++11. Conforms to the requirements for a random number distribution (§26.5.1.6 [rand.req.dist]) and is therefore compatible with the <random> C++ library header. Implemented in terms of two gamma distributions (std::gamma_distribution): if X and Y are independently distributed Γ(α, θ) and Γ(β, …
#include <iostream>
#include <sstream>
#include <string>
#include <random>
namespace sftrabbit {
template <typename RealType = double>
class beta_distribution
{
@sftrabbit
sftrabbit / reference_binding.cpp
Created January 28, 2014 11:02
C++ Reference Binding
#include <iostream>
#include <string>
std::string modifiable_rvalue() {
return "foo";
}
const std::string const_rvalue() {
return "bar";
}
@sftrabbit
sftrabbit / delim_istream_iterator.hpp
Last active January 9, 2019 13:08
Iterate over a delimited input stream
#include <iterator>
#include <istream>
#include <string>
#include <cassert>
#include <cstddef>
/**
* Iterate over each part of a delimited input stream.
* For example, to split a string into a vector:
*
@sftrabbit
sftrabbit / readme.txt
Created January 13, 2020 14:28
Simple Block Pushing Game (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@sftrabbit
sftrabbit / readme.txt
Created November 11, 2020 23:12
Simple Block Pushing Game (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@sftrabbit
sftrabbit / readme.txt
Created January 24, 2021 10:34
Simple Block Pushing Game (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@sftrabbit
sftrabbit / readme.txt
Created October 10, 2021 11:28
Simple Block Pushing Game (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@sftrabbit
sftrabbit / readme.txt
Created January 2, 2022 20:51
Simple Block Pushing Game (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@sftrabbit
sftrabbit / readme.txt
Created January 2, 2022 20:53
Simple Block Pushing Game (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@sftrabbit
sftrabbit / readme.txt
Created January 2, 2022 20:54
Simple Block Pushing Game (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html