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 / generate_image_gemini_3.py
Created December 28, 2025 09:40
Generate Image with Gemini 3 model
from google import genai
client = genai.Client(api_key=GEMINI_API_KEY)
def generate_image(prompt: str) -> None:
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents=prompt,
config=genai.types.GenerateContentConfig(
response_modalities=["IMAGE"],
@GeroZayas
GeroZayas / bug_buster.py
Created December 27, 2025 11:51
Bug Buster Script - Runs Black, Bandit and Flake8 on all Python files of the given dir
import os
import subprocess
from rich import print
print(
"""
==== 🏆 WELCOME TO BUG BUSTER ====
🧑‍💻 Necessary modules to be installed: `black`, `bandit` and `flake8`
from fastapi.templating import Jinja2Templates
templates = Jinja2Templates(directory="templates")
@app.get("/items/{id}", response_class=HTMLResponse)
async def read_item(request: Request, id: str):
return templates.TemplateResponse(
request=request, name="item.html", context={"id": id}
from urllib.parse import urlparse
from urllib.robotparser import RobotFileParser
# Look at this cool function to respect robots.txt
USER_AGENT = (
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
)
@GeroZayas
GeroZayas / print_all_methods_by_type.py
Last active August 19, 2025 06:32
Function to print all the methods of a module by type in json format
import json
def get_methods_by_type(module):
all_elements = [ele for ele in dir(module)]
ele_dict = {
"public":[],
"private":[],
"dunder":[],
}
for ele in all_elements:
# Stupid simple idea but very useful
# if some condition is met, then we return new value, or charged old value
# Else, we return the (unchanged) original value
def change_if_new(new_thing, old_thing):
if new_thing:
return new_thing
# else
return old_thing