Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephan Sokolow ssokolow

View GitHub Profile
@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
View is_zip_safe.php
<?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
View reset_play_statistics.py
#!/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
View take_screenshot.py
#!/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
View prompt_gentoo_setup.sh
#!/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)
View onelinespelltextedit.py
#!/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:
@ssokolow
ssokolow / README.md
Last active October 4, 2022 00:48
Files for making Flatpak builds of lgogdownloader
View README.md

A Flatpak release of LGOGDownloader to provide easy access to up-to-date builds with the optional QtWebEngine dependency enabled.

Note that the included patch for the htmlcxx dependency was submitted to upstream, but the project appears to be unmaintained.

@ssokolow
ssokolow / godot_game.iss
Created March 23, 2022 22:57
Example Inno Setup script for Godot games
View godot_game.iss
; IMPORTANT: Follow the instructions at
; https://docs.godotengine.org/en/stable/getting_started/workflow/export/changing_application_icon_for_windows.html
; and make sure the "Options > Application > Product Version" field is set
; in Godot's Export dialog before exporting your EXE file. Otherwise,
; Inno Setup will mistake the Godot version for your game's version.
;
; You can check whether you were successful by examining the .EXE file's
; properties dialog on Windows, or by using the `peres -v` command from `pev`
; on Linux.
;
@ssokolow
ssokolow / git-extract-paths-with-history
Last active March 14, 2023 22:40
Wrapper for git-filter-repo to extract paths into a new clone, preserving history across renames
View git-extract-paths-with-history
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Wrapper for git-filter-repo to extract paths into a new clone, following the
rename history to preserve all revisions of whitelisted paths.
WARNING: There appears to be no way to ask git-filter-repo to exclude stuff
that later takes on a name a renamed file gave up, so this will be
insufficient if you move a/b.py to b/b.py and then create a new a/b.py
and only want to preserve the history of b/b.py without keeping the
unrelated a/b.py.
@ssokolow
ssokolow / update_flatpak_cli.py
Last active March 19, 2023 07:42
Utility for making Flatpak-installed apps available in the terminal through their normal command names
View update_flatpak_cli.py
#!/usr/bin/env python3
"""Flatpak CLI Shortcut Generator
A simple no-argument tool that generates launchers with traditional non-flatpak
command names for your installed Flatpak applications in ~/.local/bin/flatpak.
Does full collision detection and warns you if you forgot to add its output
directory to your PATH. Also overrules the command-line specified in the
``.desktop`` file if the Flatpak maintainer didn't include support for
command-line arguments.
@ssokolow
ssokolow / strip_emoji.py
Created March 17, 2021 21:09
Simple script to rename non-BMP Unicode characters out of file and folder names, recursively
View strip_emoji.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Strip emoji and other non-BMP codepoints from paths to make them compatible
with mkisofs/genisoimage"""
# Prevent Python 2.x PyLint from complaining if run on this
from __future__ import (absolute_import, division, print_function,
with_statement, unicode_literals)
__author__ = "Stephan Sokolow (deitarion/SSokolow)"