Skip to content

Instantly share code, notes, and snippets.

View artivis's full-sized avatar

Jeremie Deray artivis

View GitHub Profile
@artivis
artivis / gui.yaml
Last active May 29, 2020 20:22
lxc profiles #lxc #lxd #linux container #GUI
config:
environment.DISPLAY: :0
raw.idmap: both 1000 1000
description: Enables graphical apps use.
devices:
X0:
path: /tmp/.X11-unix/X0
source: /tmp/.X11-unix/X0
type: disk
mygpu:
@artivis
artivis / crtp.cpp
Created May 20, 2020 23:57
some crtp base class #cpp #c++ #crtp
#include <type_traits>
#include <utility>
template <typename Derived>
struct Crtp {
protected:
inline Derived& derived() & noexcept {
return *static_cast< Derived* >(this);
}
inline const Derived& derived() const & noexcept {
@artivis
artivis / cockpit-temperature-plugin-sys-temp.patch
Last active March 7, 2020 17:02
cockpit-temperature-plugin small fix for RaspberryPi + Ubuntu Server.
From 7e69b28973c4cf5d7580dd3dad9fda8de245f1a7 Mon Sep 17 00:00:00 2001
From: artivis <deray.jeremie@gmail.com>
Date: Sat, 7 Mar 2020 11:53:21 -0500
Subject: [PATCH] fix for raspi+ubuntu18.04
---
temperature.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/temperature.js b/temperature.js
@artivis
artivis / crtp_default_impl.cpp
Last active November 2, 2018 11:58
[c++] CRTP with default impl
#include <iostream>
#include <type_traits>
#define USE_DEFAULT
// 2 different traits to test if a class has the function 'process'
template<typename T>
struct HasProcess
{
@artivis
artivis / debug_example.launch
Last active October 23, 2018 10:27
[ROS] optional debugging in launch file
<launch>
<!-- This only works starting from ROS Kinetic -->
<!-- Allows for passing custom launch-prefix -->
<arg name="launch_prefix" default=""/>
<!-- Launch node through a debugger (valgrind/gdb/rr) -->
<arg name="debugger" default=""/>
<arg name="launch_prefix_switch" value="gdb -ex run --args" if="$(eval debugger=='gdb')" />
@artivis
artivis / gaussian_noise_generator.h
Created May 7, 2018 07:28
Simple Gaussian Noise Generator
template <typename _Scalar = double>
class GaussianNoiseGenerator
{
using Clock = std::chrono::system_clock;
using Scalar = _Scalar;
public:
GaussianNoiseGenerator(const Scalar mean,
const Scalar std)
@artivis
artivis / optional_ref.h
Last active May 6, 2018 12:58
[cpp17] work-around std::optional<T&>
#include <functional>
#include <iostream>
#include <optional>
struct Foo
{
void read(const std::optional<std::reference_wrapper<std::string>>& text)
{
if (text)
std::cout << (*text).get() << "\n";
// Example program
#include <iostream>
#include <string>
template<class, typename T, class...> struct has_speak_m_impl : std::false_type {};
template<typename T, class... Args> struct has_speak_m_impl<decltype( std::declval<T>().speak(std::declval<Args...>()) ), T> : std::true_type {};
template<typename T, class... Args> struct has_speak_m : has_speak_m_impl<void, T, Args...> {};
template <typename Derived>
struct BaseInterface
@artivis
artivis / CmakeLists.txt
Created January 15, 2018 16:22
Latex + Cmake
cmake_minimum_required(VERSION 2.8.4)
project(my_latex_report NONE)
include(UseLatex.cmake)
UseLatex()
add_latex_document(my_latex_report.tex
INPUTS Introduction.tex
BIBFILES references.bib
@artivis
artivis / eigen_checks.h
Last active May 8, 2018 09:02
some macro for assert Eigen types dimension
#ifndef _EIGEN_CHECKS_H_
#define _EIGEN_CHECKS_H_
/**
* @note static_cast<int> to avoid -Wno-enum-compare
*/
//////////////////////
/// Static Asserts ///
//////////////////////