Skip to content

Instantly share code, notes, and snippets.

@ricardocuellar
ricardocuellar / n8n_python_section6_urgent_medium_words.py
Created December 16, 2025 18:53
n8n - Python - section 6 - urgent - medium words
urgent_words = ["urgente", "asap", "hoy", "inmediato",
"último aviso", "venc", "vencimiento"]
medium_words = ["mañana", "esta semana", "pendiente", "recordatorio"]
@ricardocuellar
ricardocuellar / n8n_python_section6_triggers.py
Created December 16, 2025 18:51
n8n - Python - section 6 - triggers
triggers = [
"por favor", "favor", "responde", "responder", "confirmar", "confirma",
"envía", "enviar", "adjunta", "adjuntar", "pagar", "pago",
"revisar", "revisa", "agendar", "agenda", "asistir", "asiste",
"firma", "firmar", "aprobar", "aprueba"
]
@ricardocuellar
ricardocuellar / analyze_words.py
Created December 9, 2025 22:45
Python + n8n - Section 4 - Analyze words (black list)
SPANISH_STOPWORDS = {
"de", "la", "que", "el", "en", "y", "a", "los", "del", "se", "las",
"por", "un", "para", "con", "no", "una", "su", "al", "lo", "como",
"más", "mas", "o", "pero", "sus", "le", "ya", "si", "porque", "cuando",
"muy", "sin", "sobre", "también", "tambien", "me", "hasta", "hay",
"donde", "han", "quien", "entre", "está", "esta", "ser", "son",
}
def tokenize(text: str) -> List[str]:
@ricardocuellar
ricardocuellar / app.jsx
Last active November 3, 2025 17:06
Sección 15 - CorsDemo - App.jsx
import { useState } from "react";
function App() {
const [data, setData] = useState(null);
const [error, setError] = useState(null);
const fetchData = async () => {
setData(null);
setError(null);
@ricardocuellar
ricardocuellar / seeds_data.py
Created October 21, 2025 09:29
FastAPI - Sección 14 - Seeds - Categories, tags y users
CATEGORIES = [
{"name": "Python", "slug": "python"},
{"name": "FastAPI", "slug": "fastapi"},
{"name": "SQLAlchemy", "slug": "sqlalchemy"},
{"name": "Django", "slug": "django"},
{"name": "Flask", "slug": "flask"},
{"name": "Javascript", "slug": "javascript"},
{"name": "Golang", "slug": "golang"},
{"name": "Laravel", "slug": "laravel"},
]
@ricardocuellar
ricardocuellar / category_router.py
Created October 21, 2025 03:20
FastAPI - Sección 13 - Category - Router
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from app.api.v1.categories.repository import CategoryRepository
from app.core.db import get_db
from app.api.v1.categories.schemas import CategoryCreate, CategoryUpdate, CategoryPublic
router = APIRouter(prefix="/categories", tags=["categories"])
@router.get("", response_model=list[CategoryPublic])
@ricardocuellar
ricardocuellar / category_repository.py
Last active November 6, 2025 19:29
FastAPI - Sección 13 - Category - Repository
from __future__ import annotations
from typing import Iterable, Sequence
from collections.abc import Iterable as IterableABC
from sqlalchemy import select, func
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import Session
from app.models.category import CategoryORM
class _ChunkCounter:
def __init__(self, f):
self._f = f
self.calls = 0
self.sizes = []
def read(self, n=-1):
data = self._f.read(n)
if data:
self.calls += 1
self.sizes.append(len(data))
@ricardocuellar
ricardocuellar / request_test.py
Created September 30, 2025 21:15
Script para probar funciones síncronas y asíncronas
import asyncio
import httpx
import time
URL = "http://127.0.0.1:8000/posts/async"
async def hit(t, client: httpx.AsyncClient):
start = time.perf_counter()
r = await client.get(URL, params={"t": t})
@ricardocuellar
ricardocuellar / fakeuser.json
Created September 27, 2025 15:12
FaskeUser sección 8 - FastAPI
FAKE_USERS = {
"[email protected]": {"email": "[email protected]", "username": "ricardo", "password": "secret123"},
"[email protected]": {"email": "[email protected]", "username": "alumno", "password": "123456"},
}