Skip to content

Instantly share code, notes, and snippets.

View asonnino's full-sized avatar

Alberto Sonnino asonnino

View GitHub Profile
@asonnino
asonnino / disk-monitor-v2.py
Created March 29, 2022 23:12
Python script to monitor a disk partition and send email alerts when it is almost full.
''' 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 the following dependencies:
$ pip3 install google-api-python-client
$ pip3 install google-auth-httplib2
$ pip3 install google-auth-oauthlib
Then schedule a regular execution of this script with a cron job, e.g.,
*/15 * * * * /usr/bin/python3 /home/pi/disk-alert.py
@asonnino
asonnino / organize-media.py
Last active July 2, 2021 15:19
Sort torrent downloads based on their media type (movies or tv shows).
''' 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 July 2, 2021 14:13
Python script to monitor a disk partition and send email alerts when it is almost full.
''' 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 October 16, 2022 13:17
Setup a VPN router on Raspbian.
@asonnino
asonnino / nginx-node-conf
Last active December 12, 2023 02:20
Example of Nginx configuration file for HTTPS proxy to a nodejs server.
#
# 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 {