Skip to content

Instantly share code, notes, and snippets.

@yrro
yrro / backup.py
Last active October 13, 2024 00:53
Orchestrate backups via borgbackup
#!/usr/bin/python3
# Usage: 'backup' alone will back the system up
# 'backup ARGS' will run borg with ARGS, configuring repository location, passphrase etc.
# e.g., 'backup list ::' will list backups in the repository
# Goals: run on RHEL 8's default Python interpreter (3.6) with no non-RHEL packages required
# Non-goals: backing up multiple filesystems, any configurability save modifying values set
# in code.
@yrro
yrro / zzz_letsencrypt
Created July 4, 2016 15:49
certbot (letsencrypt) cron job
#!/bin/bash
set -eux
mapfile domains <<- EOF
example.com,www.example.com apache2
example.net apache2
imap.example.com dovecot
smtp.example.com exim4
mumble.example.com mumble-server
#!/usr/bin/python3
import subprocess
import sys
import tempfile
def main():
kw = 'answered-learned-ham'
max_size = 2*2**20
@yrro
yrro / java-sd_notify.java
Last active August 19, 2024 12:20
The poor Java programmer's alternative to calling sd_notify
/*
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
/*
Run with:
groovy
-cp '/etc/hadoop/conf:/usr/lib/hadoop/*:/usr/lib/hadoop/lib/*'
hdfs-site.xml
yarn-site.xml
mapred-site.xml
/vagrant/config.groovy
*/
case $(locale charmap) in
UTF-8)
_smile_happy='☺'
_smile_frown='☹'
;;
*)
_smile_happy=':)'
_smile_frown=':('
;;
esac
@yrro
yrro / electrum mnemonic example
Created October 8, 2013 14:53
Generating a 256-bit passphrase with Electrum
$ x=$(od -v -t x1 -A n -N $((256/8)) < /dev/urandom | tr -d '[:space:]')
$ echo $x
807ee2385fb310491e126f248f66fded432d438b1a00133cf00456e85e59f04a
$ python mnemonic.py $x
aside enough match affection fill conversation replace toe mud forget enough bloom gently sunlight out relationship gentle lovely claw dot illuminate marry king grant
$ python mnemonic.py aside enough match affection fill conversation replace toe mud forget enough bloom gently sunlight out relationship gentle lovely claw dot illuminate marry king grant
807ee2385fb310491e126f248f66fded432d438b1a00133cf00456e85e59f04a