Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephan Sokolow ssokolow

View GitHub Profile
@ssokolow
ssokolow / x11_watch_active_window.py
Last active May 5, 2021
python-xlib example which reacts to changing the active window
View x11_watch_active_window.py
#!/usr/bin/env python
"""python-xlib example which reacts to changing the active window/title.
Requires:
- Python
- python-xlib
Tested with Python 2.x because my Kubuntu 14.04 doesn't come with python-xlib
for Python 3.x.
@ssokolow
ssokolow / trackball.sh
Last active Apr 29, 2021
xinput configuration for an old two-button Logitech Marble Mouse
View trackball.sh
#!/bin/sh
# Setup for comfortable use of an old two-button Logitech Marble Mouse
# via a cheap USB-PS/2 adapter.
#
# Resulting functionality:
# 1. Pointer acceleration is tweaked to be usable on a three-monitor spread
# 2. Press and hold left button for 300ms to get right-click
# 3. Right mouse button is remapped to middle mouse button
# 4. Holding the right button turns the trackball into a scroll wheel
# 5. Both vertical and horizontal scrolling are enabled
@ssokolow
ssokolow / update_flatpak_cli.sh
Created Apr 29, 2021
Proof of concept for making Flatpak-installed GUI apps available in the terminal through their normal command names
View update_flatpak_cli.sh
#!/bin/sh
# Flatpak CLI Shortcut Proof of Concept
# Copyright 2021 Stephan Sokolow (deitarion/SSokolow)
#
# License: MIT
#
# Known shortcomings in this quick and dirty PoC:
# * Assumes command name collisions will never happen
# (A proper implementation would need to prompt the user to resolve conflicts
# if encountered.)
@ssokolow
ssokolow / Cargo.toml
Last active Apr 14, 2021
Simple example of getting the rust-cpython and setuptools-rust examples working together
View Cargo.toml
[package]
name = "unimportant_if_subsumed_by_setuptools"
version = "0.1.0"
authors = ["Your Name Here <your@email.com>"]
[lib]
name = "unimportant_if_subsumed_by_setuptools"
crate-type = ["cdylib"]
[dependencies.cpython]
@ssokolow
ssokolow / pagination_example.sql
Created Dec 23, 2009
Reasonably efficient pagination without OFFSET (SQLite version)
View pagination_example.sql
-- Reasonably efficient pagination without OFFSET
-- SQLite version (Adapted from MS SQL syntax)
-- Source: http://www.phpbuilder.com/board/showpost.php?p=10376515&postcount=6
SELECT foo, bar, baz, quux FROM table
WHERE oid NOT IN ( SELECT oid FROM table
ORDER BY title ASC LIMIT 50 )
ORDER BY title ASC LIMIT 10
@ssokolow
ssokolow / strip_emoji.py
Created Mar 17, 2021
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)"
@ssokolow
ssokolow / dialog_collapsed_with_reporting_callback.png
Last active Mar 17, 2021
Port and refactoring of gtkexcepthook.py for PyQt 5.x and Python 3.5+
@ssokolow
ssokolow / dump_cart.py
Last active Mar 11, 2021
Rough prototype frontend for dumping cartridges with an INL Retro with minimal hassle
View dump_cart.py
#!/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 / term_qt.py
Created Apr 26, 2020
Example of creating a simple terminal emulator widget from a QTextEdit
View term_qt.py
"""Primitive terminal emulator example made from a PyQt QTextEdit widget."""
import fcntl, locale, os, pty, struct, sys, termios
import subprocess # nosec
# Quick hack to limit the scope of the PyLint warning disabler
try:
# pylint: disable=no-name-in-module
from PyQt5.QtCore import Qt, QSocketNotifier # type: ignore
from PyQt5.QtGui import QFont, QPalette, QTextCursor # type: ignore
@ssokolow
ssokolow / pycalendar.py
Last active Jan 2, 2021
Refactored version of Bill Mill's printable calendar code
View pycalendar.py
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""Generate a printable calendar in PDF format, suitable for embedding
into another document.
Tested with Python 2.7.
Dependencies:
- Python
- Reportlab