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
Select * from produtos | |
join empresa on empresa.codempresa = produtos.codempresa | |
where empresa.codempresa = :pCodEmpresa |
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
...Projeto para ensino e aprendizagem de Django |
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 | |
>>> datetime.datetime.now() | |
datetime.datetime(2017, 9, 22, 9, 34, 11, 593128) | |
>>> datetime.datetime.now().timestamp() | |
1506069255.443273 | |
>>> datetime.datetime.now().timestamp() * 1000000000 | |
1.506069262145749e+18 | |
>>> nano_date = datetime.datetime.now().timestamp() * 1000000000 | |
>>> int(nano_date) | |
1506069271086237952 |
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
# T1 - Exceptions | |
In general keep exceptions in views, not in models. | |
Put exceptions in models just when very necessary like to make process atomic or multiples tasks, | |
even in this case think if is not better split the method in multiple methos and treat exception in each method | |
# T2 - Always try to name the relationships | |
# T3 - Concentrate business logic into models methods and Managers | |
# T4 - Always help_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
1 - ############ built-in zip function for i, j in zip(list1, list2) | |
2 - ############ built-in enumerate function for i,j in enumerate(lista) i = indice j = element | |
3 - ############ accessing a global variable a = 10 def foo(): global a a = 10 | |
4 - ########### range performance | |
Python 2.7 |
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
# 1 - Ideal DRF View | |
from rest_framework import status | |
from rest_framework.decorators import detail_route | |
from rest_framework.response import Response | |
import logging | |
def do_log(e): | |
logger = logging.getLogger('django') | |
time = datetime.datetime.now() |
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
# 1 - Find file terminal | |
find ~/ -type f -name "generate_interval.py" | |
# 2 - Checking HD size | |
df -H | |
# 3 - Tailing a log in realtime | |
tailor -f file.log | |
# 4 - If else param script bash |
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
# 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
# 1 - Promisses | |
p.then(onFulfilled[, onRejected]); | |
p.then(function(value) { | |
// fulfillment | |
}, function(reason) { | |
// rejection | |
}); | |
# 2 - Find an object in a array |
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
my_variable not myVariable or even MyVariable | |
MyClass |
OlderNewer