Monday, September 15, 2025

Sanitize JSON: Blank Out Sensitive Content

jq '
  walk(
    if type == "string" or type == "number" or type == "boolean"
    then "" 
    else . 
    end
  )
' secrets.json

Thursday, August 28, 2025

Extract a portion of a log file based on the starting timestamp

If there are multiple matches, this command takes the last start and the first end, which may not be what you want. If that is acceptable, consider anchoring one line before the start and one after the end to ensure the full range is captured:
sed -n '/^2025-08-28 01:00:04,114/,/^2025-08-28 01:00:08,178/p' /tmp/test.log

Wednesday, August 27, 2025

pbcopy from linux shell

Working across Mac, Windows, and Linux via SSH? Ever wished you could pbcopy from within a remote SSH session? Add this "one-liner" to your ~/.bashrc or ~/.profile:
pbcopy() {
 printf "\033]52;c;%s\033\\" "$(cat | base64 -w0)"
}
If you use tmux you will need a bit more:
pbcopy() {
  if [ -n "$TMUX" ] && command -v tmux >/dev/null 2>&1; then
    # Read stdin into tmux buffer and also copy to system clipboard via OSC 52
    tmux load-buffer -w -
  else
    # Direct OSC 52 for non-tmux shells
    # Portable base64: avoid line wraps
    printf '\033]52;c;%s\007' "$(base64 | tr -d '\n')"
  fi
}

Monday, August 25, 2025

Sanitize your json config before sharing it

jq 'def scrub:
      if type == "object"
      then with_entries(.value |= scrub)
      else empty
      end;
    scrub' config.json

Thursday, December 19, 2024

Uninstalling python from windows where no uninstaller can be found

1. Find out the exact version installed for the package you want to remove. In this case 3.12:
PS > py --list
 -V:3.13 *        Python 3.13 (64-bit)
 -V:3.12          Python 3.12 (64-bit)
PS > py -3.12 --version
Python 3.12.0
2. Find out where the executable is for that version, in this case it is in C:\Program Files\Python312\python.exe:
PS > py -3.12 -c "import sys; print(sys.executable)"
C:\Program Files\Python312\python.exe
3. Delete the root folder containing the executable to remove that python version:
PS > Remove-Item -Path "C:\Program Files\Python312" -Recurse -Force
4. Remove registry entries for that installation (you should find 3.12 as an entry in our case in one or the two places below):
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\
and/or
Computer\HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\
5. Confirm the only version installed is the one you expect. In our case we expect only 3.13:
PS > py --list
 -V:3.13 *        Python 3.13 (64-bit)

Followers