Skip to content

Instantly share code, notes, and snippets.

View brunos3d's full-sized avatar
:shipit:
hunting bytes 🏹

Bruno Silva brunos3d

:shipit:
hunting bytes 🏹
View GitHub Profile
@brunos3d
brunos3d / fix_all_repo_permissions.sh
Created December 18, 2024 04:39
This script recursively find git repos from the current folder and revert all files with permission changes
find . -type d -name ".git" -exec sh -c 'repo_dir=$(dirname "{}"); echo "Processando repositΓ³rio: $repo_dir"; cd "$repo_dir" && [ -d .git ] && git diff -p -R --no-ext-diff --no-color --diff-filter=M | grep -E "^(diff|(old|new) mode)" --color=never | git apply' \;
@brunos3d
brunos3d / readme.md
Last active January 27, 2025 18:33
fucking fix your ollama pull: permission denied error

Just replace PATH_TO_YOUR_MODELS with the absolute (or relative) path to your ollama models directory (usually /usr/share/ollama/.ollama/models/)

sudo find PATH_TO_YOUR_MODELS -type f -exec chown ollama:ollama {} \;
sudo find PATH_TO_YOUR_MODELS -type d -exec chown ollama:ollama {} \;
sudo find PATH_TO_YOUR_MODELS -type f -exec chmod 644 {} \;
sudo find PATH_TO_YOUR_MODELS -type d -exec chmod 755 {} \;

PS: kudos for Jeron_Baffom

@brunos3d
brunos3d / setup-nvm-with-husky-init.sh
Created March 5, 2025 08:38
How to fix vscode commit gui ".husky/pre-commit: line <number>: npx: command not found" error
mkdir -p ~/.config/husky && echo 'export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' > ~/.config/husky/init.sh

Simple example with a Pure CF Worker

import jwt from "jsonwebtoken"; // Use um bundler para incluir dependΓͺncias externas, se necessΓ‘rio.

addEventListener("fetch", (event) => {
  event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
@brunos3d
brunos3d / watch-nvidia-resources-usage.sh
Last active September 7, 2025 00:03
Continuously monitors NVIDIA GPU status every 3 seconds. This command uses watch to repeatedly run nvidia-smi, showing real-time information about GPU usage, memory consumption, and running processes. Useful for tracking GPU load during training or computation-heavy tasks.
watch -n 3 nvidia-smi
# You can use the one below if you love layout shifts
# nvidia-smi --loop 3
@brunos3d
brunos3d / claude-keepalive-fix.sh
Last active May 18, 2026 07:24
Claude Code socket keepalive fix β€” workaround for 'socket connection was closed unexpectedly' (issue #60133)
#!/usr/bin/env bash
# =============================================================================
# claude-keepalive-fix.sh
# Workaround for: "API Error: The socket connection was closed unexpectedly"
# GitHub issue: https://github.com/anthropics/claude-code/issues/60133
#
# This script applies OS-level TCP keepalive fixes that compensate for
# the Claude Code binary (Bun 1.3.14) not setting SO_KEEPALIVE on its
# TCP sockets, combined with Anthropic's server-side keepalive flags
# being set to 0ms via GrowthBook feature flags.
@brunos3d
brunos3d / .zshrc
Last active June 1, 2026 13:56
How to alias your npx npm node globally for MCPs to work
# your .bashrc or .zshrc shit...
npx() { command $HOME/.nvm/versions/node/$(node --version)/bin/npx "$@"; }
npm() { command $HOME/.nvm/versions/node/$(node --version)/bin/npm "$@"; }
node() { command $HOME/.nvm/versions/node/$(node --version)/bin/node "$@"; }
# save and run "source ~/.bashrc" or "source ~/.zshrc"