Skip to content

Instantly share code, notes, and snippets.

Avatar

R. Martinho Fernandes rmartinho

View GitHub Profile
@rmartinho
rmartinho / future.c++
Created Mar 24, 2013
Sample implementation of std::future
View future.c++
#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 Jul 15, 2020
I will hate you
View hate.markdown

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 Oct 31, 2019
PBMX docs draft
View pbmx-doc.md

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 Apr 9, 2019
Program that swaps the values of variables x and y, with the usual algorithm that uses a temporary variable in a weird nonexistent language.
View gist:9485770
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 Apr 9, 2019
Randall Munroe's Radiation Dose Chart
View rad.md

(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
View keybase.md

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:

View keybase.md

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:

View rad.md

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 Apr 24, 2013 — forked from bananu7/bit_ops.cpp
Bit twiddling tools. I got tired of primitive stuff like & and |
View bit_ops.cpp
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 / stack_alloc.h++
Created Apr 17, 2013
Just a sample of what kind of magic I think could make a C++ alloca().
View stack_alloc.h++
// Usage:
// int f(int n) {
// auto buf = stack_alloc<int>(n);
// std::iota(buf.begin(), buf.end());
// return std::sum(buf.begin(), buf.end());
// }
// allocation function
template <typename T>
stack_array_ref<T> stack_alloc(size_t size) __magic_works_like_a_macro_to_use_the_right_frame__;