Skip to content

Instantly share code, notes, and snippets.

View techtonik's full-sized avatar

anatoly techtonik techtonik

View GitHub Profile
@techtonik
techtonik / urlpath.py
Last active August 29, 2015 14:04
urlparse for humans
#!/usr/bin/env python
"""
Public domain work by anatoly techtonik <techtonik@gmail.com>
History:
1.0 - parse URL string and split into attributes
2.0 - modify properties to reconstruct URL with str()
"""
# --- communicating.. networking.. ---
__author__ = "anatoly techtonik <techtonik@gmail.com>"
__license__ = "MIT/Public Domain/CC0"
__version__ = "1.0.beta1"
import socket
IP4 = socket.AF_INET
UDP = socket.SOCK_DGRAM
@techtonik
techtonik / ntkr128g.py
Last active August 29, 2015 14:10
Windows 128Gb Memory Limit
# Windows 4Gb memory limit patcher (unlocks access to 128Gb)
# (thanks to Geoff Chappell for original research)
# http://www.geoffchappell.com/notes/windows/license/memory.htm
# Check if patch for 128Gb Windows NT extensions is up to date
#
# [x] check that size of ntkrnlpa.exe and ntkr128g.exe (patched) matches
# [x] read File Version in .exe for reporting
# [ ] find signature in new original file
# [ ] show previous offsets for known File Versions and new
@techtonik
techtonik / git-burn.py
Last active August 29, 2015 14:12
git: Remove local branches merged upstream
#!/usr/bin/env python
# Remove merged git branches. Cross-platform way to execute:
#
# git branch --merged | grep -v master | xargs git branch -d
#
# Requires gitapi - https://bitbucket.org/haard/gitapi
# License: Public Domain
import gitapi
@techtonik
techtonik / winwifi.py
Last active August 29, 2015 14:13
Windows WiFi: List sorted Profile data (requires admin)
# Windows stores configured WiFi networks as Profile
# [ ] this needs to be run under administrator
# [ ] detect that it is not
try:
import _winreg # Python 2
except ImportError:
import winreg # Python 3
@techtonik
techtonik / python28.py
Last active August 29, 2015 14:17
Python 2.8 Rationale
# Solve problem of Python 2.7 defaults
# 1. switch internal Python 2 encoging from internal ASCII to Unicode
# (this fixes interoperability of Jinja2 with tools that use binary
# utf-8 for passing strings instead of Unicode, e.g. Roundup)
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
# 2. do not fail on printing stuff to stdout/stderr, but escape it
# (removes negative emotions trying to debug binary strings with print)
import codecs
@techtonik
techtonik / vardumper.py
Last active August 29, 2015 14:28
Blueprint for dumper of Python variables
"""
The code is placed in to public domain by
anatoly techtonik <techtonik@gmail.com>
Produce readable representation of variable content,
including custom properties for complex objects.
Needed features:
[ ] easy import
[ ] sane defaults
@techtonik
techtonik / treelog.json
Last active September 4, 2015 11:28
SCons - Dump Build Graph
{
"nodes": [
"wesnothd",
"wesnothd.exe",
"ban.o",
"ban.cpp",
"forum_user_handler.o",
"forum_user_handler.cpp",
"game.o",
"game.cpp",
@techtonik
techtonik / ssh-agent.py
Last active September 10, 2015 08:21
ssh-agent.py wrapper
#!/usr/bin/env python
"""\
ssh agent wrapper to detect or run agent, set environment
and either show it or execute specified command in this
environment.
usage: ssh-agent.py
ssh-agent.py <command>
examples:
@techtonik
techtonik / get_svn_path_revision.py
Created September 7, 2011 23:12
VCS - Subversion - Get revision number for a given path in local copy
def get_svn_path_revision(path):
"""return latest modification revision of a path inside svn
:raise: EnvironmentError if SVN working copy format is unknown
:return: int
"""
from os.path import basename, dirname, join, isdir
if isdir(path):
entries_path = join(path, ".svn", "entries")