Skip to content

Instantly share code, notes, and snippets.

View dolinenkov's full-sized avatar
🐈

Filipp Dolinenkov dolinenkov

🐈
  • Russia, Kaliningrad
View GitHub Profile
@dolinenkov
dolinenkov / refgen.py
Last active July 31, 2024 22:06
An example of the way how undocumented option of MSVC compiler, /d1reportallclasslayout, can be used to generate static reflection information for C++ sources
# an example of the way how undocumented option of MSVC compiler, /d1reportallclasslayout,
# can be used to generate static reflection information for C++ sources
import sys
import re
import subprocess
cl_exe = 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\Hostx64\\x64\\cl.exe'
file = 'test.cc'
@dolinenkov
dolinenkov / build_cmake_package.cmake
Created March 12, 2020 19:19
simple script for building and installing cmake dependencies
if(NOT MAX_BUILD_JOBS)
set(MAX_BUILD_JOBS 15)
endif()
# A simple function for importing a cmake-friendly buildable (and installable!) project
function(build_cmake_package SRC_DIR BIN_DIR PKG_DIR CFG_TYPE CFG_ARGS)
set(_CFG_ARGS -G ${CMAKE_GENERATOR})
if(CMAKE_GENERATOR_PLATFORM)
set(_CFG_ARGS ${_CFG_ARGS} -A ${CMAKE_GENERATOR_PLATFORM})
@dolinenkov
dolinenkov / module.cmake
Last active April 11, 2020 07:39
CMake function for adding standard layout modules
# universal function for adding a standard layout module
# usage: add_module({MODULE_NAME} [NO_CONSOLE] [DIR direcory] [TYPE executable|library] [DEPENDS target1 target2 ...])
# NO_CONSOLE (Win32): set entry point to WinMain instead of main()
# TYPE: module type, default is library
# DIR: module base directory
# DEPENDS: list of libraries(another modules) to link with
# DEBUG_DIR: debugger startup directory (Visual Studio only)
function(add_module MODULE_NAME)
if(NOT MODULE_NAME)
message("add_module(): module name not specified")
@dolinenkov
dolinenkov / tuple_get_by_index_and_type.hh
Created July 29, 2020 14:46
C++ templates - get element by tuple index and type
#include <cstddef>
#include <type_traits>
#include <tuple>
#include <iostream>
namespace tuple_utils {
template<typename ElementType, const size_t TypeOrdinal, size_t MatchCounter, size_t OverallCounter, typename Tuple>
ElementType & get_by_index_and_type(Tuple && tuple) {
@dolinenkov
dolinenkov / statistics.h
Created October 2, 2020 21:19
Scalable value statistics wrapper
#pragma once
#include <algorithm>
/*
* Convenient and scalable value statistics wrapper
*/
template<typename T>
struct Statistics
{
@dolinenkov
dolinenkov / sun8i-h3-tft35a-ili9486-xpt2064.dts
Last active December 29, 2022 21:48
TFT35a (ILI9486/XPT2046) device tree overlay for Orange Pi Zero
/*
* Device Tree overlay for Waveshare 3.5inch TFT LCD and Orange Pi Zero
* This dts is a compilation of two different dts files:
* 1. olehs' dts for ili9486/xpt2046 and Orange Pi PC:
* https://gist.github.com/olehs/1cd3e5ddf45066380df68a70d6f8462a
* 2. Viroid's dts set for ili9341/xpt2046 and Orange Pi Zero:
https://4pda.to/forum/index.php?s=&showtopic=782242&view=findpost&p=112401076
* The dts was tested at Orange Pi Zero LTS
* uname -a:
* `Linux opi-fbg5 5.15.48-sunxi #22.05.3 SMP Wed Jun 22 07:35:10 UTC 2022 armv7l GNU/Linux`