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 / 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
@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 / 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 / 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 / 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 / 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 / bigquery_client_from_service_account_file.py
Created February 24, 2026 12:50
Create a BigQuery client with a service account key file
from google.cloud import bigquery
from google.oauth2 import service_account
# TODO(developer): Set key_path to the path to the service account key
# file.
# key_path = "path/to/service_account.json"
credentials = service_account.Credentials.from_service_account_file(
key_path,
scopes=["https://www.googleapis.com/auth/cloud-platform"],
@GeroZayas
GeroZayas / fetch_and_pull_all_git_branches.sh
Created January 6, 2026 08:31
Fetch and Pull All Git Branches
# https://stackoverflow.com/questions/10312521/how-do-i-fetch-all-git-branches
git branch -r \
| grep -v '\->' \
| sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" \
| while read remote; do \
git branch --track "${remote#origin/}" "$remote"; \
done
git fetch --all
git pull --all
@GeroZayas
GeroZayas / activate_env_shortcut.sh
Created January 3, 2026 11:33
ACT Alias to activate virtual env easily (Python)
# Activates a Python virtual environment by searching for common directory names.
function act {
for venv_dir in .venv venv env .env; do
if [ -f "$venv_dir/bin/activate" ]; then
. "$venv_dir/bin/activate"
echo "Virtual environment activated: '$venv_dir'"
return 0
fi
done
@GeroZayas
GeroZayas / raylib-zig-compile.sh
Created January 2, 2026 09:00
Compile RAYLIB App with Zig (C99)
zig cc -std=c99 main.c \
-lraylib -lGL -lm -lpthread -ldl -lrt -lX11 \
-o app