Skip to content

Instantly share code, notes, and snippets.

View elementbound's full-sized avatar

Tamás Gálffy elementbound

View GitHub Profile
@elementbound
elementbound / property.cpp
Created April 27, 2017 01:01
Properties in C++
template <typename T, typename Class, T(Class::*Getter)(), void(Class::*Setter)(const T&)>
class _property {
typedef _property<T, Class, Getter, Setter> self_type;
typedef T value_type;
typedef Class parent_type;
decltype(Getter) getter_func = Getter;
decltype(Setter) setter_func = Setter;
private:
value_type _value;
@elementbound
elementbound / gml.def
Created April 20, 2017 08:25
GML language definition for CLOC
Game Maker Studio v1.x
filter remove_matches ^\s*//
filter remove_matches ^#
extension gmx
extension gml
3rd_gen_scale 1.5
@elementbound
elementbound / types.py
Created April 13, 2017 12:26
Import only types from ctypes
from ctypes import c_bool, c_char, c_wchar, c_byte
from ctypes import c_ubyte, c_short, c_ushort, c_int
from ctypes import c_uint, c_long, c_ulong, c_longlong
from ctypes import c_ulonglong, c_size_t, c_ssize_t, c_float
from ctypes import c_double, c_longdouble, c_char_p, c_wchar_p
from ctypes import c_void_p
@elementbound
elementbound / randf.cpp
Created September 3, 2015 16:27
A quick snippet for a drop-in random-generator function. Useful when you need a quick'n'dirty way, but you'll probably write something more specific with time
#include <random>
template <unsigned Seed = 0,
typename Real = float,
typename RandomGenerator = std::default_random_engine>
Real randf()
{
static RandomGenerator rng(Seed);
static std::uniform_real_distribution<Real> dst(0.0, 1.0);
@elementbound
elementbound / measure.cpp
Created June 23, 2015 22:39
A quick function to measure time intervals with std::chrono
#include <chrono>
template <typename Duration = std::chrono::milliseconds,
typename Clock = std::chrono::high_resolution_clock>
unsigned measure() {
static bool stage = false;
static auto ms_start = Clock::now();
static auto ms_end = Clock::now();
if(stage == false) {