Skip to content

Instantly share code, notes, and snippets.

View AlTosterino's full-sized avatar
💻
Working as Python Developer

Daniel Różycki AlTosterino

💻
Working as Python Developer
View GitHub Profile
@AlTosterino
AlTosterino / flag_enum_descriptor.py
Created June 14, 2024 12:24
Access env variable in enum manner -- useful for feature flags based on environment variables
import os
from enum import Flag
from typing import Any
class EnvFlag: # Descriptor
def __init__(self, name: str) -> None:
self.name = name
@AlTosterino
AlTosterino / publish.sh
Created April 17, 2023 12:02
Publishing Python package using poetry (including test pypi)
# Publish to test.pypi.org
poetry build
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi pypi-TOKEN # Token from: https://test.pypi.org/manage/account/token/
poetry publish -r test-pypi
# Publish to pypi.org
poetry build
poetry config pypi-token.pypi pypi-XXXXXXXX # Token from: https://pypi.org/manage/account/token/
poetry publish
@AlTosterino
AlTosterino / settings.py
Created January 11, 2020 18:59
Hiding settings variables in Django debug page
import re
from django.views import debug
HIDDEN_DEFAULT = 'API|TOKEN|KEY|SECRET|PASS|'
debug.HIDDEN_SETTINGS = re.compile(
f'{HIDDEN_DEFAULT}ADDED_NAME|ANOTHER_ADDED_NAME',
flags=re.IGNORECASE)