Skip to content

Instantly share code, notes, and snippets.

View dargmuesli's full-sized avatar
🎧
https://creal.jonas-thelemann.de/player

Jonas Thelemann dargmuesli

🎧
https://creal.jonas-thelemann.de/player
View GitHub Profile
@dargmuesli
dargmuesli / backup-docker-secrets.sh
Created January 5, 2023 05:01 — forked from kwonghung-YIP/backup-docker-secrets.sh
Shell script for export all secrets defined in docker swarm
#!/bin/bash
service_name="backup-all-secrets"
secret_list=( `docker secret ls --format "{{ .Name }}"` )
cmd="docker service create \
--name $service_name \
--constraint node.hostname==`hostname` "
for secret in "${secret_list[@]}"
@dargmuesli
dargmuesli / localhost-dns.md
Created November 7, 2022 20:12
DNS setup instructions for development .test TLD resolution on localhost.

DNS

Within development of a DargStack, access to the web apps should be routed via the locally resolved domain [project_name].test and its subdomains. Therefore one needs to configure the local DNS resolution to make this address resolvable. This can either be done by simply adding this domain and all subdomains to the operation system's hosts file or by setting up a local DNS server. An advantage of the latter method is that subdomain wildcards can be used and thus not every subdomain needs to be defined separately.

Here is an example configuration for dnsmasq that uses the local DNS server on top of the router's advertised DNS server:

@dargmuesli
dargmuesli / similar-filenames.sh
Created June 21, 2022 12:04
Compare all filenames inside a folder for similarity.
#!/bin/bash
# Exit on errors, use last pipe error code, do not overwrite files, ensure
# variables exist
set -o errexit -o pipefail -o noclobber -o nounset
# allow matching of files by glob directly without find
shopt -s globstar nullglob
# Set color codes for use with echo

Arch setup

Erase

Make sure SSD is not frozen.

  • sudo hdparm -I /dev/sdX | grep frozen

Enable security by setting a user password.

  • sudo hdparm --user-master u --security-set-pass PasSWorD /dev/sdX

Check if it says "enabled".

  • sudo hdparm -I /dev/sdX
@dargmuesli
dargmuesli / 4to3.sh
Last active June 9, 2022 10:44
mp4/mp3 helper script. Convert, extract covers, ...
#!/bin/bash
# Exit on errors, use last pipe error code, do not overwrite files, ensure
# variables exist
set -o errexit -o pipefail -o noclobber -o nounset
# allow matching of files by glob directly without find
shopt -s globstar nullglob
# Set color codes for use with echo
@dargmuesli
dargmuesli / presenter.sh
Last active March 5, 2021 11:08
Replace a keebinding for a Doosl wireless presenter on Linux.
#!/bin/bash
# Use evtest on last "Genius Wireless Mouse" device.
cat >"/etc/udev/hwdb.d/90-custom-presenter.hwdb" <<EOL
evdev:input:b0003v0458p0189*
KEYBOARD_KEY_70051=space
KEYBOARD_KEY_70052=p
EOL
sudo systemd-hwdb update
sudo udevadm trigger
@dargmuesli
dargmuesli / xpct_ed25519
Last active September 9, 2021 04:26
Add ssh keys with expect.
#!/usr/bin/expect -f
spawn ssh-add $env(HOME)/.ssh/id_ed25519
expect "Enter passphrase for $env(HOME)/.ssh/id_ed25519:"
send "$env(SSH_PASSPHRASE)\n"
expect "Identity added: /home/elements/.ssh/id_ed25519*"
@dargmuesli
dargmuesli / csv-url-to-base64.py
Created August 11, 2019 19:32
Converts a VCards with photo urls to VCards with base64 images.
from io import BytesIO
from itertools import tee
import base64
import requests
import vobject
# change this variable!
filename = 'contacts'
@dargmuesli
dargmuesli / pacman-tools
Created April 1, 2019 23:05
Pacman tools.
#!/bin/bash
removeorphans() {
orphans=();
while read -r
do
orphans+=("$REPLY")
done < <(pacman -Qtdq)