Skip to content

Instantly share code, notes, and snippets.

View techtonik's full-sized avatar

anatoly techtonik techtonik

View GitHub Profile
@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 / 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 / minijinja.py
Last active January 15, 2022 21:57
Template engine that knows how to render {{ tag }}
# minijinja is in public domain
class MiniJinja(object):
""" Template engine that knows how to render {{ tag }} """
def __init__(self, templates='.'):
"""templates - template path"""
import re
import sys
self.PY3K = sys.version_info[0] == 3
# --- 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 / saveclip.py
Last active May 5, 2016 20:19
save clipboard image to file
#!/usr/bin/env python
#
# the code is in public domain
# gist:4009c397f8f8aff31a46
#
# history:
# 1.2 - rename to saveclip.py
# 1.1 - mention what library should be installed
# 1.0 - make get_avail_filename() function
@techtonik
techtonik / sha1.py
Last active March 3, 2024 16:06
Calculate SHA-1 of a file in Python
#!/usr/bin/env python
"""
usage: python -m sha1 <filename>
"""
import sys
import hashlib
# --- these fields are required for packaging
__version__ = '1.0'
__author__ = 'anatoly techtonik <techtonik@gmail.com>'
@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 / 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()
"""
@techtonik
techtonik / subst: PY3K
Last active February 26, 2016 07:57
subst: PY3K
import sys
PY3K = sys.version_info[0] == 3
@techtonik
techtonik / netquery.py
Created December 16, 2013 19:05
Get ids of available network interfaces
import os
def get_nic_ids():
return os.listdir('/sys/class/net')
# Linux: Yes
# MacOS: Unknown
# FreeBSD: Unknown
# Windows: No