Skip to content

Instantly share code, notes, and snippets.

Matthieu Garrigues matt-42

Block or report user

Report or block matt-42

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@matt-42
matt-42 / codeofduty_solution.cpp
Created Jun 13, 2011
#codeofduty 2011 c++ solution
View codeofduty_solution.cpp
/*!
**\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 / sfinae_typelist.cc
Created Aug 14, 2011
C++ test on SFINAE and type lists
View sfinae_typelist.cc
#include <cassert>
// Return R
template <typename R, typename A, int (A::*)() const>
struct first
{
typedef R ret;
};
@matt-42
matt-42 / tuple.h
Created Sep 15, 2011
Tuple C++ implementation
View tuple.h
/*!
**@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 / benchmark_strcmp.cc
Created Jun 15, 2012
strcmp string comparison
View benchmark_strcmp.cc
#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 / Transformation
Created Jan 19, 2015
Iod preprocessing
View Transformation
// The preprocessor transforms this file:
#include <iod/symbol.hh>
int main()
{
@test;
}
// Into:
@matt-42
matt-42 / vpp_erode
Created Feb 18, 2015
fast erosion with vpp
View vpp_erode
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 / gist:478390fbad8275e880d2
Created Aug 24, 2015
silicon 0.2 new route syntax
View gist:478390fbad8275e880d2
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 / gist:10ee54fc51cf2264dec0
Created Oct 6, 2015
silicon: manual connection instantiation.
View gist:10ee54fc51cf2264dec0
auto factory = sqlite_connection_factory("database.db");
auto c = factory.instantiate();
@matt-42
matt-42 / json_nested.cc
Created Apr 14, 2016
iod json parsing of nested objects
View json_nested.cc
#include <iostream>
#include <iod/json.hh>
// Run iod_generate_symbols test.cc symbols.hh
#include "symbols.hh"
int main()
{
std::string str = R"({"name": "x", "position": { "x": 10, "y": 11, "z": 12}})";
using namespace s;
@matt-42
matt-42 / iod_reflection.cc
Last active Jun 13, 2016
c++ reflection with iod
View iod_reflection.cc
foreach(o) | [] (const auto& m)
{
std::cout << m.symbol().name() << ":"
<< m.value() << std::end;
};
You can’t perform that action at this time.