Skip to content

Instantly share code, notes, and snippets.

View goabonga's full-sized avatar

Chris goabonga

View GitHub Profile
@goabonga
goabonga / dict.py
Created July 27, 2025 16:32
MyList and MyDict
from collections.abc import MutableMapping
from typing import Iterator
from .user import MyUser
TKey = str
class MyDict(MutableMapping[TKey, MyUser]):
def __init__(self) -> None:
self._store: dict[TKey, MyUser] = {}
@goabonga
goabonga / response.md
Last active July 24, 2025 09:01
En Python moderne (3.10+), est-il préférable d'utiliser from __future__ import annotations plutôt que if TYPE_CHECKING pour éviter les imports circulaires dans les annotations de type ?

En Python moderne (3.10+), from __future__ import annotations et if TYPE_CHECKING ne s'opposent pas, ils sont complémentaires et souvent utilisés ensemble dans du code idiomatique.

from future import annotations

  • Rend toutes les annotations paresseuses (lazy) en les stockant sous forme de chaînes de caractères, évitant ainsi l'évaluation immédiate des types au moment du parsing du module.
  • Cela évite les imports circulaires dans les annotations uniquement, sans avoir besoin de quotes autour des noms de classes.
  • Utile pour tous les usages d’annotations, même en dehors des blocs conditionnels.

if TYPE_CHECKING

  • Ce bloc permet d’importer des modules ou classes uniquement pour les outils de typage statique (mypy, pyright, etc.), sans exécuter l'import à runtime.
@goabonga
goabonga / README.md
Last active August 2, 2025 21:50
Pong in SQL — Animated ASCII Pong using MySQL, Events, and phpMyAdmin

🕹️ Pong in SQL

A fully functional ASCII Pong game implemented entirely in MySQL, using:

  • A pong_state table to track ball and paddle positions
  • Stored procedures to simulate ball physics and paddle AI
  • A MySQL EVENT to update the game state every second
  • A visual render_full_frame_lines() procedure that returns a styled ASCII frame
  • A Docker setup with MySQL + phpMyAdmin for testing
@goabonga
goabonga / emails.txt
Last active July 8, 2025 16:49
Is your login route vulnerable to user enumeration?
notest
test
admin
john
chris
jane.doe
support
contact
@goabonga
goabonga / main.py
Created May 31, 2025 11:22
Automated Python Project Generator with Self-Healing Tests
import subprocess
import time
import re
import shutil
from pathlib import Path
import openai
from slugify import slugify
api_key = "sk-proj-..." # Replace with your OpenAI API key
qrlink() {
local url="$1"
qrencode -s 10 -o /tmp/qrcode.png "$url" && xdg-open /tmp/qrcode.png
}
@goabonga
goabonga / test_timing_attack.py
Created April 27, 2025 11:21
full-stack-fastapi-template authentication endpoint leaks user enumeration via response differences
import time
import requests
def measure_response_time(url: str, username: str, password: str) -> float:
data = {
"username": username,
"password": password
}
start = time.perf_counter()
response = requests.post(url, data=data)
@goabonga
goabonga / bootstrap_gcp_infra.sh
Created April 25, 2025 00:24
GCP Infra Bootstrap with Cookiecutter and Terragrunt Generator
#!/usr/bin/env bash
echo "build infra"
tmpfile=$(mktemp)
cat <<EOF > "$tmpfile"
default_context:
full_name: "Chris"
email: "goabonga@pm.me"
github_username: "goabonga"
@goabonga
goabonga / main.py
Last active April 14, 2025 12:07
LLM Query System with ChromaDB and Sentence Transformers
import json
import sys
import re
from typing import Any, Dict, List, Mapping, Union
import numpy as np
import httpx
from chromadb.api.client import Client
from chromadb.api.models.Collection import Collection
from sentence_transformers import SentenceTransformer
@goabonga
goabonga / cities.py
Last active April 10, 2025 16:23
chromadb & ollama & embedings & cities1000
import os
import zipfile
import httpx
import asyncio
import chromadb
from tqdm import tqdm
CHROMA_DIR = "./chroma"
EXTRACT_DIR = "./data"
ZIP_PATH = "cities1000.zip"