Skip to content

Instantly share code, notes, and snippets.

View ssokolow's full-sized avatar

Stephan Sokolow ssokolow

View GitHub Profile
@ssokolow
ssokolow / tweets.py
Created March 15, 2020 12:05
Alternative viewer for tweets in a Twitter data export
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""A simple script to preview the text of tweets in tweet.js from a Twitter
dump.
Accepts Zip files fresh from Twitter or extracted tweet.js files as input.
"""
# Prevent Python 2.x PyLint from complaining if run on this
from __future__ import (absolute_import, division, print_function,
@ssokolow
ssokolow / camelcase.rs
Last active June 20, 2022 10:28
CamelCase parser for Rust
//! Routines for parsing camelcase strings
//!
use std::mem::replace;
use unicode_categories::UnicodeCategories;
use unicode_segmentation::{GraphemeIndices, UnicodeSegmentation};
// --== Enums ==--
// TODO: Refresh my memory of which other traits I'm advised to derive on this.
@ssokolow
ssokolow / audit_python2.py
Last active January 8, 2022 17:45
Quick script to find Python files which may need porting to run on Python 3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""A simple helper to search for Python scripts which still don't declare
python3 in their shebang lines as a proxy for finding un-migrated scripts.
"""
__author__ = "Stephan Sokolow (deitarion/SSokolow)"
__appname__ = "Python 2.x Auditor"
__version__ = "0.1"
__license__ = "MIT"
@ssokolow
ssokolow / escape_non_utf8_paths.rs
Last active April 11, 2024 05:42
Code for storing Rust Path/PathBuf data as valid UTF-8 (eg. JSON) strings
/* POSIX paths in JSON via escaping which
doesn't alter valid UTF-8 paths.
The trick is recognizing that JSON can store binary nulls in strings
but nulls are the only character that can't occur in POSIX paths,
so we can use it as an escape character that won't change how existing
serialized paths get interpreted.
Copyright 2018-2020, Stephan Sokolow
@ssokolow
ssokolow / python_boilerplate.py
Created October 13, 2019 08:54
The raw/initial output from "boiler" in my ~/.vim/snippets/python.snippets
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""[application description here]"""
# 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)"
__appname__ = "[application name here]"
@ssokolow
ssokolow / mass_diff.py
Created October 4, 2019 06:44
Quick helper script to cross-compare large numbers of dumps of a ROM or disk to identify bits that vary between dumps
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Simple tool to identify bad bits in a cartridge by comparing many dumps
--snip--
Requires numpy.
"""
@ssokolow
ssokolow / gist:5b59998d2245325758ac9bbf462605c2
Created August 25, 2019 16:51
Helper script to override Firefox's attempt to open .cbz files as Zip files, regardless of OS file associations
#!/bin/sh
# NOTE: Despite this script using KDE commands like ark and kdialog, Firefox
# doesn't obey KDE's file associations, so you'll need to use a non-KDE
# file manager like PCManFM to edit the file associations.
open_zip() {
exec ark "$@"
}
offer_comix() {
@ssokolow
ssokolow / dump_cart.py
Last active March 11, 2021 19:22
Rough prototype frontend for dumping cartridges with an INL Retro with minimal hassle
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Streamlined Wizard for dumping games with the INL Retro cartridge dumper"""
__author__ = "Stephan Sokolow (deitarion/SSokolow)"
__appname__ = "INL Retro Dumping Helper"
__version__ = "0.1"
__license__ = "MIT"
# pylint: disable=bad-builtin
@ssokolow
ssokolow / image_widget.py
Last active May 20, 2023 19:42
PyQt 5.x code for Just Do What I Mean™ image display in the presence of animated GIFs and containers with no fixed aspect ratio
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Example code for a PyQt image-display widget which Just Works™
TODO: Split this into a loader wrapper and a widget wrapper so it can be used
in designs which maintain a preloaded queue of upcoming images to improve
the perception of quick load times.
"""
from __future__ import (absolute_import, division, print_function,
@ssokolow
ssokolow / dialog_collapsed_with_reporting_callback.png
Last active January 17, 2024 09:34
Port and refactoring of gtkexcepthook.py for PyQt 5.x and Python 3.5+
dialog_collapsed_with_reporting_callback.png