Skip to content

Instantly share code, notes, and snippets.

@nyov
nyov / mozlz4a.py
Last active November 1, 2020 12:15 — forked from Tblue/mozlz4a.py
MozLz4a compression/decompression utility
#!/usr/bin/python3
#
# 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
#
@nyov
nyov / example-usage.sql
Last active March 8, 2022 06:50 — forked from myitcv/time_travel_trigger.sql
postgres timetravel using triggers (row-level versioning)
DROP TABLE IF EXISTS fruits;
CREATE TABLE fruits (
id SERIAL NOT NULL,
name TEXT,
valid_from TIMESTAMP NOT NULL,
valid_to TIMESTAMP NOT NULL
);
DROP TRIGGER IF EXISTS fruits_before ON fruits;
@nyov
nyov / adbapi.py
Last active August 17, 2017 05:53 — forked from powdahound/adbapi.py
from twisted.enterprise import adbapi
from twisted.python import log
import MySQLdb
class ReconnectingConnectionPool(adbapi.ConnectionPool):
"""Reconnecting adbapi connection pool for MySQL.
This class improves on the solution posted at
http://www.gelens.org/2008/09/12/reinitializing-twisted-connectionpool/
by checking exceptions by error code and only disconnecting the current