Skip to content

Instantly share code, notes, and snippets.

View vedovelli's full-sized avatar
💭
🚀

Fábio Vedovelli vedovelli

💭
🚀
View GitHub Profile

Advanced JavaScript Concepts for Interview Preparation

Closures in JavaScript

A closure is a function paired with its surrounding lexical environment. It allows an inner function to retain access to the variables of an outer function even after the outer function has returned. Every time a function is created in JavaScript, a closure is formed at function creation time. This mechanism allows functions to “remember” and access their outer scope variables later on, enabling powerful patterns for state management and encapsulation.

Use Cases:

  • Data Privacy and State – maintaining a private counter or configuration that only your functions can access.
  • Function Factories and Currying – presetting arguments and returning new functions.
  • Caching and Memoization – storing previous results in a closure for performance.

Plano de Refatoração para o Código do AI Task Manager

Este documento descreve um plano abrangente para refatorar a aplicação AI Task Manager, seguindo as melhores práticas de engenharia de software. O plano aborda separação de responsabilidades, organização de código e manutenibilidade.

Instruções gerais

  • Módulos de servidor (.server.ts) jamais devem ser referenciados em arquivos de componentes React, a não ser que este arquivo seja um módulo de rota (vivendo em ~/app/routes)

1. Implementação da Camada de Serviço

@vedovelli
vedovelli / embeddings.sql
Created May 4, 2025 20:54
Instrução SQL criação tabela de embeddings
CREATE TABLE task_embeddings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
chunk_content TEXT NOT NULL,
task_id INTEGER NOT NULL REFERENCES tasks (id) ON DELETE CASCADE,
embedding F32_BLOB (3072) NOT NULL
);
CREATE INDEX task_embeddings_idx ON task_embeddings (libsql_vector_idx (embedding));
@vedovelli
vedovelli / mcp.json
Created April 16, 2025 16:44
SQLite MCP config
{
"mcpServers": {
"sqlite": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--network=host",
"-v",
@vedovelli
vedovelli / vedovelli-cursor-general-rules.mdc
Created March 25, 2025 21:08
Vedovelli Cursor Rules - general rules
You are a senior software engineer specialized in building highly-scalable and maintainable systems.
# Guidelines
When a file becomes too long, split it into smaller files. When a function becomes too long, split it into smaller functions.
After writing code, deeply reflect on the scalability and maintainability of the code. Produce a 1-2 paragraph analysis of the code change and based on your reflections - suggest potential improvements or next steps as needed.
DO NOT make big assumptions. When in doubt, ALWAYS ask before making an implementation.
# Planning
@vedovelli
vedovelli / gist:686ee125f2da67bc8adb9295f7fe36d9
Created January 22, 2025 11:15
cursorrules-laravel-react
You are an expert in Laravel, Inertia.js, React and Tailwind CSS, with a strong emphasis on Laravel and PHP best practices.Key Principles- Write concise, technical responses with accurate PHP examples.- Follow Laravel best practices and conventions.- Use object-oriented programming with a focus on SOLID principles.- Prefer iteration and modularization over duplication.- Use descriptive variable and method names.- Favor dependency injection and service containers.PHP and Laravel Core- Use PHP 8.3+ features when appropriate (e.g., typed properties, match expressions).- Follow PSR-12 coding standards.- Use strict typing: declare(strict_types=1);- Utilize Laravel's built-in features and helpers when possible.- Follow Laravel's directory structure and naming conventions.- Use lowercase with dashes for directories (e.g., app/Http/Controllers).- Implement proper error handling and logging: - Use Laravel's exception handling and logging features. - Create custom exceptions when necessary. - Use try-catch blocks for e
@vedovelli
vedovelli / Instructions.MD
Created January 7, 2025 09:29 — forked from diogogpinto/Instructions.MD
Best Laravel AI Prompt to use with Claude

I have been utilizing artificial intelligence to enhance and optimize my codebases. After evaluating various models, applications, and editors, I find the claude.ai interface with a Pro Account to be the most effective. Here’s the approach I’ve developed to achieve optimal results:

This gist contains a carefully crafted prompt and a script designed to convert your entire Laravel codebase (excluding the resources folder, which can be easily added if needed) into a TXT file with the following structure:

<File Start: ./path/filename.extension> Content of file <End File: ./path/filename.extension>

To implement this method:

# Salvar num arquivo ~/encode.sh, conceder direito de execução e
# executar desta forma (adaptar nomes de diretórios e arquivos para seu caso):
# $ ~/encode.sh ~/Video/bigFile.mp4 ~/Video/smallFile.mp4
ffmpeg -i "$1" -vcodec h264 -acodec aac "$2"
AxiosError: Request failed with status code 400
at settle (/Users/vedovelli/Shamrock/app-new/node_modules/axios/lib/core/settle.js:19:12)
at IncomingMessage.handleStreamEnd (/Users/vedovelli/Shamrock/app-new/node_modules/axios/lib/adapters/http.js:505:11)
at IncomingMessage.emit (node:events:539:35)
at endReadableNT (node:internal/streams/readable:1345:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ERR_BAD_REQUEST',
config: {
transitional: {
silentJSONParsing: true,
@vedovelli
vedovelli / db.server.ts
Created September 23, 2022 18:37
Remix Prisma DB server
// @ts-nocheck
import { PrismaClient } from '@prisma/client';
let db: PrismaClient;
declare global {
let __db: PrismaClient | undefined;
}
// this is needed because in development we don't want to restart