jq '
walk(
if type == "string" or type == "number" or type == "boolean"
then ""
else .
end
)
' secrets.json
Monday, September 15, 2025
Sanitize JSON: Blank Out Sensitive Content
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
}
To support it inside screen:
pbcopy () {
if [ -n "$TMUX" ] && command -v tmux > /dev/null 2>&1; then
tmux load-buffer -w -;
elif [ -n "$STY" ]; then
# inside GNU screen: wrap OSC 52 in screen's DCS passthrough (\eP ... \e\\)
# so screen forwards it to the outer terminal instead of swallowing it
printf '\033P\033]52;c;%s\007\033\\' "$(base64 | tr -d '\n')";
else
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, February 20, 2025
Friday, January 24, 2025
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.02. 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.exe3. Delete the root folder containing the executable to remove that python version:
PS > Remove-Item -Path "C:\Program Files\Python312" -Recurse -Force4. 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)
Friday, October 18, 2024
Find content of all relevant files in a project respecting .gitignore
fd -t f -0 | xargs -0 -I {} sh -c 'echo "File: {}"; cat {}'
Tuesday, August 06, 2024
Remove server header in IIS to stop disclosing running version(s)
Set attribute removeServerHeader="true" in web.config node configuration."system.webServer".security.requestFiltering.
Thursday, July 18, 2024
When the clock on MAC OSX goes off
To sync your macOS clock and prevent it from drifting after sleep cycles, follow these steps:
- Run this command to sync time:
- Remove the current time settings:
- After reboot, turn on "Set time and date automatically" in System Settings > Date & Time. This should ensure your clock remains accurate.
- Run this command to sync time:
sudo sntp -sS time.apple.com- Go to System Settings > Date & Time and turn off "Set time and date automatically."
- Remove the current time settings:
sudo rm /var/db/timed/com.apple.timed.plist- Reboot the Mac.
- After reboot, turn on "Set time and date automatically" in System Settings > Date & Time. This should ensure your clock remains accurate.
Monday, May 27, 2024
Sunday, April 14, 2024
Minimal kubernetes pods log shipping with fluent-bit
I just released how to ship kubernetes cluster pod logs to Amazon Simple Storage Service (AWS S3) using fluent-bit. Platform engineers should do their best to keep cloud independence. This setup will work for Azure AKS, Google GKE and Amazon EKS. The choice for S3 is just a pick and not a preference. Google Cloud Storage (GCS) or Azure Blob Storage (ABS) will do the job as well (just check fluent-bit docs and adapt the code below for your choice).
Wednesday, March 20, 2024
Sunday, March 10, 2024
Securely sharing the content of your MAC OSX ~/.zshrc and other profile configuration files
cat ~/.zshrc | sed -E "s/(export[^=]*=).*/\1***/"
Friday, February 23, 2024
Tuesday, February 20, 2024
Monday, February 19, 2024
My .vimrc for google (and amazon) cloud shell
Will keep here what I am using in google (and amazon) cloud shells.
" keep all defaults source $VIMRUNTIME/defaults.vim " disable visual mode when using mouse set mouse=c " keep all defaults source $VIMRUNTIME/defaults.vim " disable visual mode when using mouse set mouse=c " paste as copied set paste " indentation set tabstop=2 " Set the width of a tab character to 2 spaces set shiftwidth=2 " Set the number of spaces to use for each step of (auto)indent set expandtab " Convert tabs to spaces set softtabstop=2 " Set the number of spaces a Tab counts for while performing editing operations, like inserting a Tab or using BS set smartindent " Enable smart indenting for new lines
Sharing code without using git
Sometimes you do not want to commit to git for security reasons and yet you want to test your code somewhere else.
Run the below from your local copy of the git repository:
Run the below from your local copy of the git repository:
rsync -av --exclude-from='.gitignore' --exclude='.git' . ~/Downloads/my-repo-copy cd ~/Downloads/my-repo-copy zip -r ~/Downloads/my-repo-copy.zip ./Copy the content to the remote location and run the below:
mkdir my-repo mv my-repo-copy.zip my-repo/ cd my-repo unzip my-repo-copy.zip rm my-repo-copy.zip
Wednesday, September 06, 2023
Tuesday, May 30, 2023
Copy MongoDB indexes from one host database to another
Do it in one environment. Use it in all the rest:
Subscribe to:
Posts (Atom)