Given a table...
CREATE TABLE foo (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
...
);
def quebra_periodo(begin:str, end:str, freq: str = 'mensal') -> List[Tuple]: | |
dt_start = datetime.datetime.strptime(begin, '%Y-%m-%d') | |
dt_end = datetime.datetime.strptime(end, '%Y-%m-%d') | |
one_day = datetime.timedelta(1) | |
start_dates = [dt_start] | |
end_dates = [] | |
today = dt_start | |
while today <= dt_end: |
# Configuration for Alacritty, the GPU enhanced terminal emulator. | |
# Import additional configuration files | |
# | |
# Imports are loaded in order, skipping all missing files, with the importing | |
# file being loaded last. If a field is already present in a previous import, it | |
# will be replaced. | |
# | |
# All imports must either be absolute paths starting with `/`, or paths relative | |
# to the user's home directory starting with `~/`. |
import sqlparse | |
def pquery(qs): | |
# Pretty Print Queryset querys | |
statement = str(qs.query) | |
print sqlparse.format(statement, reindent=True, keyword_case='upper') |
import cProfile | |
import pstats | |
import io | |
def profile(fnc): | |
def inner(*arg, **kwargs): | |
pr = cProfile.Profile() | |
pr.enable() | |
retval = fnc(*arg, **kwargs) |
# Configurar a exibição de dados no pandas (vale para o pdb/ipdb/web_pdb) | |
import pandas as pd | |
pd.set_option('display.max_rows', 500) | |
pd.set_option('display.max_columns', 500) | |
pd.set_option('display.width', 1000) | |
# o mesmo para numpy | |
import numpy | |
numpy.set_printoptions(linewidth=160) |
# Testando o problema de Monty Hall | |
# https://pt.wikipedia.org/wiki/Problema_de_Monty_Hall | |
# | |
# Nesta simulação, o jogador sempre troca a porta depois que o Monty Hall abre uma | |
# O resultado sempre fica em torno de 65~67% Execute várias vezes para ver... | |
# | |
import random | |
A='A' | |
B='B' |
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
python_3_email_with_attachment.py | |
Created by Robert Dempsey on 12/6/14. | |
Copyright (c) 2014 Robert Dempsey. Use at your own peril. | |
This script works with Python 3.x | |
NOTE: replace values in ALL CAPS with your own values |
Given a table...
CREATE TABLE foo (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
...
);
This gist contains lists of modules available in
in AWS Lambda.
It also contains the code to run in Lambda to generate these lists. In addition there
is a less_versbose
module in the code that you can call to get a list of the top
level modules installed and the version of those modules (if they contain a version
""" | |
Esta classe compatibiliza o campo ArrayField do Postgres para rodar na migration do SQLite. | |
Django 1.9 | |
O correto é você testar em um banco de dados Postgres mesmo, mas para ambientes onde você execute os dois | |
testes, ajuda. | |
""" | |
from django.contrib.postgres.fields import ArrayField | |
class CustomArrayField(ArrayField): |