Skip to content

Instantly share code, notes, and snippets.

View rmartinho's full-sized avatar

R. Martinho Fernandes rmartinho

View GitHub Profile
@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/>.
@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 / hate.markdown
Last active July 15, 2020 01:33
I will hate you

Dear C++ library writer,

  1. If your library forces me to use new all over, I will hate you.

  2. If your library has types with bogus values, I will hate you.

  3. If the documentation for your library gets the terminology of its own domain wrong, I will hate you.

  4. If I say "My God, it's full of stars!" when I see the function signatures in your library, I will hate you.

@rmartinho
rmartinho / pbmx-doc.md
Last active October 31, 2019 16:44
PBMX docs draft

PBMX

PBMX is a framework to creating secure and fair games that can be played over mail.

The main concern is supporting games that feature information that is secret, unknown, or unavailable without the need for a trusted third party. Secret information is information known to only a subset of the players; this could be e.g. in a game of poker, the contents of a player's hand. Unknown information is information that no player knows; in a game of poker, the contents of the deck

@rmartinho
rmartinho / gist:9485770
Last active April 9, 2019 01:19
Program that swaps the values of variables x and y, with the usual algorithm that uses a temporary variable in a weird nonexistent language.
temporary_ACC creation_V.
temporary_DAT assignment_V x_ACC.
y_ACC x_DAT assignment_V.
assignment_V temporary_ACC y_DAT.
@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

Keybase proof

I hereby claim:

  • I am rmartinho on github.
  • I am rmf (https://keybase.io/rmf) on keybase.
  • I have a public key ASBIyYm_eGuZT1d7ge401nPRHeGKB2pX7SAcVcyqcm4y2go

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am rmartinho on github.
  • I am rmf (https://keybase.io/rmf) on keybase.
  • I have a public key ASCYKofoBc-K2YaOXeUUED7xdcVf2C3dpJmsdZbT-cMaCAo

To claim this, I am signing this object:

Randall Munroe's Radiation Dose Chart

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

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 / bit_ops.cpp
Created April 24, 2013 22:44 — forked from bananu7/bit_ops.cpp
Bit twiddling tools. I got tired of primitive stuff like & and |
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> {};