Skip to content

Instantly share code, notes, and snippets.

View tomlankhorst's full-sized avatar
🌊

Tom Lankhorst tomlankhorst

🌊
View GitHub Profile
@tomlankhorst
tomlankhorst / talker_listener_ros.launch
Last active June 3, 2020 10:08
Launch ROS nodes in a docker container (roscpp_tutorial/talker_listener). This example uses host networking, but creating a network and setting the ROS_MASTER_URI should work just as well. See: https://github.com/ros/ros_tutorials/tree/melodic-devel/roscpp_tutorials https://hub.docker.com/_/ros/
<launch>
<node launch-prefix="docker run --rm --name listener -v$HOME:$HOME -u$UID --privileged --net=host -eROS_HOME=$ROS_HOME ros:melodic-ros-base-bionic" name="listener" pkg="roscpp_tutorials" type="listener" output="screen"/>
<node launch-prefix="docker run --rm --name talker -v$HOME:$HOME -u$UID --privileged --net=host -eROS_HOME=$ROS_HOME ros:melodic-ros-base-bionic" name="talker" pkg="roscpp_tutorials" type="talker" output="screen"/>
</launch>
@tomlankhorst
tomlankhorst / rebind-usb.sh
Created October 31, 2020 09:24
Re-bind XHCI driver to make USB devices responsive again after a wakeup. https://tomlankhorst.nl/unresponsive-usb-unbind-bind-linux
#!/bin/bash
# See https://tomlankhorst.nl/unresponsive-usb-unbind-bind-linux
DEV=${1:-0000:06:00.3}
echo $DEV | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind
sleep 1
echo $DEV | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind
@tomlankhorst
tomlankhorst / decay_optional.hpp
Created April 14, 2021 07:40
Decay optional type
template<typename T>
struct decay_optional {
using type = T;
};
template<typename T>
struct decay_optional<std::optional<T>> {
using type = T;
};
@tomlankhorst
tomlankhorst / libpqxx_boost_uuid.hpp
Last active April 19, 2021 09:16
Basic support for `boost::uuids::uuid` in `libpqxx` 7.4
#pragma once
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
/**
* This snippet implements basic string conversion support for `boost::uuids::uuid`
* in libpqxx.
*
@tomlankhorst
tomlankhorst / mqtt-demo.cpp
Created May 11, 2021 14:59
MQTT mosquitto demo (with fmt/7.1.3 mosquitto/2.0.10)
#include <iostream>
#include <csignal>
#include <thread>
#include <chrono>
#include <string_view>
#include <fmt/core.h>
#include <fmt/color.h>
#include <mosquitto.h>
#include <openssl/ssl.h>