Skip to content

Instantly share code, notes, and snippets.

View ssokolow's full-sized avatar

Stephan Sokolow ssokolow

View GitHub Profile
@ssokolow
ssokolow / openraster_test.py
Created October 7, 2024 09:13
Proof of Concept for OpenRaster-based "Use external editor" option
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Proof of concept code for generating and opening an OpenRaster image in the
user's preferred OpenRaster editor.
"""
__author__ = "Stephan Sokolow (deitarion/SSokolow)"
__appname__ = "OpenRaster Proof of Concept"
__version__ = "0.1"
__license__ = "MIT"
@ssokolow
ssokolow / completingplaintextedit.py
Created May 10, 2024 05:44
QPlainTextEdit subclass with completion and extras, suitable for Qt Designer promotion
"""A QPlainTextEdit subclass with completion and some extras
Adapted from
https://doc.qt.io/qt-5/qtwidgets-tools-customcompleter-example.html
with the intent to be a minimally complicated way to get as-you-type
autocomplete in a QTextEdit.
As such, a lot of needless complexity has been removed, and odd design choices
which make the code needlessly difficult to maintain have been corrected.
@ssokolow
ssokolow / manga_to_html.py
Created November 23, 2023 07:15
Quick script to split a CBZ file full of two-page scans into pages and then bundle them into data URIs in a .html file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""A quick helper for splitting manga pages in a CBZ containing two-page
spreads and then bundling them into base64 URLs in an HTML file so the mobile
Safari preview inside the iOS Files app can act as a quick-and-dirty manga
reader.
Takes .cbz files and produces large .html files.
Currently assumes first image will be a cover and doesn't split it.
@ssokolow
ssokolow / manga_split.py
Created November 23, 2023 06:05
Quick script to split manga CBZs scanned as two-page spreads so they'll convert with proper page order in Calibre
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""A quick helper for splitting manga pages so Calibre doesn't split them for
you and present them in the wrong order.
Takes and produces .cbz files.
Currently assumes first image will be a cover and doesn't split it.
"""
@ssokolow
ssokolow / dragtargets.py
Created April 8, 2023 17:48
Quick and dirty example of receiving inter-application drag-and-drop in Python with GTK 3.x
#!/usr/bin/python
"""Quit and dirty port of the old PyGTK dragtargets.py to PyGObject"""
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk, Gtk
@ssokolow
ssokolow / is_zip_safe.php
Last active March 12, 2023 16:12
PHP Code to check for Zip files which require ZIP64 support to unpack successfully
<?php
// NOTE: If your goal is to check for maximum compatibility
// rather than ZIP64 specifically, hedge against Zip
// implementations which use signed integer variables by
// changing 0xFFFF and 0xFFFFFFFF to 0x7FFF and 0x7FFFFFFF
// and then add a check for which compression algorithm
// each statIndex call says is in use.
function isZipSafe($path) {
@ssokolow
ssokolow / reset_play_statistics.py
Last active December 10, 2022 21:31
Script to reset play statistics on EmulationStation-based distros like RetroPie and Batocera
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""A helper to reset play statistics in gamelist.xml files.
Originally developed for preparing a Batocera Linux device to be installed as a
gift to the family after it had been recording play statistics in response to
QA and integration testing, but should work on any EmulationStation-based
distro.
--snip--
@ssokolow
ssokolow / take_screenshot.py
Last active September 13, 2022 07:38
Proof of concept for automatically taking PySolFC screenshots
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""A simple tool for taking consistent screenshots of PySolFC
Requires wmctrl, xprop, and ImageMagic's import command to be installed.
"""
__author__ = "Stephan Sokolow (deitarion/SSokolow)"
__appname__ = "PySolFC Screenshot Helper"
__version__ = "0.0pre0"
@ssokolow
ssokolow / prompt_gentoo_setup.sh
Created August 12, 2022 17:12
My performance-optimized Zsh prompt
#!/bin/zsh
# Modified gentoo prompt theme
# customized by Stephan Sokolow for git branch and virtualenv display based on:
# http://www.jukie.net/~bart/blog/20071219221358
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/#comment-4166
# https://virtualenvwrapper.readthedocs.io/en/latest/tips.html
#
# See also:
# https://www.topbug.net/blog/2016/10/11/speed-test-check-the-existence-of-a-command-in-bash-and-zsh/
@ssokolow
ssokolow / onelinespelltextedit.py
Last active July 22, 2022 19:53
QLineEdit replacement with automatic PyEnchant spell-checking (based on QPlainTextEdit because it's easier to implement)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Single-Line QPlainTextEdit With Inline Spell Check mimicking QLineEdit
Original PyQt4 Version:
https://nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check/
Multi-Line Version:
https://gist.github.com/ssokolow/0e69b9bd9ca442163164c8a9756aa15f
TODO: