Skip to content

Instantly share code, notes, and snippets.

@mattbierner
mattbierner / sample.md
Created March 13, 2016 21:38
RNN Urban Dictionary Sample
@mattbierner
mattbierner / main.cpp
Last active January 14, 2023 17:12
C++ std::tuple cdr, car, cons
#include "tuple_ops.h"
template<typename T>
void print_tuple(const T& x)
{
std::cout << "Head:" << Car(x) << " Remaining:" << std::tuple_size<T>::value - 1 << std::endl;
}
int main(int argc, const char* argv[])
{
@mattbierner
mattbierner / gist:6145671
Last active January 14, 2023 17:12
C++ std::tuple map, foldl, and foldr
/*------------------------------------------------------------------------------
Common list operations (map, foldl, foldr) for C++ tuples.
Depends on Cons, Car, and Cdr for tuples from: https://gist.github.com/mattbierner/6145505
------------------------------------------------------------------------------*/
#include "tuple_ops.h"
/* Impl --------------------- */
@mattbierner
mattbierner / life_comonadic.cpp
Created November 3, 2014 00:25
c++ Compile Time Comonaic Life
/**
* Conway's game of life implemented in C++ templates at compile time using Comonads.
*
* Logic based on: http://blog.emillon.org/posts/2012-10-18-comonadic-life.html
*/
#include <iostream>
/// Identity functor
template <typename X>
struct id {
@mattbierner
mattbierner / gist:090a80d25259b6472827
Last active March 5, 2021 13:55
Compile Time Brainfuck C++ Metaprogramming Evaluator
#include <utility>
using iochar = char;
using memval = unsigned char;
/* BF Memory Cell */
template <memval val = 0>
struct Cell {
enum { value = val };
<?xml version="1.0" encoding="UTF-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<authoring_tool>SceneKit Collada Exporter v1.0</authoring_tool>
</contributor>
<created>2019-07-04T04:45:25Z</created>
<modified>2019-07-04T04:45:25Z</modified>
<unit meter="1.000000"/>
<up_axis>Y_UP</up_axis>
@mattbierner
mattbierner / image.html
Last active December 5, 2018 15:00
Automatic migration of ghost images to Jekyll
<figure class="image">
{% capture image_src %}{% if include.file %}/content/{{ page.path | remove_first:'_posts/' | split:'.' | first }}/{{ include.file }}{% else %}{{ include.url }}{% endif %}{% endcapture %}
<a href="{{ image_src }}">
<img src="{{ image_src }}" alt="{{ include.description }}" />
</a>
{% if include.description %}
<figcaption>{{ include.description }}</figcaption>
{% endif %}
</figure>
@mattbierner
mattbierner / integral_constant_literal.cpp
Last active November 22, 2018 14:41
std::integral_constant user defined literal
/**
Defines a user defined literal that can create std::integral_constant values.
http://blog.mattbierner.com/stupid-template-tricks-stdintegral_constant-user-defined-literal/
*/
constexpr unsigned digit_to_value(char c) {
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
else if (c >= 'A' && c <= 'F') return c - 'A' + 10;
else if (c >= '0' && c <= '9') return c - '0';
else throw std::invalid_argument("c");
@mattbierner
mattbierner / gist:d6d989bf26a7e54e7135
Last active November 15, 2017 09:34
C++ Template Meta Programming Linear Feedback Shift Register
#include <iostream>
#include <utility>
/**
Ordered collection of bits.
*/
template <bool... values>
using bitset = std::integer_sequence<bool, values...>;
/**
hessider
- Operation Space
- Povelan
- Blinding In The Moon
- Falling Along #067
- Sky Aisle
- Rhythm 10 Prophemie
- Laisure Bullaltoware
- Lonely Hults Ocean Can't Forest
- Anarchist