This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import subprocess | |
| from rich import print | |
| print( | |
| """ | |
| ==== 🏆 WELCOME TO BUG BUSTER ==== | |
| 🧑💻 Necessary modules to be installed: `black`, `bandit` and `flake8` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
NewerOlder