Skip to content

Instantly share code, notes, and snippets.

View tbnorth's full-sized avatar

Terry Brown tbnorth

View GitHub Profile
@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.
terrynbrown@gmail.com, 2019-10-03
"""
import sys
try:
from PyQt5 import QtWidgets, QtCore, Qt
from PyQt5.QtCore import Qt as QtConst
@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, terrynbrown@gmail.com, 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
terrynbrown@gmail.com, 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
terrynbrown@gmail.com, 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, terrynbrown@gmail.com, 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