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 / 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 / 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

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 / 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
@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 / 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 / fix_permissions.sh
Last active December 18, 2024 04:27
A script to securely apply custom file and directory permissions in a user's home directory, ensuring proper access levels for sensitive files, development tools, and shared directories.
#!/bin/bash
#########
##### THIS SCRIPT CAN FUCK YOUR COMPUTER, use it on your own responsibility
#########
# User directory path
read -p "Enter the username or press Enter to use the current user ($(logname)): " input_user
USER_HOME="/home/${input_user:-$(logname)}"
# Function to apply permissions
@brunos3d
brunos3d / .log
Created November 24, 2023 19:55
MF 8 errror after running next dev
bruno in next-mf-host-with-mandatory-libs/apps/remote on ξ‚  main [!?] took 8.3s
➜ npm run dev
> @demo/remote-app@0.1.0 dev
> next dev -p 3011
npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.
npm ERR! A complete log of this run can be found in: /home/bruno/.npm/_logs/2023-11-24T19_33_46_944Z-debug-0.log
@brunos3d
brunos3d / singleton-by-default-issue-example.jsx
Created October 30, 2023 15:15
An example of a common issue when using singleton: true for all shared packages
// remote
// uses xlib@10 as a singleton
import { generate } from 'xlib'; // hey, I'm a singleton and I will have only one global instance in memory =]
// the federated component
export default function GenerateSomethingButton() {
const content = generate();
return <h1>{content}</h1>;
}
@brunos3d
brunos3d / webpack.config.js
Last active October 24, 2023 22:36
How to proper infer Webpack types to webpack.config.js
const path = require('path');
/**
* @type {import('webpack').Configuration & { devServer?: import('webpack-dev-server').Configuration }}}
*/
module.exports = {
entry: './src/index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist'),