Skip to content

Instantly share code, notes, and snippets.

View AlexisTM's full-sized avatar
🤠

Alexis Paques AlexisTM

🤠
View GitHub Profile
@AlexisTM
AlexisTM / disable_middle_click_paste.txt
Last active August 5, 2024 07:52
Middle-click paste disable on Ubuntu
# Gnome, using gnome-tweaks
sudo apt install gnome-tweaks
gnome-tweaks
# Switch the option Middle Click Paste
# Firefox, within `about:config`, change the following configs
middlemouse.contentLoadURL false
middlemouse.paste false
@AlexisTM
AlexisTM / .clangd
Created October 19, 2023 11:59
clangd config, note it has to use \t !
CompileFlags:
CompilationDatabase: /path_to_build_with_compile_database.json
@AlexisTM
AlexisTM / zerotier.md
Created May 13, 2023 08:41
Set zerotier network as private to allow local network access (Windows 10/11 Pro)

Workaround:

To check public/private setting

Get-NetConnectionProfile | Where-Object "InterfaceAlias" -like "Zero*"

To set all ZeroTier networks to Private

Get-NetConnectionProfile | Where-Object "InterfaceAlias" -like "Zero*" | Set-NetConnectionProfile -NetworkCategory Private
@AlexisTM
AlexisTM / concat.cpp
Last active February 28, 2023 14:33
Variadic template string and string_view concat for C++17
#include <string>
// concat(a,b,c) is the equivalent to std::string(a) + std::string(b) + std::string(c)
template<class T>
std::string concat(T t) {
return std::string(t);
}
template<class T, class... Types>
std::string concat(T t, Types&&... others) {
@AlexisTM
AlexisTM / update_alternative_clang.sh
Created December 22, 2022 12:40
update_alternative for clang-15
# based on https://gist.github.com/junkdog/70231d6953592cd6f27def59fe19e50d?permalink_comment_id=3780497
function register_clang_version {
local version=$1
local priority=$2
update-alternatives \
--verbose \
--install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-${version} ${priority} \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-${version} \
--slave /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-${version} \
@AlexisTM
AlexisTM / tristate.cpp
Last active July 15, 2022 13:15
C++ Tri-state enum method which is nice to use, but bad to write.
#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 February 17, 2022 10:01
++ Operator one liner
#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 12:11
Print types of variables at runtime c++
#include <type_name.h>
#include <iostream>
class A {
public:
int a = 1;
int b = 2;
int c = 3;
};
@AlexisTM
AlexisTM / magic.h
Last active June 11, 2021 06:13
C/C++ performance magic functions (prevent optimization)
/**
* 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 November 24, 2020 13:53
Merge multiple compile_commands.json
# 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