This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QtCore> | |
#include <QtDebug> | |
QVariant call(QObject* object, QMetaMethod metaMethod, QVariantList args) | |
{ | |
// Convert the arguments | |
QVariantList converted; | |
// We need enough arguments to perform the conversion. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# updates an environment variable of a running process (needs sudo) | |
# example: sudo export_pid <variable=value> <pid> | |
export_process(){ | |
script=/tmp/.gdb.$2 | |
echo -e "attach $2\ncall putenv (\"$1\")\ndetach\n" > $script | |
gdb -q -batch -x $script &>/dev/null | |
rm $script | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <iostream> | |
#include <initializer_list> | |
#define expand_pack(...) (void) std::initializer_list<int>{((void)(__VA_ARGS__), 0)...}; | |
template <typename... Iter> | |
void increment_all(Iter&... iters) { | |
expand_pack(++iters); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def urldecode: | |
def unhex: | |
if 48 <= . and . <= 57 then . - 48 elif 65 <= . and . <= 70 then . - 55 else . - 87 end; | |
def bytes: | |
def loop($i): | |
if $i >= length then empty else 16 * (.[$i+1] | unhex) + (.[$i+2] | unhex), loop($i+3) end; | |
[loop(0)]; | |
def codepoints: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sample toolchain file for building for Windows from an Ubuntu Linux system. | |
# | |
# Typical usage: | |
# *) install cross compiler: `sudo apt-get install mingw-w64` | |
# *) cd build | |
# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/mingw-w64-x86_64.cmake .. | |
# This is free and unencumbered software released into the public domain. | |
set(CMAKE_SYSTEM_NAME Windows) | |
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <class T> | |
constexpr std::string_view type_name() { | |
#ifdef __clang__ | |
std::string_view p = __PRETTY_FUNCTION__; | |
return std::string_view(p.data() + 34, p.size() - 34 - 1); | |
#elif defined(__GNUC__) | |
std::string_view p = __PRETTY_FUNCTION__; | |
# if __cplusplus < 201402 | |
return std::string_view(p.data() + 36, p.size() - 36 - 1); | |
# else |