This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| if str is bytes: | |
| def copy(text): | |
| p = subprocess.Popen(['pbcopy', 'w'], | |
| stdin=subprocess.PIPE, close_fds=True) | |
| p.communicate(input=str(text)) | |
| def paste(): | |
| p = subprocess.Popen(['pbpaste', 'r'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| class RGB(tuple): | |
| LUM_SCALE=(0.35,0.48,0.17) | |
| def __new__(cls, *args): | |
| if not args: | |
| raise TypeError('A string or tuple is required for an RGB') | |
| if len(args) == 1: | |
| arg, = args | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import re | |
| from collections import defaultdict | |
| class PtnReps: | |
| def __init__(self, flags, reps): | |
| parts = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import openpyxl | |
| def scan_merges(sheet): | |
| merges = {} | |
| for m in sheet.merged_cells.ranges: | |
| c = m.start_cell.coordinate | |
| for pos in m.cells: | |
| merges[pos] = c | |
| return merges |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import sys | |
| import os | |
| import subprocess as sp | |
| from tempfile import TemporaryDirectory | |
| RPA = os.path.expanduser('~/bin/rpatool') | |
| TOICNS = os.path.expanduser('~/Code/python/toicns.py') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import sys | |
| import os | |
| import itertools | |
| from typing import Optional, Any, TypeAlias | |
| from PIL import Image | |
| Size: TypeAlias = tuple[int,int] | |
| MIN_SIZE = (512,512) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import re | |
| class MultiSub: | |
| def __init__(self, subs:dict): | |
| self.subs = subs | |
| self.ptn = re.compile('|'.join(map(re.escape, subs))) | |
| def replacement(self, m): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Tool for editing a large block of text split into lines. | |
| This can make small changes much faster. | |
| Also provides lots of methods for searching and mutating | |
| the text. | |
| """ | |
| import re as _re | |
| from typing import NamedTuple, Match |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """Dumps the table definitions (and optionally view definitions) | |
| of a specified schema using command-line mysql commands. | |
| If you don't specify --views or --tables, table definitions will be | |
| included.""" | |
| import subprocess | |
| import sys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| # decrypt_dbvis.py ~ gerry@twitter.com | |
| # DbVisualizer uses PBEWithMD5AndDES with a static key to store passwords. | |
| # This is a quick hack to extract and decrypt credentials from DbVisualizer config files. | |
| # Tested against DbVisualizer Free 9.0.9 and 9.1.6 | |
| # | |
| # install lxml and pycryptodome | |
| # |
NewerOlder