Skip to content

Instantly share code, notes, and snippets.

View rochacbruno's full-sized avatar
🛠️
Working on Galaxy_ng and Dynaconf

Bruno Rocha rochacbruno

🛠️
Working on Galaxy_ng and Dynaconf
View GitHub Profile
@rochacbruno
rochacbruno / fastapi_session.py
Last active May 4, 2024 15:43
Session based cookie auth fastapi
from fastapi import Request, Depends, HTTPException, Response
from fastapi.responses import RedirectResponse
# This must be randomly generated
RANDON_SESSION_ID = "iskksioskassyidd"
# This must be a lookup on user database
USER_CORRECT = ("admin", "admin")
# This must be Redis, Memcached, SQLite, KV, etc...
@rochacbruno
rochacbruno / ACCESS_ELASTIC.md
Last active May 3, 2024 19:15
Docker-compose wait-to-start

When unsing docker compose you can have a problem with the order of dependent linked containers

The solution is to start a script which tries to access a service and waits until it gets ready before loading your program

@rochacbruno
rochacbruno / dummy-web-server.py
Created April 25, 2020 17:14 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python (Updated for Python 3.7)
Usage:
./dummy-web-server.py -h
./dummy-web-server.py -l localhost -p 8000
Send a GET request:
@rochacbruno
rochacbruno / main.py
Created October 12, 2021 17:37
better main for python
import atexit
import sys
def main(f):
if f.__module__ == "__main__":
atexit.register(f)
sys.modules['main'] = main # noqa
@rochacbruno
rochacbruno / gruvbox-dark.micro
Created April 21, 2022 18:49
Gruvbox Dark Theme for Micro Editor
color-link default "#ebdbb2,#1d2021"
color-link comment "#928374,#1d2021"
color-link symbol "#d79921,#1d2021"
color-link constant "#d3869b,#1d2021"
color-link constant.string "#b8bb26,#1d2021"
color-link constant.string.char "#b8bb26,#1d2021"
color-link identifier "#8ec07c,#1d2021"
color-link statement "#fb4934,#1d2021"
color-link preproc "#fb4934,235"
color-link type "#fb4934,#1d2021"
@rochacbruno
rochacbruno / send_email.py
Created March 25, 2020 22:11
Send Email Python Local SMTP postfix
"""
sudo systemcrl start sendmail
"""
import smtplib
from dynaconf import settings
def get_email_server():
"""Creates an instance of email server.
{
"workbench.startupEditor": "newUntitledFile",
"editor.fontSize": 14,
"editor.lineHeight": 1.8,
"javascript.suggest.autoImports": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.rulers": [80, 120],
"extensions.ignoreRecommendations": true,
"typescript.tsserver.log": "off",
"files.associations": {
@rochacbruno
rochacbruno / curses_detect.py
Created April 18, 2022 20:49
curses detect key pressed python - detect each types key
import curses
import os
def main(win):
win.nodelay(True)
key = ""
win.clear()
win.addstr("Detected key:")
@rochacbruno
rochacbruno / debug_ovi_env.md
Created February 25, 2024 13:25
Debug in OCI ENV

Debug in oci-env

Add the breakpoint to the task, then stop workers and start a worker manually.

$ s6-svc -d /var/run/service/pulpcore-worker\@1/
$ pulpcore-worker