Skip to content

Instantly share code, notes, and snippets.

@SimonHertoge
SimonHertoge / deluge-recover-session.py
Created December 28, 2024 22:19
Recovers a crashed Deluge session using the corresponding fastresume file
from deluge._libtorrent import lt
from deluge.core.core import Core
from deluge.core.rpcserver import RPCServer
from deluge.core.torrentmanager import TorrentState
"""
Recovers a crashed Deluge session when the corresponding libtorrent fastresume file still exists,
because it contains all the necessary metadata. As a bonus you don't need to recheck terabytes of data.
Make sure to stop any other running instances to avoid file conflicts.
"""
@SimonHertoge
SimonHertoge / doc-page-counter.py
Created January 10, 2019 15:05
Counts the page/slide total of a list of documents (pptx, docx, pdf), w/o dependencies
from sys import argv
from xml.etree import ElementTree
from zipfile import ZipFile
import re
def count(filename):
ext = filename.split('.')[-1]
if ext == 'pptx' or ext == 'docx':
with ZipFile(filename) as zip:
meta = zip.read('docProps/app.xml')
@SimonHertoge
SimonHertoge / pdc2pdf.sh
Created September 23, 2018 21:50
Dump PDFs from "protected" LockLizard PDC files, requires Cygwin and Sysinternals tools (and a registered license)
#!/usr/bin/env bash
syspath="/cygdrive/c/Users/Simon/Desktop/Tools/Nirsoft Launcher/SysInternals/"
pdcpath="/cygdrive/c/Program Files (x86)/Locklizard Safeguard PDF Viewer/"
IFS=$'\n'
for file in $(ls *.pdc); do
echo $file
file=$(echo $file | sed 's/\(.*\)\.pdc/\1/')
"${pdcpath}PDCViewer.exe" "$file.pdc" &
sleep 6
pid=$("${syspath}/pslist" | findstr PDCViewer | tr -s ' ' | cut -f2 -d' ' | tail -n1)