Skip to content

Instantly share code, notes, and snippets.

View tbnorth's full-sized avatar

Terry Brown tbnorth

View GitHub Profile
@tbnorth
tbnorth / xargs.sh
Last active June 5, 2018 15:23
parallel process / convert files
basename -s .png *.png | xargs -P3 -IF bash -c "convert -density 400 F.pdf F.png; mogrify -trim -resize x740 F.png"
# probably something like
mogrify -format png -density 400 -trim -resize x740 F.pdf
# would do the same thing, but not the point of this gist
@tbnorth
tbnorth / make_icons.py
Created March 28, 2018 15:35
my Leo icons
"""
make_icons.py - make simple 4 color icons for the box00.png...box15.png
Could be adapted for other icon styles, iterates the 16 states in the
correct order.
WARNING: saves box00.png...box15.png in current directory
Terry Brown, [email protected], Tue Mar 27 12:01:11 2018
"""
theme_name = c.config.getString('theme-name') or c.config.getString('color-theme')
roots = [g.os_path_join(g.computeHomeDir(), '.leo'), g.computeLeoDir()]
theme_subs = ["themes/{theme}/Icons", "themes/{theme}", "Icons/{theme}"]
bare_subs = ["Icons", "."] # "." for icons referred to as Icons/blah/blah.png
paths = []
for root in roots:
for sub in theme_subs:
paths.append(g.os_path_join(root, sub.format(theme=theme_name)))
for root in roots:
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, [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