Skip to content

Instantly share code, notes, and snippets.

View tbnorth's full-sized avatar

Terry Brown tbnorth

View GitHub Profile
@tbnorth
tbnorth / pywait.py
Last active March 3, 2023 15:13
pywait.py - execute arguments whenever a file changes
"""
pywait.py - execute arguments whenever a file changes
Terry N. Brown, [email protected], Mon Dec 12 10:47:49 2016
"""
import os
import sys
import time
@tbnorth
tbnorth / mmove.py
Created October 14, 2016 16:40
Python mouse mover for screen saver suppression
"""
Using mouse events rather than just moving the cursor is important
"""
import sys
import time
import win32api
import win32con
last = -1
@tbnorth
tbnorth / place_window.py
Created September 21, 2016 17:24
Window placement in Windows with Python
"""
Wait 2 seconds then move the active window to the top/bottom
of the left monitor
[email protected], 2016-09-21
"""
import sys
import win32gui
import win32con
@tbnorth
tbnorth / report_reminder.py
Last active March 15, 2023 21:08
Open a big red window when a window called r".*Reminder.*" exists. Because Outlook reminder windows get buried and fail to remind.
"""
Open a big red window when a window called r".*Reminder.*" exists.
Because Outlook reminder windows get buried and fail to remind.
Thanks to http://stackoverflow.com/q/18146596/1072212
[email protected], 2016-09-19
"""
@tbnorth
tbnorth / bootreveal.sh
Last active August 15, 2019 17:24
Bash script to start a new reveal.js presentation on GitHub pages
GITUSER="$1"
NAME="$2"
if [ -e "$NAME" ]; then
echo "$NAME exists, quitting"
return 10 2> /dev/null || exit 10
fi
git clone --depth 1 https://github.com/hakimel/reveal.js "$NAME"
if ! cd "$NAME"; then
@tbnorth
tbnorth / cpd.py
Created July 14, 2016 20:50
Simple duplicate code finder
"""
cpd.py - copy paste detector
output is stupidly redundant, but works fine to detect duplicate code
Terry Brown, [email protected], Thu Jul 14 14:40:02 2016
"""
import os
from collections import defaultdict
@tbnorth
tbnorth / status_recur.sh
Last active May 10, 2023 13:27
Recursively show detailed status of git repos.
find . \( -name HEAD -o -name .git \) -print -prune \
| xargs -L1 dirname \
| xargs -IF sh -c ' \
echo; echo -n F ""; \
(cd F; git rev-parse --abbrev-ref HEAD); \
echo "$((cd F; git ls-files --others --exclude-standard) | wc -l) untracked"; \
(cd F; git remote -v) | sed "s/(.*)//" | sort -u; \
(cd F; git cherry -v 2>/dev/null); \
[ -d F/.git ] && (cd F; git -c core.fileMode=false status -uno -s) \
' \
@tbnorth
tbnorth / httpcp.py
Last active December 7, 2018 21:07
GET and put (POST) files over HTTP(S)
"""
Quick hack to get read/write access to remote files over port 80 or 443.
WebDAV is probably a better solution, if available.
When it starts, it prints a random key, which must be included in request
headers as X-RandKey. For chrome, you can do this with an extension like
ModHeader. For curl, use
curl -H "X-RandKey: 0.05982546114570.452987805101" ...
@tbnorth
tbnorth / git_repo_diff.sh
Last active May 12, 2016 18:43
Show commits that exist in one git repository but not another
# color version
read -p "Path to other repo.: " OTHER; echo; \
diff --new-line-format "%c'\033'[31m- %L" \
--old-line-format "%c'\033'[32m+ %L" --unchanged-line-format '' \
<(git log --all --format='%H' | sort) \
<(git -C "$OTHER" log --all --format='%H' | sort); echo -e '\033[0m'
# no color version
@tbnorth
tbnorth / read_reveal_md.py
Last active May 11, 2016 18:22
reveal.js HTML slides markdown importer for Leo
# reveal.js markdown uses two blank lines to separate stacked slides
# and three to separate side by side slides. This snippet reads
# such markdown into the appropriate tree layout in the Leo
# editor (http://leoeditor.com/)
lines = p.b.strip().split('\n')
while lines[0][0] == '@':
del lines[0]
nd = p.insertAfter()