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 / 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 / fast.c++
Last active December 16, 2015 02:39
“I want it as fast as possible”
int main(){}
@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;
@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 / 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/>.
@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 / halcyon.md
Last active October 10, 2015 14:58
Halcyon

This document is an informal collection of design ideas for the Halcyon programming language. This document in in permanent draft status; do not take anything you read here as final. There are no plans to ever actually implement the ideas here; they're listed only for future reference.

Wants

  • Static, strong typing

    Type errors at runtime are stupid.

  • Type inference