This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
ssh_client_ip=$(echo $SSH_CLIENT | awk '{print $1}') | |
w_json="$(w --pids $USER | jc --w)" | |
if [ -z "$w_json" ]; then | |
echo "error: 'w --pids | jc --w' didn't print anything!" | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env -iS PATH=/bin bash --noprofile --norc -eou pipefail | |
HOME=~ | |
# this will fubar your environment and maybe kill your shell if you source it | |
if (return 0 2>/dev/null); then | |
echo "do not source this script! execute it as its own process." | |
return 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Simon Leary | |
; 12/31/2021 | |
; when you go to cook, as you click on the item to cook, press scrollLock to keep cooking | |
; to stop press scrollLock again | |
#maxthreadsperhotkey 2 | |
ScrollLock:: | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def printable_length(x: str) -> int: | |
assert "\n" not in x and "\t" not in x, "no newlines or tabs allowed!" | |
# https://stackoverflow.com/q/14693701/12035739 | |
ansi_be_gone = re.compile(r"(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]") | |
return len(ansi_be_gone.sub("", x)) | |
def fmt_table(table: list[list]) -> list[str]: | |
""" | |
I would use tabulate but I don't want nonstandard imports |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def human_readable_size(size_in_bytes: int) -> str: | |
current_size = size_in_bytes | |
current_unit = "bytes" | |
if current_size == 0: | |
return "0 bytes" | |
for new_unit in ["KB", "MB", "GB", "TB", "PB"]: | |
new_size = current_size / 1000 | |
if new_size < 1: | |
return f"{current_size:.2f} {current_unit}" | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import json | |
import yaml | |
import shutil | |
import subprocess | |
from ansible.plugins.action import ActionBase | |
""" | |
fails if bitwarden is not unlocked |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"description": "ctrl+v -> ctrl+shift+option+v (only Stickies)", | |
"manipulators": [ | |
{ | |
"conditions": [ | |
{ | |
"bundle_identifiers": [ | |
"^com\\.apple\\.Stickies$" | |
], | |
"type": "frontmost_application_if" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _format_diff_strings(before: str, after: str) -> str: | |
before_lines = before.splitlines() | |
after_lines = after.splitlines() | |
diff = difflib.unified_diff(before_lines, after_lines, lineterm="") | |
output = "" | |
removed_lines = [] | |
added_lines = [] | |
def _format_added_removed(): | |
# given the current state of the `added` and `removed` variables, add text to the `output` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import threading | |
import subprocess | |
before = "" | |
after = "" | |
before_read_fd, before_write_fd = os.pipe() | |
after_read_fd, after_write_fd = os.pipe() | |
diff_proc = subprocess.Popen( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ansible module | |
import os | |
from ansible.module_utils.basic import AnsibleModule | |
def main(): | |
module = AnsibleModule( | |
argument_spec=dict( | |
paths=dict(type="list", required=True), | |
follow=dict(type="bool", default=True), | |
), |