Skip to content

Instantly share code, notes, and snippets.

View BlackDex's full-sized avatar

Mathijs van Veluw BlackDex

View GitHub Profile
@BlackDex
BlackDex / Dockerfile.j2.md
Last active June 19, 2020 07:45
Dockerfile to generate systemd (/sbin/init) capable image for ansible molecule (Debian, Ubuntu, RHEL, CentOS, Fedora, OpenSUSE)
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

{% if item.env is defined %}
{% for var, value in item.env.items() %}
{% if value %}
@BlackDex
BlackDex / cname-cloaking-nextdns-updater.sh
Last active October 22, 2023 11:53
PiHole CNAME cloacking updater using NextDNS blocklist
#!/usr/bin/env bash
# https://github.com/nextdns/cname-cloaking-blocklist
# Add this script to /etc/cron.weekly and make it executable
file=/tmp/pihole-nextdns.$$
Cleanup() {
rm -f $file
}
trap Cleanup EXIT
@BlackDex
BlackDex / termbin-encrypted-data.md
Created February 25, 2020 14:25 — forked from schmich/termbin-encrypted-data.md
Sharing encrypted data via termbin.com with only netcat and OpenSSL

Single file

Source

  • cat /foo/bar/file.txt | openssl enc -aes-256-cbc -base64 | nc termbin.com 9999
  • Enter password twice (quickly), note termbin.com URL

Destination

  • curl -s http://termbin.com/{id} | openssl enc -aes-256-cbc -base64 -d > file.txt
That’s one of the real strengths of Docker: the ability to go back to a previous commit. The secret is simply to docker tag the image you want.
Here’s an example. In this example, I first installed ping, then committed, then installed curl, and committed that. Then I rolled back the image to contain only ping:
$ docker history imagename
IMAGE CREATED CREATED BY SIZE
f770fc671f11 12 seconds ago apt-get install -y curl 21.3 MB
28445c70c2b3 39 seconds ago apt-get install ping 11.57 MB
8dbd9e392a96 7 months ago 131.5 MB
@BlackDex
BlackDex / show_ssl_expire
Last active October 17, 2019 09:29 — forked from bmatthewshea/show_ssl_expire
Retrieve/Check SSL certificate expiration date(s)
#!/bin/bash
# By B Shea Dec2018
# https://www.holylinux.net
# Test for OpenSSL - if not installed stop here.
if ! [[ -x $(which openssl) ]]; then
printf "\nOpenSSL not found or not executable.\nPlease install OpenSSL before proceeding.\n\n"
exit 1
fi
@BlackDex
BlackDex / davmail_tray-icon_gnome-shell.md
Last active April 29, 2021 20:13
Have DavMail as a Tray Icon in Gnome-Shell

Have DavMail as a Tray Icon in Gnome-Shell

DavMail is a java application which could use swt for a tray-icon, which has worked fine since somewhere during and before Ubuntu 16.04 with some tweaks.
But it does not work anymore in Gnome-Shell environments. This can be mitigated via some small adjustments and installing a Gnome-Shell Extension.

Install gnome-shell extension

First install the following gnome-shell extension Minimize to Tray.

Change davmail.desktop file

@BlackDex
BlackDex / jq-cheetsheet.md
Created August 15, 2019 15:12 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@BlackDex
BlackDex / mount_qcow2.md
Created July 31, 2019 09:37 — forked from shamil/mount_qcow2.md
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8
@BlackDex
BlackDex / ratelimit.nginxconf
Created January 30, 2019 23:28 — forked from ipmb/ratelimit.nginxconf
Nginx reverse proxy with rate limiting
upstream myapp {
server 127.0.0.1:8081;
}
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
server {
listen 443 ssl spdy;
server_name _;