Skip to content

Instantly share code, notes, and snippets.

Avatar

nathants nathants

View GitHub Profile
View .xmodmap
! 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
View serve_secure.py
#!/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.
"""
@nathants
nathants / disable_keyboard.sh
Last active Aug 20, 2022
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
View disable_keyboard.sh
#!/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
View yaml.py
#!/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
View count-last.py
#!/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 / matplot.py
Last active Aug 20, 2022
>> echo timestamp=2021-10-07T00:38:00Z a=160.2 b=20.8 c=1 | matplot
View matplot.py
#!/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
@nathants
nathants / plot.py
Last active Aug 20, 2022
>> echo 1 1 1 2 2 2 4 4 4 4 8 8 8 8 16 16 16 16 | tr ' ' '\n' | plot
View plot.py
#!/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 / grid.py
Last active Aug 20, 2022
live visualizing simple data as a grid
View grid.py
#!/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 / tail_tinysnitch_logs.sh
Last active Aug 20, 2022
a small and colorful format to tail tinysnitch logs
View tail_tinysnitch_logs.sh
# 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 / color.py
Last active Oct 5, 2022
colorize input text
View color.py
#!/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