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
>>> from datetime import date | |
>>> with patch('mymodule.date') as mock_date: | |
... mock_date.today.return_value = date(2010, 10, 8) | |
... mock_date.side_effect = lambda *args, **kw: date(*args, **kw) | |
... | |
... assert mymodule.date.today() == date(2010, 10, 8) | |
... assert mymodule.date(2009, 6, 8) == date(2009, 6, 8) | |
... |
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 pytz | |
from django.utils import timezone | |
local_tz = pytz.timezone('America/Sao_Paulo') | |
datetime_now = timezone.now() | |
localized_date = datetime_now.astimezone(local_tz) | |
date_now = localized_date.strftime('%d%m%Y') # DDMMAAAA | |
time_now = localized_date.strftime('%H%M%S') # HHMMSS |
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
- Nginx -> Camada em cima da aplicação | |
para que nem todas as requisições sejam | |
servidas pela aplicação | |
APLICAÇÃO <----> NGINX <----> INTERNET | |
<----- USUÁRIO XPTO | |
-----> USUÁRIO XPTO | |
APLICAÇÃO <---- NGINX | |
-----> USUÁRIO XPTO |
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
- Nginx -> Camada em cima da aplicação | |
para que nem todas as requisições sejam | |
servidas pela aplicação | |
APLICAÇÃO <----> NGINX <----> INTERNET | |
<----- USUÁRIO XPTO | |
-----> USUÁRIO XPTO | |
APLICAÇÃO <---- NGINX | |
-----> USUÁRIO XPTO |
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
# ..... ommited lines | |
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': True, | |
'filters': { | |
'require_debug_false': { | |
'()': 'django.utils.log.RequireDebugFalse' | |
}, | |
'disable_on_test': { |
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
#!/bin/bash | |
VOLUME=$(echo $VOLUME) | |
PORT=$(echo $PORT) | |
NAME=$(echo $NAME) | |
POSTGRES_PASSWORD=$(echo $POSTGRES_PASSWORD) | |
VERSION="latest" | |
DATE=$(date +"%d%m%Y-%H%M%S") | |
PARAM="$1" | |
if [ "$PARAM" == '-h' ]; then |
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 string | |
import random | |
def id_generator(size=10, chars=None): | |
""" | |
Generate a random string with 10 characters. | |
This function have more explain here: | |
http://stackoverflow.com/questions/2257441/ |
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 re | |
def count_words(word, sentence): | |
"""Count the number of occurrences of a word in the sentence""" | |
match = re.compile(word) | |
return len(match.findall(sentence)) |
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 | |
""" | |
Some parts of this code were extracted from Django framework | |
https://github.com/django/django/blob/master/django/utils/crypto.py | |
""" | |
random = random.SystemRandom() | |
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 -*- | |
import json | |
from urllib import urlopen | |
import time | |
DEBUG = True | |
TEMPO = 5 | |