Skip to content

Instantly share code, notes, and snippets.

View AsyncRaiiExample.cpp
#include <atomic>
#include <future>
#include <iostream>
class AsyncRaiiExample
{
public:
AsyncRaiiExample() : mStopRequired(false)
{
View MyCameraCalibComputer.cpp
#include <future>
class MyThreadedCameraCalibComputer
{
public:
struct GuiCalibInfo
{
cv::Mat mImage;
std::string result;
std::string userInstruction;
@pthom
pthom / literate_programming.md
Last active Aug 1, 2020
literate_programming_editor
View literate_programming.md

I sometimes dream of a source code editor that would allow inline diagrams and nicele rendered documentation and or equations. This could apply to any language that has support for multiline comments.

For example, a code like this, (where md stands for markdown)

/*md
Square value of *any* type
@pthom
pthom / instructions.md
Last active May 13, 2020
vcpkg / opencv4: instructions to test the build on android
View instructions.md

These instructions were tested on a vanilla linux installation.

  1. Download Android ndk
mkdir ~/Android
cd ~/Android
wget https://dl.google.com/android/repository/android-ndk-r21b-linux-x86_64.zip
unzip android-ndk-r21b-linux-x86_64.zip
# edit the path below if needed
@pthom
pthom / cpp_repl_type.cpp
Last active Feb 15, 2019
REPL in C++: display readable types and variable contents.
View cpp_repl_type.cpp
// REPL in C++: display readable types and
// variable contents.
// This demo uses cling, a fully compliant C++14 REPL,
// It also uses based on CleanType (a C++ type introspection
// library)
#include <cleantype/cleantype.hpp>
View opencv_pybind_converter.h
#pragma once
#include <pybind11/numpy.h>
#include <opencv2/core/core.hpp>
#include <stdexcept>
#include <iostream>
// Adapted from
// https://github.com/pybind/pybind11/issues/538#issuecomment-273981569
namespace pybind11 { namespace detail {
View overlay_alpha_image_precise.py
import numpy as np
import cv2
def overlay_alpha_image_lazy(background_rgb, overlay_rgba, alpha):
# cf https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending
# If the destination background is opaque, then
# out_rgb = overlay_rgb * overlay_alpha + background_rgb * (1 - overlay_alpha)
overlay_alpha = overlay_rgba[: , : , 3].astype(np.float) / 255. * alpha
overlay_alpha_3 = np.dstack((overlay_alpha, overlay_alpha, overlay_alpha))
overlay_rgb = overlay_rgba[: , : , : 3].astype(np.float)
@pthom
pthom / lambda_named_params.cpp
Last active Aug 26, 2017
Variations around named function parameters in C++ using lambdas
View lambda_named_params.cpp
// This code explores some variations around the lambda proposition in the following article by Marco Arena
// https://marcoarena.wordpress.com/2014/12/16/bring-named-parameters-in-modern-cpp/
#include <iostream>
#include <string>
//Version 1 (without macros)
// Will be called like this :
//
@pthom
pthom / CLion_Ninja.md
Last active Dec 21, 2020 — forked from nevkontakte/CLion_Ninja.md
Ninja support for CLion IDE
View CLion_Ninja.md

Ninja support for CLion IDE

This script enables Ninja-powered builds in CLion IDE by wrapping around CMake, which it uses. See my blog post for details.

Disclaimer

This script is provided AS IS with no guarantees given or responsibilities taken by the author. This script relies on undocumented features of CLion IDE and may lead to instability of build and/or IDE. Use it on your own risk under WTFPL terms.

View index.html
<!DOCTYPE HTML>
<html>
<head>
<meta name="description" content="Test webkit Table">
<link rel="stylesheet" href="http://cdn.webix.com/edge/webix.css" type="text/css">
<script src="http://cdn.webix.com/edge/webix.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript" charset="utf-8">
/* place for UI configuration */