Skip to content

Instantly share code, notes, and snippets.

Stephan Sokolow ssokolow

View GitHub Profile
@ssokolow
ssokolow / generate_sql_docs.py
Created Mar 4, 2019
A one-off script for converting a specific dump of the SDL wiki into a Dash/Zeal docset... in case it's useful to someone
View generate_sql_docs.py
#!/usr/bin/env python
"""Quick script to generate a Dash/Zeal docset from the SDL 2 wiki.
Requirements:
- Python 2.x (3.x may work, but it's untested)
- LXML (for parsing the non-XML HTML used in the pages)
- Pillow (for converting favicon.ico into icon.png)
- http://www.libsdl.org/tmp/SDL-wiki.zip
"""
@ssokolow
ssokolow / timestamp.rs
Last active Jul 23, 2018
Quick semi-hack to provide a means to serde-serialize file modification times prior to UNIX_EPOCH
View timestamp.rs
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::panic::catch_unwind;
/// Variation on `std::time::Duration` that sacrifices a bit of precision on the positive
/// side of the in order to provide a nicely serializable form for `SystemTime` values.
///
/// (Workaround for https://github.com/serde-rs/json/issues/464)
#[derive(Eq, PartialEq, Debug, Serialize, Deserialize)]
pub struct Timestamp {
@ssokolow
ssokolow / spelltextedit.py
Last active Feb 23, 2018
Spell-checked QPlainTextEdit for PyQt 5.x using PyEnchant
View spelltextedit.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""QPlainTextEdit With Inline Spell Check
Original PyQt4 Version:
https://nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check/
Copyright 2009 John Schember
Copyright 2018 Stephan Sokolow
@ssokolow
ssokolow / pycalendar.py
Last active Nov 25, 2017
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
@ssokolow
ssokolow / 99-rfid-scanner.rules
Created Nov 2, 2017
Demonstration of using a cheap chinese RFID reader from a background application without messing up foreground ones
View 99-rfid-scanner.rules
# Use `udevadm info -a -n /dev/input/whatever` to look up ATTRS{name}
SUBSYSTEM=="input", ATTRS{name}=="HID 04d9:1400", MODE="0666"
@ssokolow
ssokolow / screenshot.png
Last active Jun 6, 2018
Simple script to streamline the process of updating a Retrode's firmware on Linux
@ssokolow
ssokolow / Cargo.toml
Last active Oct 9, 2018
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 / update_check.py
Last active Aug 26, 2017
Simple apt-get update notifier using desktop notifications and cron
View update_check.py
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""Simple notify2-based apt-get update notifier
Requires:
- dbus-python (A.K.A. python-dbus)
- notify2
- python-gobject (for Python 2.x)
(Though it shouldn't be too difficult to adapt to Python 3.x since
@ssokolow
ssokolow / grab_id.sh
Created Jul 14, 2017
Helper for downloading Windows-only Steam games on Linux (eg. for the ScummVM resources)
View grab_id.sh
#!/bin/sh
#
# A simple helper to automate the process of downloading Windows-only games
# using the Linux version of SteamCMD.
#
# (This is what happens when I self-nerd-snipe on something despite finding
# it distasteful, like downloading ScummVM resources from Steam because the
# Humble Bundle DRM-free downloads were missing a couple of the games offered
# by the included the Steam key.)
#
@ssokolow
ssokolow / transmission_vpn.py
Last active May 22, 2017
Wrapper to bind Transmission to the IP for a VPN interface on Linux or refuse to start on failure
View transmission_vpn.py
#!/usr/bin/env python
"""Simple wrapper to update Transmission's IPv4 binding on startup for use with VPNs.
(For Linux systems. Tested on Ubuntu 14.04 LTS)
"""
import json, os, subprocess
VPN_IF = "tun0"
TRANSMISSION_CFG = os.path.expanduser('~/.config/transmission/settings.json')
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.