Skip to content

Instantly share code, notes, and snippets.

View P0ulpy's full-sized avatar
:shipit:
Focusing

P0ulpy P0ulpy

:shipit:
Focusing
  • Poulpy's Inc
  • France
  • 05:19 (UTC +02:00)
View GitHub Profile
@P0ulpy
P0ulpy / best-gpu.cpp
Last active June 24, 2025 09:11
Trick to tell AMD and Nvidia drivers to use the most powerful GPU instead of a lower-performance (such as integrated) GPU
/* Trick to tell AMD and Nvidia drivers to use the most powerful GPU instead of a lower-performance (such as integrated) GPU
*
* --- On Windows Platforms ---
*
* As discribed at https://docs.nvidia.com/gameworks/content/technologies/desktop/optimus.htm and http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf,
* Nvidia Optimus disables GPU auto-select for the program
* and make the driver use the most powerful GPU instead of a lower-performance GPU (such as integrated ones).
*
* Nvidia Windows drivers look for this exported symbol into the executable to enable Nvidia Optimus.
* ```
@P0ulpy
P0ulpy / is_template_base_of.hpp
Created December 12, 2024 09:57
Metaprograming C++ is_template_base_of
#include <type_traits>
template <template <typename...> class Template>
struct is_template_base_of
{
template <typename T>
static auto test(int) -> std::enable_if_t<std::is_base_of_v<Template<typename T::template_type>, T>, std::true_type>;
static auto test(...) -> std::false_type;
template <typename T>
static constexpr bool value = decltype(test<T>(0))::value;
@P0ulpy
P0ulpy / install.cmake
Created November 7, 2024 14:01
Install with CMake cheatsheet
# Where should files should be installed / delivered ?
set(INSTALL_DEST_DIR delivery)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/${INSTALL_DEST_DIR)
set(CMAKE_INSTALL_BINDIR ${CMAKE_SOURCE_DIR}/${INSTALL_DEST_DIR)
# Print in stdout only newly installed files
set(CMAKE_INSTALL_MESSAGE LAZY)
# Modify as needed to fit what should be installed or not
# TARGET means executable / lib compiled bins
// THIS CODE REQUIRES -std=c++2b FLAG TO WORK PROPERLY
#include <iostream>
#include <format>
#include <algorithm>
#include <numeric>
#include <ranges>
#include <utility>
@P0ulpy
P0ulpy / ressources-prebuild-copy.cmake
Last active October 2, 2024 17:33
Assets/Ressources prebuild copy CMake
set(PROJECT_NAME your_cmake_target)
set(RESSOURCES_FOLDER ressources)
add_custom_command(
TARGET ${PROJECT_NAME}
COMMENT "Copy ressources directory"
PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/${RESSOURCES_FOLDER} $<TARGET_FILE_DIR:${PROJECT_NAME}>/${RESSOURCES_FOLDER}
)
@P0ulpy
P0ulpy / Assertion.hpp
Last active October 2, 2024 09:27
Command parser powered by templates
#pragma once
#include <type_traits>
template<typename T>
struct assert_false : std::false_type {};
template<typename T>
constexpr bool assert_false_v = assert_false<T>::value;
@P0ulpy
P0ulpy / README.md
Created December 11, 2023 12:29
When `cv2.VideoCapture` not working fix rapberry pi camera on opencv (cv2) using lib-camera directly (workaround)

Work around to get camera stream using open-cv on a raspberry pi when no other method is working

Some times you can encounter serious issues using a raspberry pi camera with open-cv specially using cv2.VideoCapture().
I encountered a lot of them without finding and figured out a as "elegant" as possible workaround.

How it work

If you have libcamera-hello working on your raspberry this can be a solution for you.

This project is using the libcamera-vid command to generate an image buffer of the camera and then read it using opencv.

@P0ulpy
P0ulpy / HOW-TO-FIX.md
Created December 11, 2023 10:24
Fix issue when installing a PyQt5 in a venv on a raspberry pi (work around)

Work around to Install a PyQt5 in a venv on a raspberry pi

Sometime installing python package on a raspberry pi can be paintfull, here a workaround how can save you a lot of efforts if you just whant a thing to work

Install PyQt5 on a recalcitrant python venv

If python3 -m pip install PyQt5 doesn't work or stay stucked for some raisons you can try to install it using apt :

sudo apt install python3-pyqt5 qtbase5-dev