Skip to content

Instantly share code, notes, and snippets.

View nathants's full-sized avatar

nathants nathants

View GitHub Profile
@nathants
nathants / color.py
Last active October 5, 2022 00:20
colorize input text
#!/usr/bin/env python3
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
"""
colorize parts of lines to arbitrary colors
usage: echo a b c | color 0:green 1:red 2:blue
@nathants
nathants / tail_tinysnitch_logs.sh
Last active August 20, 2022 08:05
a small and colorful format to tail tinysnitch logs
# tinysnitch: https://github.com/nathants/tinysnitch
# color: https://gist.github.com/nathants/336bc5e501ad174aeeb7986f2b0633e4
# count-last: https://gist.github.com/nathants/f6d3f2cd4147af102c65a69a7e729b53
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
# colorful snitch logs
tail -f /tmp/tinysnitch.log \
@nathants
nathants / grid.py
Last active August 20, 2022 08:04
live visualizing simple data as a grid
#!/usr/bin/env python3
# type: ignore
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
import argh
import json
import sys
@nathants
nathants / plot.py
Last active August 20, 2022 08:05
>> echo 1 1 1 2 2 2 4 4 4 4 8 8 8 8 16 16 16 16 | tr ' ' '\n' | plot
#!/usr/bin/env python3
# type: ignore
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
import math
import argh # pip install argh
import sys
@nathants
nathants / matplot.py
Last active January 18, 2024 06:47
>> echo timestamp=2021-10-07T00:38:00Z a=160.2 b=20.8 c=1 | matplot
#!/usr/bin/env python3
# type: ignore
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
import matplotlib as mpl
from matplotlib import pyplot # pip install matplotlib
import argh # pip install argh
#!/usr/bin/env python3
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
import blessed # pip install blessed
import sys
term = blessed.Terminal()
last = None
@nathants
nathants / yaml.py
Last active January 29, 2024 03:56
#!/usr/bin/env python3
# flake8: noqa
# type: ignore
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
"""
convert json/yaml to colorized yaml for easy reading
@nathants
nathants / disable_keyboard.sh
Last active August 20, 2022 08:05
after some work minutes, lock the screen requiring password entry, and disable the keyboard for a few minutes, delaying possibility of unlock and forcing break minutes
#!/bin/bash
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
set -euo pipefail
seconds=$1
#!/usr/bin/env python3
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
"""
send and receive files via https over lan. run on laptop, read qrcode url with phone.
"""
! for thinkpad laptop and thinkpad usb keyboard
! capslock -> alt
clear Lock
keycode 0x42 = Meta_L
! ctrl/alt/command -> ctrl/alt/ctrl
clear control
clear mod1
clear mod4