Skip to content

Instantly share code, notes, and snippets.

@sangelone
sangelone / cleanup.sql
Last active November 2, 2022 04:42
Cleaning a Synapse Server's Postgres DB
DROP FUNCTION IF EXISTS synapse_clean_redacted_messages();
CREATE FUNCTION synapse_clean_redacted_messages()
RETURNS void AS $$
DECLARE
BEGIN
UPDATE events SET content = '{}' FROM redactions AS rdc
WHERE events.event_id = rdc.redacts
AND (events.type = 'm.room.encrypted' OR events.type = 'm.room.message');
END;
$$ LANGUAGE 'plpgsql';
@sangelone
sangelone / word_filter.py
Last active January 5, 2022 20:32
Word filter for speeding up hamming-distance-of-1 searches
''' Word filter for speeding up hamming-distance-of-1 searches.
Narrows down the search space by filtering out words that
can't possibly match because their 'total' is out of
the range +/- 26 from the origin word. Should reduce your
search space by at least half (depending on the word list).
Part of a solution for Proggit quiz #5: http://proggitquiz.com/challenge/5/
'''
#!/usr/bin/env python
"""Bacon Graph Brute-Force Solver
By [email protected]
Synposis: python brute.py [filename]
where filename is a valid bacon graph file
Reference: http://proggitquiz.com/challenge/4/
"""