Skip to content

Instantly share code, notes, and snippets.

View derjohn's full-sized avatar

derjohn derjohn

View GitHub Profile
@derjohn
derjohn / keybase.md
Created May 1, 2017 08:48
keybase.md

Keybase proof

I hereby claim:

  • I am derjohn on github.
  • I am derjohn (https://keybase.io/derjohn) on keybase.
  • I have a public key whose fingerprint is EE7A 1F2F 1111 1299 A921 0830 79AA 0D82 0805 1F6C

To claim this, I am signing this object:

@derjohn
derjohn / android_backup_restore.sh
Last active May 30, 2019 16:04 — forked from silvae86/android_backup_restore.sh
Backup and restore Android partitions to SD Card
#!/bin/sh
#open adb shell
adb shell
#listing partitions (general command for Android devices)
#ls -l /dev/block/platform/<block_device_name>/by-name/
#for the ZTE Axon7
ls -l /dev/block/platform/soc/624000.ufshc/by-name/

Keybase proof

I hereby claim:

  • I am derjohn on github.
  • I am derjohn (https://keybase.io/derjohn) on keybase.
  • I have a public key whose fingerprint is EE7A 1F2F 1111 1299 A921 0830 79AA 0D82 0805 1F6C

To claim this, I am signing this object:

@derjohn
derjohn / rdp-connect.sh
Created September 8, 2020 09:54
rdp connect script with smart resizing and scaling (using xfreerdp v2 !)
#!/bin/sh
# Example usage RDPHOST=127.0.0.1 RDPPASS=foobar RDPUSER=admin rdp-connect.sh
if ! xfreerdp --version | grep -q 'version 2\.'; then echo "Please apt install freerdp2-x11"; exit 1; fi
RDPHOST=${1:-""}
RDPPASS=${RDPPASS:-""}
RDPUSER=${RDPUSER:-""}
RDPTITLE=${RDPTITLE:-"${RDPHOST}"}
RDPDRIVE=${RDPDRIVE:-'/tmp/'}
@derjohn
derjohn / create-memorylimited-slice
Created September 24, 2020 08:25
It creates a systemd "slice" with a memory limit. Ideal if e.g. firefox or chromium eat up all your memory and block your whole desktop. The slice will be OOM killed by systemd / cgroups, if it runs of bounds.
#!/bin/bash
# It creates a systemd "slice" with a memory limit. Ideal if e.g. firefox or chromium eat up all your memory and block your whole desktop.
# The slice will be OOM killed by systemd / cgroups, if it runs of bounds.
# usage: ./create-memorylimited-slice /path/to/your/binary
SLICEPATH=${1:-'/usr/bin/firefox'}
SLICENAME=$(basename ${SLICEPATH})
## Create system-wide scripts
cat <<EOF | sudo tee /usr/local/bin/${SLICENAME}-slice > /dev/null
@derjohn
derjohn / Setup-e-mail-to-fax-with-dusnet
Created September 24, 2020 10:56
E-Mail to Fax Gateway with a DUS.net account
# Goal: Send an PDF Attachment to an catchall E-Mail Adresss with the fax number LHS
# like +49123456778@myfax.example.com and have it processes as a Fax message.
# You need: an dus.net account and the crypto token for the subject-line-auth
# an catchall e-mail account like *@myfax.example.com with an own homedirectory
# This script will rewrite the e-mail target and subject and forward it to DUS.net.
1) Create a <USERHOME>/.procmailrc
LOGFILE=procmail-for-fax.log
VERBOSE=YES

Howto manage a tomcat8/9 instance as a user (non-root)

Install tomcat8/9

Figure out yourself, probably use your distros package manager Create a user e.g. tomcat9user

Create an Instance

sudo -iu tomcat9user
tomcat9-instance-create -p 8081 -c 8006 ~/tomcat9specialservice-instance
#!/bin/sh
sudo apt-get -y remove docker docker-engine docker.io runc
sudo apt-get update
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
@derjohn
derjohn / gpu-tune.sh
Created September 20, 2021 08:59
gpu custom settings helper script for ROC-smi-rocm ROCm Radeon on Compute
#!/bin/bash
# usage: ./gpu-tune.sh '1 3 5' # runs GPU Settings in card 1,3 and 5
# Settings must be coded into the script (no external config yet).
# But this still handy, if you work on just one card
GPUS=${1:-'1 2 3 4 5'}
ROCMDIR=./ROC-smi-rocm-3.9.0
function tune() {
DEV=$1
#!/bin/sh
# Virtualmin Package not working on older debian ?
# They packed the .deb with "xz" fragments inside, older debian debs don't understand deb + xz
# Repack them als gzip
# Example webmin-virtual-server_7.2.gpl-1_all.deb for debian wheezy
ar x webmin-virtual-server_7.2.gpl-1_all.deb
xz -d control.tar.xz
xz -d data.tar.xz
gzip control.tar