Skip to content

Instantly share code, notes, and snippets.

View Genarito's full-sized avatar
🚀
Working

Genaro Camele Genarito

🚀
Working
View GitHub Profile
@Genarito
Genarito / update_docker_postgres_version.sh
Last active October 17, 2022 21:02
Backups the Docker volume, updates the Postgres version and finally restores the data in the new Postgres version
# Backup the data. Taken from https://stackoverflow.com/a/67568671/7058363
docker volume create --name backup_volume
docker container run --rm -it -v [old volume]:/from -v backup_volume:/to alpine ash -c "cd /from ; cp -av . /to"
# Export Postgres data
docker exec -t [name of DB container] pg_dump [db name] | gzip > exported_postgres_data.sql.gz
# MANUAL: stop the Docker container to which the volume is attached...
@Genarito
Genarito / static_encoder.py
Last active January 3, 2024 14:37
Django template tag for encoding images in base64 and rendering with server with Python 3.x
from django import template
from django.contrib.staticfiles.finders import find as find_static_file
import base64
register = template.Library()
def get_file_data(file_path: str) -> bytes:
"""
@param file_path: Path of the file to get the data