Skip to content

Instantly share code, notes, and snippets.

View techtonik's full-sized avatar

anatoly techtonik techtonik

View GitHub Profile
@techtonik
techtonik / subst: ISWIN
Last active March 20, 2016 18:31
subst: ISWIN
import platform
ISWIN = platform.system() == 'Windows'
@techtonik
techtonik / pkgcoparser.py
Last active February 29, 2016 14:58
pkg-config *.co file parser
# public domain
data = """
prefix=/opt/windows_32
exec_prefix=${prefix}
libdir=/opt/windows_32/lib
includedir=${prefix}/include
Name: Pango Win32
Description: Win32 GDI font support for Pango
@techtonik
techtonik / NonBlockingPipe.md
Last active September 21, 2023 18:01
Non-blocking pipe reads in Windows Python
@techtonik
techtonik / tooltip.html
Created December 26, 2015 10:26
HTML tooltip on hover
<!DOCTYPE html>
<style>
#suggestButton { display: none; }
table.badge > tbody > tr > td > img,
table.badge > tbody > tr > th { cursor: pointer; }
#markup-tooltip {
display:none;
position:fixed;
@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 / webview.py
Last active October 27, 2023 10:33
View HTML content in Python with PySide
"""
Placed into public domain by
anatoly techtonik <techtonik@gmail.com>
Show HTML in GUI window through PyQt4/PySide.
[ ] position window at the center of the screen
(right now it is middle bottom)
[ ] implement lazy loading for PyQt4/PySide
"""
@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 / stripspace.py
Last active November 9, 2016 10:41
Strip trailing whitespace from file
#!/usr/bin/env python2
"""\
strip trailing whitespace from file
usage: stripspace.py <file>
code is placed into public domain
"""
import sys
@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 / 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