Skip to content

Instantly share code, notes, and snippets.

View rmartinho's full-sized avatar

R. Martinho Fernandes rmartinho

View GitHub Profile
@rmartinho
rmartinho / rad.md
Last active April 9, 2019 00:37
Randall Munroe's Radiation Dose Chart

(presented in units of time of exposure to background radiation)

You can find the original chart here. I added some other values; additional sources can be found at the bottom.

Description Dose
Sleeping next to someone 7m
Living within 50 miles of a nuclear power plant for a year 13m
Eating one banana 15m
Living within 50 miles of a coal power plant for a year 45m
@rmartinho
rmartinho / game.md
Last active August 29, 2015 14:06
A game of Nomic run by denizens of the Lounge<C++>.

Lounge<Nomic>

Immutable Rules

101. All players must always abide by all the rules then in effect, in the form in which they are then in effect. The rules in the Initial Set are in effect whenever a game begins. The Initial Set consists of Rules 101-116 (immutable) and 201-213 (mutable).

102. Initially rules in the 100's are immutable and rules in the 200's are mutable. Rules subsequently enacted or transmuted (that is, changed from immutable to mutable or vice versa) may be immutable or mutable regardless of their numbers, and rules in the Initial Set may be transmuted regardless of their numbers.

103. A rule-change is any of the following:

@rmartinho
rmartinho / fast.c++
Last active December 16, 2015 02:39
“I want it as fast as possible”
int main(){}
@rmartinho
rmartinho / future.c++
Created March 24, 2013 11:42
Sample implementation of std::future
#include <wheels/concurrency/locker_box.h++>
#include <chrono>
#include <exception>
#include <future>
#include <memory>
#include <mutex>
#include <type_traits>
#include <utility>
@rmartinho
rmartinho / flavoured_strings.cpp
Created March 23, 2013 13:50
Using char_traits to get strong string aliases.
#include <string>
#include <iostream>
namespace dessert {
template <typename Tag>
struct not_quite_the_same_traits : std::char_traits<char> {};
template <typename Tag>
using strong_string_alias = std::basic_string<char, not_quite_the_same_traits<Tag>>;
using vanilla_string = std::string;
@rmartinho
rmartinho / expand.h++
Last active April 3, 2024 06:32
Some lousy simple logger
// Internal Combustion Engine
//
// Written in 2012 by Martinho Fernandes <martinho.fernandes@gmail.com>
//
// To the extent possible under law, the author(s) have dedicated all copyright and related
// and neighboring rights to this software to the public domain worldwide. This software is
// distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
@bananu7
bananu7 / bit_ops.cpp
Created February 15, 2013 20:32
Bit operations from Robot
template <int Size>
struct uint_least : uint_least<Size+1> {};
template <>
struct uint_least<8> : identity<u8> {};
template <>
struct uint_least<16> : identity<u16> {};
template <>
struct uint_least<32> : identity<u32> {};
template <>
struct uint_least<64> : identity<u64> {};
@rmartinho
rmartinho / darray2d.h
Created October 26, 2012 17:05
Two-dimensional array with dimensions determined at runtime
// Two-dimensional array with dimensions determined at runtime
//
// Written in 2012 by Martinho Fernandes
//
// To the extent possible under law, the author(s) have dedicated all copyright and related
// and neighboring rights to this software to the public domain worldwide. This software is
// distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
@rmartinho
rmartinho / sarray2d.h
Created October 26, 2012 17:04
Two-dimensional array with dimensions determined at compile-time
// Two-dimensional array with dimensions determined at compile-time
//
// Written in 2012 by Martinho Fernandes
//
// To the extent possible under law, the author(s) have dedicated all copyright and related
// and neighboring rights to this software to the public domain worldwide. This software is
// distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
@rmartinho
rmartinho / arrays.h
Last active October 12, 2015 02:48
Simple functions for better usage of arrays
// begin() and end() functions for arrays (C++03)
//
// Written in 2012 by Martinho Fernandes
//
// To the extent possible under law, the author(s) have dedicated all copyright and related
// and neighboring rights to this software to the public domain worldwide. This software is
// distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.