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
drmalex07 / Notes-Archive-CKAN-resources.md
Last active November 13, 2019 15:25
Archive resources from CKAN catalogue. #CKAN

Archive resources from CKAN catalogue

1. Replace resource file with symbolic link

A resource file can be archived without breaking the file hierarchy that CKAN builds under /var/lib/files/resources. The actual data for a resource 7896ea0c-504d-401c-818f-065430419695 will be stored as a regular file under a 3-level hierarchy at 789/6ea/0c-504d-401c-818f-065430419695.

For example:

tree resources
...
@drmalex07
drmalex07 / README-setup-keycloak.md
Last active April 21, 2020 10:58
Setup Keycloak. #keycloak

Setup Keycloak (5.0)

This is a checklist of steps to be taken to setup the identity server (in standalone mode). We assume that keycloak is installed under /usr/local/keycloak (so all paths will be relative to this).

1. Add module for PostgreSQL database

Under modules/org/postgresql/main we must place:

  • module.xml: descriptor for the module
  • postgresql-*.jar: the actual JAR for the PostgreSQL JDBC driver
@drmalex07
drmalex07 / README-fail2ban-keycloak.md
Last active November 22, 2025 10:31
Use fail2ban to block brute-force attacks to keycloak server. #keycloak #fail2ban #brute-force-attack

Add regular-expression filter under /etc/fail2ban/filter.d/keycloak.conf:

[INCLUDES]

before = common.conf

[Definition]

_threadName = [a-z][-_0-9a-z]*(\s[a-z][-_0-9a-z]*)*
_userId = (null|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})
@drmalex07
drmalex07 / README-fail2ban-openvpn.md
Created March 3, 2019 13:34
Block unauthorized requests to OpenVPN using fail2ban. #openvpn #fail2ban

Block unauthorized requests to OpenVPN using fail2ban.

The following is based on https://stefan.angrick.me/block-unauthorized-openvpn-logins-using-fail2ban.

1. Create filter confifuration

Add a filter configuration under /etc/fail2ban/filter.d/openvpn.conf. The contents would be something like (regular expressions may need adjustments):

[INCLUDES]
before = common.conf
@drmalex07
drmalex07 / README-minimal-CA.md
Last active October 3, 2024 23:17
Setup a minimal certificate authority. #ca #minimal-ca #certificate #certificate-authority

Setup minimal Certificate Authority (CA)

1. Setup directory

Setup a directory to be used as the root of the certificate authority, e.g /home/user/documents/identity/ca.

First, create the root key/certificate pair root.{key,crt} that will be used to sign client requests. For example:

    openssl genrsa -out root.key 4096
@drmalex07
drmalex07 / README-convert-properties-to-json-using-jq.md
Last active November 5, 2024 14:46
Convert properties to JSON using jq. #properties $json #jq

README

Say we have a properties file at foo.properties.

First, clean-up whitespace and empty lines, store in foo-1.properties:

cat foo.properties | \
    sed 's/[[:space:]]*=[[:space:]]*/=/' | \
    sed 's/[[:space:]]*$//' | \

sed '/^$/d' > foo-1.properties

@drmalex07
drmalex07 / README-gnuplot-examples.md
Last active February 26, 2025 18:57
Some gnuplot examples. #gnuplot

README - gnuplot examples

Non-interactive use

Pass command-line args

To run a gnuplot script non-interactively (possibly passing positional arguments from the command line) use the -c flag of gnuplot. For example:

gnuplot -c plot-something.gnuplot "Measurements on A" measurements.csv
@drmalex07
drmalex07 / README-memory-measurement.md
Last active December 11, 2018 00:45
A quick-n-dirty memory measurement. #proc-meminfo #memory

Take a measurement via /proc/meminfo and pipe it to a parser AWK script to turn it into a data row:

cat /proc/meminfo | parse-meminfo.awk

Maybe append it to a series of measurements (removing the extra header line from each measurement):

cat /proc/meminfo | parse-meminfo.awk | tail -n +2 | tee --append memory-measurements.csv

Plot measurements as time series:

@drmalex07
drmalex07 / README-vagrant-add-disk.md
Last active October 12, 2021 07:01
A Vagrant recipe to attach more hard disk drives to a VM. #vagrant #virtualbox #hard-disk #hdd #storage

README - Add a hard disk (block device) to a vagrant box

Create disk image

Create using the VDI format (will allocate space lazily). For example:

vboxmanage createmedium --filename $PWD/disk-2.vdi --size 1024 --format VDI 

Configure VM

@drmalex07
drmalex07 / README-docker-compose-postgres.md
Last active April 13, 2025 20:03
An example docker-compose recipe. #docker-compose #postgresql

Readme - An example PostgreSQL docker-compose recipe

Prepare init script under /db-init-scripts/. For example, create db-init-scripts/s01-create-test1-database.sh:

#!bin/bash
set -e -u -o pipefail

quote='$q$'
pass=$(cat /secrets/tester1-password)