Skip to content

Instantly share code, notes, and snippets.

Avatar
🤠

Alexis Paques AlexisTM

🤠
View GitHub Profile
@AlexisTM
AlexisTM / tristate.cpp
Last active Jul 15, 2022
C++ Tri-state enum method which is nice to use, but bad to write.
View tristate.cpp
#include <stdint.h>
#include <stdio.h>
// The processes vision can be running
enum struct Process : uint16_t {
PROCESS_1,
PROCESS_2,
};
enum struct Function : uint16_t {
@AlexisTM
AlexisTM / ++operator.cpp
Created Feb 17, 2022
++ Operator one liner
View ++operator.cpp
#include <iostream>
struct S {
int value = 0;
decltype(auto) operator++(auto... t) {
return ((*this = {value + 1}), ..., S{value - 1 + t});
}
};
@AlexisTM
AlexisTM / test.cpp
Created May 5, 2021
Print types of variables at runtime c++
View test.cpp
#include <type_name.h>
#include <iostream>
class A {
public:
int a = 1;
int b = 2;
int c = 3;
};
@AlexisTM
AlexisTM / magic.h
Last active Jun 11, 2021
C/C++ performance magic functions (prevent optimization)
View magic.h
/**
* Those functions are related to: https://www.youtube.com/watch?v=nXaxk27zwlk&t=2446s
*
* They are used to allow to benchmark functions with -O3 that would otherwise be removed because it is unused.
*
* escape(&object) prevents object to be optimized out
* "This ASM code has some unknowable side effects and possibly stored the pointer globally"
* clobber() tells the compiler some asm might be reading the whole memory
* "This ASM code could probably read/write to all memory" => observe all memory
*/
@AlexisTM
AlexisTM / merge.sh
Created Nov 24, 2020
Merge multiple compile_commands.json
View merge.sh
# This is to be used with catkin_make or catkin_tools if we want to merge compile_commands.txt in a single file to allow some tools to work such as Sourcetail.
sudo apt install jq
jq -s 'map(.[])' PATH_TO_COMPILE_COMMANDS_ROOT/**/compile_commands.json > compile_commands.json
@AlexisTM
AlexisTM / singleton.hpp
Last active Nov 20, 2020
The safe singleton in C++
View singleton.hpp
class Singleton {
public:
static Singleton& get() {
static Singleton instance;
return instance;
}
Singleton(Singleton&&) = delete;
Singleton& operator=(Singleton&&) = delete;
@AlexisTM
AlexisTM / factorial.js
Created May 18, 2020
Very fast algorithm for the a first approximation of a very large factorial (10 decimals)
View factorial.js
function factorial(number) {
let result = 0;
for(let i = number; i > 0; --i) {
result += Math.log10(i);
}
return result;
}
function scientific_factorial(number) {
let fact = factorial(number);
View resume.json
{
"basics": {
"name": "Alexis Paques",
"label": "Head of Robotics",
"picture": "",
"email": "alexis.paques@gmail.com",
"phone": "+32496203699",
"website": "http://alexistm.github.io",
"summary": "I love to experience new technologies, hardware as well as software. I am a conscientious person who works hard to get the right/best result, depending on the deadline. In the meantime, I consider coding as an art. It is personal and it should beautiful to ourselves yet readable for the others. I am autodidact as well as flexible, I can learn new languages with ease.",
"location": {
@AlexisTM
AlexisTM / minimal_gcs.py
Last active May 31, 2019
Minimal heartbeat for a Ground control station in ROS for PX4
View minimal_gcs.py
#!/usr/bin/env python2
"""
Minimal heartbeat for a Ground control station in ROS for PX4.
It enables STATUS_TEXT streams.
Author: AlexisTM
"""
from threading import Thread
import rospy
@AlexisTM
AlexisTM / cookie.js
Created Jan 20, 2019
Parse a cookie
View cookie.js