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
#!/usr/bin/env python | |
# pip install dbus-python pulsectl | |
import signal | |
import sys | |
import pulsectl | |
import dbus | |
def sig_handler(signal, frame): |
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
Setting up a VPN with WireGuard | |
Prerequisites | |
A linux server with | |
- ip forwarding enabled: | |
~> sysctl net/ipv4/ip_forward | |
net.ipv4.ip_forward = 1 | |
- the "tun" kernel module loaded: | |
~> lsmod | grep tun |
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 <cassert> | |
#include <cstdint> | |
#include <iostream> | |
#include <type_traits> | |
template <unsigned arg, unsigned result = 0> | |
constexpr unsigned log2 = log2<(arg >> 1), result + 1>; | |
template <unsigned result> | |
constexpr unsigned log2<1, result> = result; |
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
all: program | |
program: program.cpp | |
g++ -std=c++14 -o program program.cpp -ldl -rdynamic | |
run: program query.cpp | |
./program "`< query.cpp`" | |
.PHONY: clean | |
clean: |
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
#!/usr/bin/env ruby | |
# When passing static libraries to GNU ld, one has to make sure the order is correct or undefined references will occur. | |
# This is due to the linker reading each static library just once. | |
# With "--start-group" and "--end-group" this behaviour can be overridden but using these options is discouraged. | |
# call the linker verbosely and print the correct library order to the shell | |
# ~> gcc prog.c -static -Wl,--verbose -Wl,-\( -llib1 -llib2 -lrest_of_the_libs -Wl,-\) | ./order_deps.rb | |
libs = Array.new |
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
/* | |
When using std::bind, all parameters have to be bound either to a value or to a placeholder. | |
This makes it impossible to use std::bind with variadic functions if you do not know the number | |
of parameters they take in advance. | |
This gist shows how to allow binding the first parameters of variadic functions. | |
The original idea can be found here: http://stackoverflow.com/questions/21192659/variadic-templates-and-stdbind#21193316 | |
*/ | |
#include <experimental/tuple> | |
#include <functional> |
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 <algorithm> | |
#include <experimental/any> | |
#include <array> | |
#include <condition_variable> | |
#include <functional> | |
#include <iostream> | |
#include <iterator> | |
#include <mutex> | |
#include <thread> | |
#include <vector> |
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 <algorithm> | |
#include <array> | |
#include <fstream> | |
#include <numeric> | |
#include <random> | |
using namespace std; | |
// Step 1 - Create a file with 256 MiB of data | |
array<uint64_t, 256 * 1024 * 1024 / sizeof(uint64_t)> data; |
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
using System; | |
using System.Linq; | |
namespace Times { | |
static class Extensions { | |
public static void times(this int t, Action f) { | |
for (int i = 0; i < t; ++i) { | |
f(); | |
} | |
} |
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
// g++ -std=c++14 -o gtkmm-example gtkmm-example.cpp `pkg-config --cflags --libs gtkmm-3.0` | |
#include <memory> | |
#include <gtkmm.h> | |
class MainWindow : public Gtk::ApplicationWindow { | |
public: | |
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder) | |
: Gtk::ApplicationWindow(obj) | |
, builder{builder} |
NewerOlder