Skip to content

Instantly share code, notes, and snippets.

@cppcooper
cppcooper / has_a.cpp
Created March 15, 2022 06:23
member detection with templates/macro
#include <type_traits>
#define DECLARE_HASA(what) \
template<typename T, typename = int> struct has_##what : std::false_type { };\
template<typename T> struct has_##what<T, decltype((void) T::what, 0)> : std::true_type {};
DECLARE_HASA(when) //declares above statement with 'when' replacing 'what'
@cppcooper
cppcooper / qemu hook.bash
Last active November 28, 2022 04:55
libvirt cpu isolation
#!/bin/bash
# To use, put in the file:
# /etc/libvirt/hooks/qemu
# remember to chmod +x
echo $1 $2
cores=$(grep -c ^processor /proc/cpuinfo)
last_core=$((cores-1))
host_cpuset="0-$last_core"