Skip to content

Instantly share code, notes, and snippets.

View CaselIT's full-sized avatar

Federico Caselli CaselIT

View GitHub Profile
@CaselIT
CaselIT / main.py
Created April 3, 2020 20:24 — forked from henribru/main.py
`selectinload` doesn't load all relationships when used with `with_polymorphic` and subclasses have relationships with the same name
from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, inspect
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, with_polymorphic, selectinload
from sqlalchemy.orm import sessionmaker
engine = create_engine('sqlite:///:memory:', echo=True)
Session = sessionmaker(bind=engine)
Base = declarative_base()
@CaselIT
CaselIT / mozlz4a.py
Created November 27, 2017 20:31 — forked from Tblue/mozlz4a.py
MozLz4a compression/decompression utility
#!/usr/bin/env python
#
# Decompressor/compressor for files in Mozilla's "mozLz4" format. Firefox uses this file format to
# compress e. g. bookmark backups (*.jsonlz4).
#
# This file format is in fact just plain LZ4 data with a custom header (magic number [8 bytes] and
# uncompressed file size [4 bytes, little endian]).
#
# This Python 3 script requires the LZ4 bindings for Python, see: https://pypi.python.org/pypi/lz4
#