Skip to content

Instantly share code, notes, and snippets.

View d-rama's full-sized avatar
🏠
Working from home

Dennis Rama d-rama

🏠
Working from home
View GitHub Profile
@d-rama
d-rama / gist:0e5002524ec05da00877bd06e9fe029c
Last active January 26, 2021 21:18 — forked from enkore/gist:2978752
HTML to reportlab flowables converter
# I place this in the public domain
# This only handles non-nested lists, emphasis, headings and horizontal rules (which are converted to page breaks)
# Sufficient for converting Markdown generated HTML to reportlab flowables...
import xml.sax as sax
def html_to_rl(html, styleSheet):
elements = list()
@d-rama
d-rama / middleware.py
Created December 20, 2018 16:02 — forked from rbtsolis/middleware.py
Django Access the Request or User Object Inside the Models and Signals
# 1) Create a middlewares/middlewares.py file and copy this:
import threading
class RequestMiddleware:
def __init__(self, get_response, thread_local=threading.local()):
self.get_response = get_response
self.thread_local = thread_local
# One-time configuration and initialization.