Skip to content

Instantly share code, notes, and snippets.

View MilovanTomasevic's full-sized avatar
🎯
Focusing

Milovan Tomaőević MilovanTomasevic

🎯
Focusing
View GitHub Profile
@cabecada
cabecada / gist:da8913830960a644755b18a02b65e184
Last active January 14, 2025 16:00
python postgres connection with retry example
#!/usr/bin/env python
#https://github.com/psycopg/psycopg2/issues/261
import psycopg2
ISOLEVEL = psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT
import time
@Julian-Nash
Julian-Nash / flask_sitemap_generator.py
Last active July 13, 2025 17:56
Flask dynamic sitemap generator
@app.route("/sitemap")
@app.route("/sitemap/")
@app.route("/sitemap.xml")
def sitemap():
"""
Route to dynamically generate a sitemap of your website/application.
lastmod and priority tags omitted on static pages.
lastmod included on dynamic content such as blog posts.
"""
from flask import make_response, request, render_template
import threading
from typing import Any
class PropagatingThread(threading.Thread):
"""A Threading Class that raises errors it caught, and returns the return value of the target on join."""
def __init__(self, *args, **kwargs):
self._target = None
self._args = ()