Skip to content

Instantly share code, notes, and snippets.

View tbnorth's full-sized avatar

Terry Brown tbnorth

View GitHub Profile
@tbnorth
tbnorth / rename.sh
Created September 21, 2017 20:00
collapse numbering of sorted files for avconv / ffmpeg
ls *.png | cat -n | sed 's/\(.*[0-9]\)\t\(.*\)/echo mv \2 $(printf %010d \1).png/' | bash
@tbnorth
tbnorth / v
Created September 18, 2017 14:43
Code snippets for helper commands etc.
#!/bin/sh
# capture stdin and show in separate window (virtual temporary paper)
# "git bash" version
cat >/tmp/$$.v.tmp
mintty --exec less /tmp/$$.v.tmp &
@tbnorth
tbnorth / cross_factor.py
Created April 3, 2017 18:55
Cross factor generator
"""
cross_factor.py - describe
Terry N. Brown, [email protected], Mon Apr 03 13:28:41 2017
"""
from collections import namedtuple
def cross_factor(lists):
"""Return (as namedtuples) all combinations of elements from dict of lists"""
@tbnorth
tbnorth / README.md
Last active November 22, 2017 19:35
Yet another dictionary with dot notation.
@tbnorth
tbnorth / signal_manager.py
Last active March 26, 2017 14:40
SignalManager - light weight signal management
"""
signal_manager.py - SignalManager - light weight signal management
Extremely light weight. No enforcement of signal arguments, or
even explicit listing of which signals exist.
Terry Brown, [email protected], Thu Mar 23 21:13:38 2017
"""
from collections import defaultdict
@tbnorth
tbnorth / pyqt58style.py
Last active March 16, 2017 13:04
Demo Qt 5.8 stylesheet tilde problem
"""
Qt >= 5.8 stops parsing stylesheet when it sees ~=,
button text is underlined but not italic, and doesn't change when clicked
PyQt < 5.8 works as expected, button text is underlined and italic,
and becomes large and red when clicked
"""
import sys
from PyQt5 import QtWidgets
@tbnorth
tbnorth / launcher.py
Last active January 30, 2017 15:25
Python script to scan task list and launch missing background tasks
"""
launcher.py - scan running tasks and launch as needed. Useful on Windows where
cygwin's ps isn't informative and procps may be unavailable.
Terry N. Brown, [email protected], Mon Jan 30 09:20:30 2017
"""
import sys
from subprocess import Popen, PIPE
@tbnorth
tbnorth / makecsvt.py
Created January 26, 2017 19:39
Make a GDAL csvt file for a csv file
"""
makecsvt.py - make GDAL .csvt file
Terry Brown, [email protected], Thu Aug 04 10:04:14 2016
"""
import csv
import sys
def get_type_text(path):
# insert / update headlines as comments in @nosent R code
headlines = []
for nd in p.self_and_subtree_iter():
if nd.h and nd.h[0] == '@' or nd.b and nd.b[0] == '@':
continue
headlines.append(nd.h)
lines = nd.b.split('\n')
@tbnorth
tbnorth / blacktape.py
Last active August 8, 2020 11:45
A PyQt "task launcher" for quick access to python scripts.
"""
A PyQt piece of black tape to cover annoying screen features.
[email protected], 2019-10-03
"""
import sys
try:
from PyQt5 import QtWidgets, QtCore, Qt
from PyQt5.QtCore import Qt as QtConst