Skip to content

Instantly share code, notes, and snippets.

View duducp's full-sized avatar

Carlos Eduardo duducp

View GitHub Profile
@duducp
duducp / 0-index.md
Last active February 26, 2025 23:42
English

Índice (Index)

  1. Tempos Verbais (Verb Tenses)

Expressions

in order to ("a fim de" ou "para")

É usada para indicar o propósito ou a intenção de uma ação. Geralmente, é seguida por um verbo no infinitivo.

@duducp
duducp / transaction.py
Created October 18, 2024 01:33
Transaction Atomic Django (Sync and Async)
from types import TracebackType
from asgiref.sync import sync_to_async
from django.db.transaction import Atomic as _Atomic
__all__ = ["AtomicAsync", "Atomic"]
class AtomicAsync(_Atomic):
"""
@duducp
duducp / semaphore_python.py
Last active October 13, 2022 17:01
Semáforo em Python
from threading import Semaphore, Thread
from time import sleep
# Número máximo de threads a serem execultadas simultaneamente
control_threads = Semaphore(5)
def view_log(number: int):
with control_threads:
print(f'O número atual é: {number}')
@duducp
duducp / using_with.py
Last active January 30, 2020 16:59
With Test Example
class Test:
def __init__(self):
print("Executando construtor da classe.")
def __enter__(self):
print("Iniciando escopo da função.")
return self
def __exit__(self, exc_type, exc_val, exc_tb):
print("Finalizando escopo da função.")
@duducp
duducp / read_file_with.py
Last active January 30, 2020 16:59
Read File With
with open('test.txt', 'r') as file:
print(file.read())
@duducp
duducp / switch_case_with_if_else.py
Last active October 17, 2023 02:57
Switch case with if/else
def function1():
print("Case 1 selected")
def function2():
print("Case 2 selected")
def default():
print("Value default")
def switch(case):
@duducp
duducp / switch_case_dict_functions.py
Last active October 17, 2023 02:57
Switch case using dict functions
def function1():
print("Case 1 selected")
def function2():
print("Case 2 selected")
def default():
print("Value default")
if __name__ == "__main__":
@duducp
duducp / redis_docker-compose.yml
Last active January 30, 2020 17:01
Redis Docker Compose
version: '3'
services:
redis-compose:
image: redis
command: redis-server --requirepass SUASENHA --appendonly yes
hostname: redis
ports:
- "6379:6379"
volumes:
@duducp
duducp / docker_redis.ps1
Last active January 30, 2020 17:01
Docker Redis With Commands
docker pull redis
docker run --name redis -p 6379:6379 -i -t -d redis
@duducp
duducp / pgadmin_postgresql_docker-compose.yml
Last active January 30, 2020 17:03
Docker Compose for pgAdmin
version: '3'
services:
postgres-compose:
image: postgres
environment:
POSTGRES_USERNAME: "postgres"
POSTGRES_PASSWORD: "postgres"
ports:
- "5432:5432"