Skip to content

Instantly share code, notes, and snippets.

View jm4R's full-sized avatar

Mariusz Jaskółka jm4R

View GitHub Profile
@jm4R
jm4R / benchmark.cpp
Last active September 18, 2023 12:49
Easy benchmark boilerplate that most often works as expected
#include <cstdio>
#include <chrono>
#include <string>
class benchmark
{
using clock = std::chrono::steady_clock;
public:
benchmark(std::string location, unsigned line)
@jm4R
jm4R / generate_to_string.hpp
Last active March 23, 2022 13:16
Generate to_string function for given enum
// workaround for old msvc preprocessor:
// https://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly
#define ETS_EXP(x) x
#define ETS_CASE(e, x) \
case e::x: \
return #x;
#define ETS_FE_0(e)
#define ETS_FE_1(e, x) ETS_CASE(e, x)
@jm4R
jm4R / keys_monitor.hpp
Last active January 13, 2022 09:54
Portable (Linux/X11 and Windows) way to monitor keyboard shortcuts + integration with asio
#pragma once
#include <boost/predef/os.h>
#include <boost/asio/steady_timer.hpp>
#include <chrono>
#include <initializer_list>
#if BOOST_OS_LINUX