Skip to content

Instantly share code, notes, and snippets.

View GeroZayas's full-sized avatar
🔵
Learning the Norse God

Gero Zayas GeroZayas

🔵
Learning the Norse God
View GitHub Profile
@GeroZayas
GeroZayas / traceback_to_see_who_calls_line.py
Created March 23, 2026 08:33
Use traceback to see who call a line
import traceback
def objetivo():
stack = traceback.extract_stack()
caller = stack[-2] # quien llamó a esta función
print(f"{caller.filename}:{caller.lineno} -> {caller.name}")
def a():
objetivo()
@GeroZayas
GeroZayas / debug_tracer.py
Last active May 22, 2026 10:34
A script to trace function calls in Python (for Debugging Purposes) and it saves locally to trace.log
# USE IT LIKE THIS in main.py, for example:
"""
_TRACE_CALLS = install_call_tracing(app_root=ROOT, source_root=ROOT.parent)
"""
from __future__ import annotations
import atexit
import os
import sys
import time
@GeroZayas
GeroZayas / py-one-liner-reduce-image-size.md
Created June 8, 2026 05:41
Python One Liner to Reduce Size in KB of images

Do this:

uvx --from pillow python -c "from PIL import Image; Image.open('README-assets/ad-example-1.png').save('README-assets/ad-example-1-better.webp', quality=75)"
@GeroZayas
GeroZayas / chatgpt-download-markdown-copy-and-paste-in-console.js
Last active June 21, 2026 11:19
chatgpt-download-markdown-copy-and-paste-in-console.js
// Generated from src/extraction-engine.js by scripts/build-exporters.js.
// Edit the source engine or this build script, then run npm run build.
(() => {
'use strict';
(function initChatExporterEngine(root, factory) {
const engine = factory();
if (root) {
@GeroZayas
GeroZayas / functions_connections_docs_and_diagram.py
Created June 23, 2026 11:47
Create a MD document (and Mermaid diagram) of all the Python functions and their connections in a py file
"""
analyse_functions.py
--------------------
Statically analyses a Python file and outputs:
- A Markdown report of all functions (with signatures, docstrings, line numbers)
- A Mermaid call-graph diagram (who calls whom)
Usage:
python analyse_functions.py <target_file.py> [--out report.md]
"""
@GeroZayas
GeroZayas / act_alias_python_venv_activation.sh
Created June 26, 2026 15:28
Put this in ~/.zshrc to activate the venv in Python with the "act" alias
unalias act 2>/dev/null
# Activate virtual environments
act() {
for d in .venv env venv .env; do
if [ -d "$d" ]; then
if [ -f "$d/bin/activate" ]; then
source "$d/bin/activate"
echo "Virtual Environment activated: $d"
return