This file contains 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 threading | |
import asyncio | |
from queue import Queue as BlockingQueue | |
class TwoSidedQueue: | |
""" | |
Behaves like an `asyncio.Queue`, but `get` and `put` act on different ends. | |
""" | |
def __init__(self, queue_in, queue_out): |
This file contains 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 datetime as dt | |
import os | |
import motor | |
from beanie import Document, Indexed, PydanticObjectId, init_beanie, operators | |
from fastapi import FastAPI, Response, status | |
from pydantic import BaseModel | |
app = FastAPI() |
This file contains 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
# Pass the env-vars to MYCOMMAND | |
eval $(egrep -v '^#' .env | xargs) MYCOMMAND | |
# … or ... | |
# Export the vars in .env into your shell: | |
export $(egrep -v '^#' .env | xargs) | |
# set variables from .compose.env but don't override existing exported vars | |
eval "$(grep -v '^#' .compose.env | sed -E 's|^(.+)=(.*)$|export \1=${\1:-\2}|g' | xargs -L 1)" | |
# Load up .env |
This file contains 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
''' | |
Run the following commands (bc. gists don't allow directories) | |
pip install flask django dj-database-url psycopg2 | |
mkdir -p app/migrations | |
touch app/__init__.py app/migrations/__init__.py | |
mv models.py app/ | |
python manage.py makemigrations | |
python manage.py migrate |
This file contains 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
repos: | |
- repo: https://github.com/pre-commit/pre-commit-hooks | |
rev: v2.3.0 | |
hooks: | |
- id: check-yaml | |
- id: end-of-file-fixer | |
language_version: python3 | |
- id: trailing-whitespace | |
- id: debug-statements | |
language_version: python3 |
This file contains 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
Docs - LXD Helpful Docs: | |
https://www.stgraber.org/2016/03/30/lxd-2-0-image-management-512/ | |
https://www.flockport.com/flockport-first-look-at-lxd/ | |
http://insights.ubuntu.com/2016/03/14/the-lxd-2-0-story-prologue/ | |
Docs - Installation: | |
http://insights.ubuntu.com/2016/03/14/the-lxd-2-0-story-prologue/ | |
Docs - API: | |
https://linuxcontainers.org/lxd/getting-started-cli/ |
This file contains 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
.PHONY: clean-pyc clean-build docs clean | |
define BROWSER_PYSCRIPT | |
import os, webbrowser, sys | |
try: | |
from urllib import pathname2url | |
except: | |
from urllib.request import pathname2url | |
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) | |
endef |
This file contains 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
try: | |
from django.apps import apps | |
get_model = apps.get_model | |
except ImportError: | |
from django.db.models.loading import get_model |
This file contains 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
Para CPF | |
/^\d{3}\.\d{3}\.\d{3}\-\d{2}$/ | |
Para CNPJ | |
/^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/ | |
Para ambos ao mesmo tempo |
This file contains 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 django.core.files.uploadhandler import TemporaryFileUploadHandler | |
from django.core.files.base import File | |
from dropbox.client import DropboxClient | |
from dropbox.session import DropboxSession | |
from django.conf import settings | |
import os | |
class DropboxFileUploadHandler(TemporaryFileUploadHandler): | |
def __init__(self, *args, **kwargs): | |
super(DropboxFileUploadHandler, self).__init__(*args, **kwargs) |
NewerOlder