This file contains hidden or 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
| class Unset: | |
| """ | |
| This class represent an unset instance. | |
| """ | |
| unset = Unset() | |
| def first_or_default(sequence, condition=unset, default=None): |
This file contains hidden or 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 | |
| from django.conf import settings | |
| from django.utils import timezone | |
| from django.utils.translation import ugettext_lazy as _ | |
| from rest_framework import serializers, compat | |
| class TimestampField(serializers.Field): | |
| default_error_messages = { |
This file contains hidden or 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 itertools | |
| import random | |
| def _cnpj_dv(digits): | |
| """ | |
| Returns the calculated verification digit. | |
| """ | |
| mul = list(itertools.chain(*[range(len(digits) - 7, 1, -1), range(9, 1, -1)])) | |
| return ((sum([a * b for a, b in zip(digits, mul)]) * 10) % 11) % 10 |
This file contains hidden or 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 random | |
| def _cpf_dv(digits): | |
| """ | |
| Returns the calculated verification digit. | |
| """ | |
| mod = sum(a * b for a, b in zip(digits, range(len(digits) + 1, 1, -1))) % 11 | |
| return 0 if mod < 2 else 11 - mod |
This file contains hidden or 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
| """ | |
| Cep query by brazilian correios web services. | |
| requirements: | |
| - zeep==3.4.0 | |
| """ | |
| from zeep import Client, exceptions | |
This file contains hidden or 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
| ## Função para o calculo do coeficiente de Pearson | |
| ## e do intervalo de confiança de Pearson. | |
| pearsonr_ci <- function(x, y, alpha = 0.05) { | |
| r <- cor(x, y) | |
| p <- cor.test(x, y)$p.value | |
| r_z <- tanh(r) | |
| se <- 1 / sqrt(length(x) - 3) | |
| z <- qnorm(1 - alpha / 2) | |
| lo_z <- r_z - z * se | |
| hi_z <- r_z + z * se |
This file contains hidden or 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
| """ | |
| @author: arkanister; | |
| """ | |
| def cache_it(method=None, name=None): | |
| """ | |
| Decorator to cache a function result in the class. | |
| Using this is expected that the function can only be called once by instance, | |
| which means that the second time the function is called, the cached result |
This file contains hidden or 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
| # coding: utf-8 | |
| """ | |
| This is an interface for simplify the django queryset handler | |
| when we need to apply a filter on it. | |
| Usage: | |
| >>> from core import models | |
| >>> from filters import FilterableQuerysetMixin, SimpleFilter, SimpleSearchFilter | |
| >>> |
This file contains hidden or 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
| const express = require('express'); | |
| const { MyModel } = require('../models/index'); | |
| const { paginate } = require('./pagination'); | |
| const router = express.Router(); | |
| router.get('/', async (request, response) => { |
This file contains hidden or 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
| def singleton(kls): | |
| """ | |
| A decorator to grant that only a single class | |
| instance will be created. | |
| Usage: | |
| >>> @singleton | |
| >>> class MyCustomClass: | |
| >>> ... do something ... | |
| >>> |
NewerOlder