Skip to content

Instantly share code, notes, and snippets.

View tbnorth's full-sized avatar

Terry Brown tbnorth

View GitHub Profile
@tbnorth
tbnorth / send_large_data.md
Last active October 17, 2018 18:42
Notes for sending a large amount of data

Say you have a large amount of data you want to send in a folder, say /path/to/large/data. Make a new folder, somewhere it can be accessed by your recipient, by FTP / scp / ssh / HTTP, whatever. E.g. /other/path/to/parts. Then do:

SOURCE="/path/to/large/data"
DEST="/other/path/to/parts"
tar cf - "$SOURCE" | gzip | split -da6 -b10M - "$DEST"/part.
sha1sum "$DEST"/part.* >"$DEST"/checksums.txt

Be careful to omit trailing slashes, as in the first two lines above.

@tbnorth
tbnorth / notes.md
Last active October 1, 2018 18:48
notes on printing notes from GitHub markdown to pdf

One time,

echo -e '\usepackage{extsizes}\n\usepackage[margin=0.25in]{geometry}' >extsizes.inc

because -V geometry:margin=0.25in is ignored for some reason.

Then

pandoc https://raw.githubusercontent.com/tbnorth/deltest/554550cf/toolsdemo.md \
 --include-in-header extsizes.inc -V documentclass=extarticle \
@tbnorth
tbnorth / guacdock.md
Last active February 20, 2021 19:44
Set up Apache Guacamole using Docker

Apache Guacamole using Docker to put your personal desktop on the web

  • This guide doesn't cover security issues at all.
  • This guide is intended to just get your personal desktop onto the web so you can use it remotely, it doesn't cover serious multi-user Guacamole deployment.
  • At the end of this file there are some notes on installing docker, running a VNC server, and setting up a web proxy, but this guide really isn't meant to cover those topics.
  • This guide is based on [Installing Guacamole with Docker
@tbnorth
tbnorth / sedcol.md
Last active November 16, 2020 01:49
sed select column

A sed solution that selects a column by number:

echo 0 1 2 3 iv 5 6 | sed -E 's/^(\S+\s+){4}(\S+).*/\2/'

or

echo 0 1 2 3 iv 5 6 | sed 's/^\(\S\+\s\+\)\{4\}\(\S\+\).*/\2/'
@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