Skip to content

Instantly share code, notes, and snippets.

View tbnorth's full-sized avatar

Terry Brown tbnorth

View GitHub Profile
from collections import namedtuple
Field = namedtuple("Field", 'name type')
# creates a `Field` class which has two fixed attributes, `name` and `type`
class TablesIndex:
"""TablesIndex - index of DB's and tables in an outline"""
def __init__(self, c):
"""initialize for c
@tbnorth
tbnorth / layout.html
Created December 11, 2017 18:39
d3 layout experiment
<html>
<head>
<style>
</style>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/d3-dispatch.v1.min.js"></script>
<script src="https://d3js.org/d3-selection.v1.min.js"></script>
<script src="https://d3js.org/d3-drag.v1.min.js"></script>
</head><body>
<svg width='900' height='600'>
@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, terrynbrown@gmail.com, 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, terrynbrown@gmail.com, 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, terrynbrown@gmail.com, 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, terrynbrown@gmail.com, Thu Aug 04 10:04:14 2016
"""
import csv
import sys
def get_type_text(path):