Skip to content

Instantly share code, notes, and snippets.

View matt-42's full-sized avatar

Matthieu Garrigues matt-42

View GitHub Profile
@matt-42
matt-42 / tuple.h
Created September 15, 2011 15:05
Tuple C++ implementation
/*!
**@file tuple.h
**@author Matthieu Garrigues <matthieu.garrigues@gmail.com>
**@date Thu Sep 15 17:07:34 2011
**
**@brief C++ tuple implementation. Maximum number of arguments is 6.
** Features:
** - tuple<...>::get<N>(); returns the N'th element of the tuple.
** - Map tuple members to a function call:
** float fun(float a, int b);
@matt-42
matt-42 / gist:10ee54fc51cf2264dec0
Created October 6, 2015 19:36
silicon: manual connection instantiation.
auto factory = sqlite_connection_factory("database.db");
auto c = factory.instantiate();
@matt-42
matt-42 / benchmark_strcmp.cc
Created June 15, 2012 12:42
strcmp string comparison
#include <iostream>
#include <cstring>
double get_time()
{
timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
return double(ts.tv_sec) + double(ts.tv_nsec) / 1000000000.;
}
@matt-42
matt-42 / sfinae_typelist.cc
Created August 14, 2011 15:35
C++ test on SFINAE and type lists
#include <cassert>
// Return R
template <typename R, typename A, int (A::*)() const>
struct first
{
typedef R ret;
};
@matt-42
matt-42 / codeofduty_solution.cpp
Created June 13, 2011 08:44
#codeofduty 2011 c++ solution
/*!
**\file main.cc
**\author Matthieu Garrigues <matthieu.garrigues@googglemail.com>
**\date Sat Jun 11 13:53:44 2011
**
**\brief Solution of Code of Duty 2011
**
**
*/
@matt-42
matt-42 / gist:478390fbad8275e880d2
Created August 24, 2015 15:56
silicon 0.2 new route syntax
GET / _set_person / _id[int()]
* get_parameter(_name = string())
* post_parameter(_city = string()) =
[] (auto p) {
cout << " id = " << p.id
<< " name = " << p.name
<< " city = " << p.city;
}
@matt-42
matt-42 / vpp_erode
Created February 18, 2015 14:33
fast erosion with vpp
template <typename I, typename O>
void erode(const I& img, O& out)
{
auto win = make_array(vint2{-4, 0}, vint2{-3, 0}, vint2{-2, 0}, vint2{-1, 0},
vint2{ 1, 0}, vint2{ 2, 0}, vint2{ 3, 0}, vint2{ 4, 0},
vint2{0, -7}, vint2{0, -6}, vint2{0, -5}, vint2{0, -4}, vint2{0, -3}, vint2{0, -2}, vint2{0, -1},
vint2{0, 1}, vint2{0, 2}, vint2{0, 3}, vint2{0, 4}, vint2{0, 5}, vint2{0, 6}, vint2{0, 7});
auto nbh = const_box_nbh2d<typename I::value_type, 9, 15>(img);
@matt-42
matt-42 / Transformation
Created January 19, 2015 14:26
Iod preprocessing
// The preprocessor transforms this file:
#include <iod/symbol.hh>
int main()
{
@test;
}
// Into: