Não use UUID
como PK nas tabelas do seu banco de dados.
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 dateutil.relativedelta import relativedelta | |
from datetime import datetime | |
WEEKLY = relativedelta(weeks=1) | |
BIWEEKLY = relativedelta(weeks=2) | |
MONTHLY = relativedelta(months=1) | |
YEARLY = relativedelta(years=1) | |
def get_next_date( |
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 pickle | |
import codecs | |
data = {"coisa": "novidade", "nome": "valder", "estado": "SC"} | |
pickled = codecs.encode(pickle.dumps(data), "base64").decode() | |
print(pickled) | |
unpickled = pickle.loads(codecs.decode(pickled.encode(), "base64")) | |
print(unpickled) |
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 pytest | |
basket = ["apple", "orange", "apple", "pear", "orange", "banana"] | |
def subtract_set_list(total_items, item_to_remove): | |
return set(total_items) - set(item_to_remove) | |
@pytest.mark.parametrize( |
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 requests | |
from lxml.html import document_fromstring | |
from django.core.exceptions import ValidationError | |
from pprint import pprint | |
def _parse_wiki_data(content): | |
table = content.xpath("/html/body/div[3]/div[3]/div[5]/div[1]/table[1]").pop() | |
tz_name = table.xpath("//tr/td[2]/a//text()") | |
iana_times_utc_std = table.xpath("//tr/td[5]/a//text()") |
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 csv | |
import os | |
from dataclasses import dataclass | |
from typing import Generator | |
from bs4 import BeautifulSoup | |
FILENAME = "content.html" | |
DATABASE = "reviewers.csv" |
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
{ | |
// Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", |
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 os | |
import pytest | |
from flask_sqlalchemy import SQLAlchemy | |
from sqlalchemy_utils.functions import create_database, database_exists, drop_database | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
from main import app as main_app | |
from main.database import db as _db |
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 functools import wraps | |
import time | |
import logging | |
import random | |
logger = logging.getLogger(__name__) | |
def retry(exceptions, total_tries=4, initial_wait=0.5, backoff_factor=2, logger=None): | |
""" |
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 __future__ import absolute_import | |
from fabric import task | |
from fabric import Connection | |
import os | |
import io | |
import time | |
import glob | |
from pprint import pprint | |
from const import ENVS, RESTORE_BLACK_LIST, GROUP_ENVS, HIDE_OUTPUT |
NewerOlder