Skip to content

Instantly share code, notes, and snippets.

@mbos
mbos / mailbackup.sh
Created March 4, 2022 07:42
Backup to SFTP script for mailcow
#!/bin/bash
SFTPSOLEUS="-i ~/.ssh/<KEYFILE> <USER>@@s<HOST>:<DIR>"
SFTPRSYNC="-i ~/.ssh/<KEYFILE> <USER>@@s<HOST>:<DIR>"
NOW=$(date +"%m_%d_%Y")
cd /opt/mailcow-dockerized/
docker run --rm -i -v $(docker inspect --format '{{ range .Mounts }}{{ if eq .Destination "/var/vmail" }}{{ .Name }}{{ end }}{{ end }}' $(docker-compose ps -q dovecot-mailcow)):/vmail -v ${PWD}:/backup debian:stretch-slim tar cvfz /backup/backup_vmail.tar.gz /vmail
sftp $SFTPSOLEUS <<< $'put backup_vmail.tar.gz backup_vmail_'"$NOW"'.tar.gz'
sftp $SFTPRSYNC <<< $'put backup_vmail.tar.gz backup_vmail_'"$NOW"'.tar.gz'
@mbos
mbos / get-tel.py
Last active June 12, 2018 10:05
Pythonista script: Parses a text from drafts 5 to look for a Dutch or international telephone number and calls that number
# title: get-tel.py
# Desc: Parses a text from drafts 5 to look for a Dutch or international telephone number and calls that number
from sys import argv, exit
import webbrowser
import re
TEL_REGEX = re.compile(r"(^0(6-?[0-9]{8}$|[0-9]{2}-?[0-9]{7}$)|^\+[0-9]{11}$)")
# get the input
words = argv[1].split()
@mbos
mbos / get-mail.py
Last active June 12, 2018 10:01
Pythonista script: Parses a text from drafts 5 to look for e-mail addresses and opens mail # with the addresses in the to and the draft in the body
# title: get-mail.py
# Desc: Parses a text from drafts 5 to look for e-mail addresses and opens mail
# with the addresses in the to and the draft in the body
from sys import argv
from urllib.parse import quote
import webbrowser
import re
EMAIL_REGEX = re.compile(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)")
@mbos
mbos / get-address.py
Last active June 12, 2018 10:05
Pythonista script: Parses a text from drafts 5 to look for a Dutch address or coordinates, opens google maps with it. For addresses is has two modes, first it looks for something that is formatted as an address and has a common word (ie street) if it doesn't find anything it just dumbs down and looks for something formatted as an address. If no …
# title: get-address.py
# Desc: Parses a text from drafts 5 to look for a Dutch address or coordinates, opens google maps with it
# For addresses is has two modes, first it looks for something that is formatted as an address and has
# a common word (ie street) if it doesn't find anything it just dumbs down and looks for something formatted as an address
# If no address is found it checks for lattitude / longitude coordinates
from sys import argv, exit
import webbrowser
import re
from urllib.parse import quote
@mbos
mbos / keybase.md
Created September 18, 2015 09:51
keybase prove of ownership

Keybase proof

I hereby claim:

  • I am mbos on github.
  • I am mikebos (https://keybase.io/mikebos) on keybase.
  • I have a public key whose fingerprint is C048 802E F412 4D29 A189 250B 1F25 F0DF 7882 4FC3

To claim this, I am signing this object: