Skip to content

Instantly share code, notes, and snippets.


Tom Lankhorst tomlankhorst

View GitHub Profile
tomlankhorst / mqtt-demo.cpp
Created May 11, 2021
MQTT mosquitto demo (with fmt/7.1.3 mosquitto/2.0.10)
View mqtt-demo.cpp
#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>
tomlankhorst / libpqxx_boost_uuid.hpp
Last active Apr 19, 2021
Basic support for `boost::uuids::uuid` in `libpqxx` 7.4
View libpqxx_boost_uuid.hpp
#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.
View decay_optional.hpp
template<typename T>
struct decay_optional {
using type = T;
template<typename T>
struct decay_optional<std::optional<T>> {
using type = T;
tomlankhorst /
Created Oct 31, 2020
Re-bind XHCI driver to make USB devices responsive again after a wakeup.
# See
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 / talker_listener_ros.launch
Last active Jun 3, 2020
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:
View talker_listener_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"/>
tomlankhorst / thanks
Last active Apr 29, 2020
Thanks! Star the current GitHub repository.
View thanks
#!/usr/bin/env python3
import os
import re
import requests
from subprocess import check_output
github_origin_re = r"^(git@github\.com:|https:\/\/\/)([\w\-_]+)\/([\w\-_]+)\.git$"
View apache-cors-site.conf
<VirtualHost *:443>
# Set CORS headers to allow XHR
# Determine if Origin matches the regex
SetEnvIf Origin "http(s)?://(|$" AccessControlAllowOrigin=$0
# Set Access-Control-Allow-Origin if the Origin is allowd
Header always set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header always set Access-Control-Allow-Credentials true
Header always set Access-Control-Allow-Headers "Origin, Authorization, Accept"
View trigger.groovy
def organization = Hudson.instance.getItemByFullName('my_organization')
if (!organization) throw new Exception("No organization by that name")
def jobs = organization.getItems()
jobs.each {
// find the sub-job that's named "master"
master = it.items.find { it.getName() == "master" }
tomlankhorst /
Created Mar 21, 2020
AuthorizedKeysCommand that appends a public list of keys to the user's list.
# Current user
HOME=$(eval echo ~$USER)
# Base keys
cat $HOME/.ssh/authorized_keys
tomlankhorst /
Last active Jul 1, 2022
Instructions for Docker swarm with GPUs