Skip to content

Instantly share code, notes, and snippets.

Avatar

Alberto Sonnino asonnino

View GitHub Profile
@asonnino
asonnino / organize-media.py
Last active Jul 2, 2021
Sort torrent downloads based on their media type (movies or tv shows).
View organize-media.py
''' Python script to sort torrent media downloads based on their type (movies
or tv shows). The script does not move the media, but rather creates a
symlink to the desired location (so to not disrupt seeding).
Schedule a regular execution of this script with a cron job, e.g.,
*/15 * * * * /usr/bin/python3 /home/pi/organize-media.py
'''
from os.path import join, basename, splitext, isdir, exists
from glob import glob
import os
@asonnino
asonnino / disk-monitor.py
Last active Jul 2, 2021
Python script to monitor a disk partition and send email alerts when it is almost full.
View disk-monitor.py
''' Python script to monitor a disk partition and send email alerts when it is
almost full. The alert is sent from a Gmail account.
First install 'yagmail':
$ pip install yagmail
Then schedule a regular execution of this script with a cron job, e.g.,
*/15 * * * * /usr/bin/python3 /home/pi/disk-monitor.py
'''
import subprocess
@asonnino
asonnino / raspbian-vpn-router-guide.md
Last active Jul 2, 2021
Setup a VPN router on Raspbian.
View raspbian-vpn-router-guide.md
@asonnino
asonnino / nginx-node-conf
Last active Jul 2, 2021
Example of Nginx configuration file for HTTPS proxy to a nodejs server.
View nginx-node-conf
#
# nginx configuration file for HTTPS proxy to a nodejs server.
# 1. obtain an SSL certificate from letsencrypt (https://letsencrypt.org)
# 2. copy this file to /etc/nginx/site-available;
# 3. create an alias for nginx: ln -s /etc/nginx/site-available/example.com /etc/nginx/site-enabled
# 4. restart nginx: sudo service nginx restart
#
# HTTP - redirect all requests to HTTPS:
server {
@asonnino
asonnino / nginx-html-conf
Last active Jul 2, 2021
Example of Nginx configuration file for plain html website with SSL/TLS.
View nginx-html-conf
#
# nginx configuration file for plain html website with SSL/TLS.
# 1. obtain an SSL certificate from letsencrypt (https://letsencrypt.org)
# 2. copy this file to /etc/nginx/site-available;
# 3. create an alias for nginx: ln -s /etc/nginx/site-available/example.com /etc/nginx/site-enabled
# 4. restart nginx: sudo service nginx restart
#
# HTTP - redirect all requests to HTTPS
server {