Skip to content

Instantly share code, notes, and snippets.

@petzku
petzku / diff.py
Last active November 19, 2021 11:43
""" Diff video sources to catch infoboxes and other signs.
Usage: $ python diff.py <clean> <hardsubbed> [start-offset]
`start-offset` should be the number of frames to drop from start to align the two video sources.
Positive values drop frames from `clean`, negative from `hardsubbed`.
If left out, automatically deduce the proper offset.
Outputs frame ranges to stdout, and a diffing clip to "out.y4m".
-- Copyright (c) 2020, petzku <petzku@zku.fi>
--
-- Permission to use, copy, modify, and distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
@petzku
petzku / secrets.py
Last active October 4, 2019 10:16
script to replace secrets into config files
#!/usr/bin/env python3
""" replace secrets with base64-encoded env-vars
Specifically, replace any instance of ${{ secrets.XXXX }} with the Base64 encoded value of $XXXX.
Usage:
`python secrets.py <input file> [output file]`
if output file is unspecified, outputs to stdout.
"""
import os
@petzku
petzku / goldfish_to_txt.py
Last active August 29, 2019 15:56
Python script to reformat mtggoldfish decklists to "normal" text form
#!/usr/bin/env python3
from typing import List
def goldfish_to_txt(lines: List[str], skip_headers=False) -> List[str]:
""" Takes a deck in mtggoldfish format and returns traditional text
Arguments:
lines -- each line is either a "header" or a decklist entry
skip_headers -- whether to skip header lines