Skip to content

Instantly share code, notes, and snippets.

View carloscarucce's full-sized avatar

Carlos Alberto Bertholdo Carucce carloscarucce

View GitHub Profile
System:
Kernel: 6.17.0-22-generic arch: x86_64 bits: 64 compiler: gcc v: 13.3.0
Desktop: KDE Plasma v: 5.27.12 Distro: Kubuntu 24.04.4 LTS (Noble Numbat)
base: Ubuntu
Machine:
Type: Desktop Mobo: BIOSTAR model: H610MH D5 serial: <superuser required>
UEFI: American Megatrends LLC. v: 5.27 date: 09/12/2023
CPU:
Info: 20-core (8-mt/12-st) model: Intel Core i7-14700F bits: 64
type: MST AMCP arch: Raptor Lake rev: 1 cache: L1: 1.8 MiB L2: 28 MiB
@carloscarucce
carloscarucce / large-fileupload.js
Created March 12, 2026 18:55
Large file upload - Laravel
const CHUNK_SIZE = 10 * 1024 * 1024; // 10MB
async function uploadFile(file) {
const totalChunks = Math.ceil(file.size / CHUNK_SIZE);
const init = await fetch("/api/upload/init", {
method: "POST",
body: JSON.stringify({
filename: file.name,
size: file.size,
@carloscarucce
carloscarucce / MyComponent.jsx
Created November 21, 2025 12:48
Dynamic object state control for React Components
export default const MyComponent => () => {
const [formData, setFormData] = useState({});
const removeFormData = (path) => {
setFormData(prev => {
const newData = structuredClone(prev);
const keys = path.split(".");
let obj = newData;
@carloscarucce
carloscarucce / FBLoginButton.jsx
Last active October 22, 2025 15:21
Facebook login button for react
import React, {useCallback, useEffect, useState} from 'react';
const FBLoginButton = (
{
children = 'Login with Facebook',
appId = null,
graphApiVersion = 'v18.0',
configurationId = null,
onMessage = null,
onLoginCallback = null
@carloscarucce
carloscarucce / stream.php
Created October 13, 2025 12:15
Video stream script
<?php
// Path to your protected video file (outside web root recommended)
$videoFile = '/path/to/your/private/video.mp4';
// Check if the file exists
if (!file_exists($videoFile)) {
header("HTTP/1.1 404 Not Found");
exit;
}
@carloscarucce
carloscarucce / lotto.js
Created September 17, 2025 16:33
Generate random numbers for lotto games
function lotto(slots, max, min) {
slots = slots ?? 6;
max = max ?? 60;
min = min ?? 1;
const numbers = new Set();
while (numbers.size < slots) {
const num = Math.floor(Math.random() * max) + min;
numbers.add(num);
@carloscarucce
carloscarucce / slack_notify.yml
Created March 10, 2025 13:10
Slack bot release notes with github action
name: Publish Package
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
if: github.event.release.draft == false
@carloscarucce
carloscarucce / Dockerfile.publish
Created March 5, 2025 12:27
GithubAction para publicação de pacotes npm
# Usa a versão específica do Node que está no .nvmrc
FROM node:20.11.1-slim
WORKDIR /app
# Copia os arquivos
COPY . .
# Instala as dependências e builda o projeto
RUN yarn install --frozen-lockfile
@carloscarucce
carloscarucce / code-commit-rename-repos.sh
Created June 14, 2024 12:38
Renames all repositories in AWS code commit using awscli + jq
#!/bin/bash
PROFILE=my-profile
REGION=us-east-1
CODE_REPOSITORIES=$(aws codecommit list-repositories --no-paginate --profile=$PROFILE --region=$REGION |jq -r .repositories[].repositoryName)
for REPO in $CODE_REPOSITORIES; do
NEW_REPO_NAME="${REPO}_deprecated"
echo "- Reponame: ${REPO}; New name: ${NEW_REPO_NAME}"
@carloscarucce
carloscarucce / gh-add-repos-to-team.sh
Last active June 12, 2024 18:56 — forked from narze/gh-add-repos-to-team.sh
Add repos to team with gh
#!/bin/bash
PERMISSION="push" # Can be one of: pull, push, admin, maintain, triage
ORG="orgname"
TEAM_SLUG="your-team-slug"
# Get names with `gh repo list orgname`
# Change "limit" if necessary
gh repo list $ORG --limit 1000 --json name --json owner -q '.[] | "\(.owner.login)/\(.name)"' | while read -r REPO; do
echo "Repo: ${REPO}\r\n"