Skip to content

Instantly share code, notes, and snippets.

View drmalex07's full-sized avatar

MichailAlexakis drmalex07

  • IMIS "Athena" Research Center
  • Athens, Greece
View GitHub Profile
drmalex07 / resolvectl-add-routing-domain.bash
Created May 15, 2024 16:29
An up hook for openvpn clients to configure routing for private DNS domains. #openvpn #resolvectl
set -u -e
# On systems with `systemd-resolved.service`, this script can be used as an "up" hook in client ovpn file.
# For example:
# ...
# script-security 2
# up /etc/openvpn/add-routing-domain.bash
# ...
drmalex07 /
Last active June 28, 2023 08:02
Setup a K3s cluster. #k3s #k8s

README - Setup K3s cluster (multiple nodes)

Download k3s binary on all machines at /usr/local/bin (see instructions at

1. Setup server (controlplane)

Prepare env file for the service unit (/etc/default/k3s). For example:

drmalex07 /
Created January 14, 2023 22:00
An example with DelayQueue in Java. #DelayQueue #java
import java.time.Duration;
import java.util.concurrent.Callable;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class DelayQueueExample
drmalex07 /
Last active April 25, 2024 18:18
Checkout subtree of a Git repository. #git #git-sparse-checkout #git-checkout

README - Checkout subtree of a Git subdirectory

See also:

Clone with a specific history depth (--depth) and start at the root of the repository (--sparse). You can also filter-out BLOB files. For example:

git clone --sparse --depth 1 --filter blob:none --branch master

Change directory into the newly-cloned repository and enable sparse-checkout mechanism (to fetch parts of the subtree in steps of increasing depth)

drmalex07 /
Last active February 14, 2023 12:36
Run flyway migration from a Docker container. #flyway

README - Run a Flyway migration from a Docker container

See also:

Prepare basic Flyway configuration (no sensitive data inside), say at config/flyway.conf:

# vim: set syntax=jproperties:
# See
flyway.schemas = foo
flyway.defaultSchema = foo
drmalex07 / read-line-with-prompt.c
Created March 12, 2021 23:31
Real lines in C without overflowing buffer. #C #fgets #read-line
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const int MAX_LINE_SIZE = 10;
int main(int argc, char **argv){
char line[MAX_LINE_SIZE + 2];
drmalex07 /
Created February 6, 2021 00:52
Mimic escapism Python package in Java. #escapism
import java.util.Objects;
* Mimic escaping logic from Python {@code escapism} package.
public class Escapism
public static final String SAFE_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789";
public static final char ESCAPE_CHAR = '-';
drmalex07 / weighted-graph.hpp
Created November 14, 2020 23:15
A simple weighted graph in C++. #c++ #graph #weighted-graph #minimum-spanning-tree #MST
#include <iostream>
#include <limits>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <stdexcept>
drmalex07 /
Last active April 11, 2021 13:02
Setup nullmailer. #smtp #nullmailer

README - Setup nullmailer

1. Prepare the inventory

An example inventory hosts.yml:

    # ...
drmalex07 /
Created September 30, 2020 11:08
An oneshot systemd service for loading IPVS table. #ipvs #ipvsadm #virtual-servers #linux-virtual-servers #systemd

README - Restore IPVS table (systemd service)

Lets assume our IPVS table is saved under /usr/local/etc/ipvs-table (e.g. as the output of ipvsadm -S).

Create the service file at /etc/systemd/system/restore-ipvs-table.service:

Description=Restore IPVS table from file