View get_default_gateway_linux.py
#Snippet for getting the default gateway on Linux
#No dependencies beyond Python stdlib
import socket, struct
def get_default_gateway_linux():
"""Read the default gateway directly from /proc."""
with open("/proc/net/route") as fh:
for line in fh:
fields = line.strip().split()
View firefox_migration.rst

Disaster Plans for Firefox XUL Sunset

Public URL:Github Gist
Status: Incomplete
Last Updated:2017-06-01 05:08 EDT

Threat Summary

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.
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
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.)
#
View boilerplate.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""[application description here]"""
__appname__ = "[application name here]"
__author__ = "Stephan Sokolow (deitarion/SSokolow)"
__version__ = "0.0pre0"
__license__ = "GNU GPL 3.0 or later"
import logging
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')
View partial_shell_parser.py
import shlex
def lex_shellscript(script_path, statement_cb):
"""Given a file-like object, use a POSIX-mode shlex.shlex object to split
it into statements and call the given statement processor to convert
statements into dicts.
"""
fields = {}
with open(script_path, 'r') as fobj:
View restarted_since.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Check if all processes matching a name were started after a config
file's mtime.
--snip--
Tested under Python 2.7 and 3.4
"""
View sftpget.bat
@echo off
REM Usage:
REM 1. Set up your DOS network and packet drivers
REM 2. Install sftpd386.exe
REM 3. Edit the line which calls sftpd386.exe for path/credentials/IP address
REM 4. Run "sftpget file1 file2 file3 ..."
REM Write sftp script
(
@echo off