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 main import calculate_simple_interest_investment, calculate_compound_interest_investment | |
def test_calculate_compound_interest_investment_when_principal_amount_is_zero(): | |
principal_amount = 0.0 | |
rate = 0.07 | |
time = 2 | |
expected_interest = 0 | |
interest = calculate_compound_interest_investment( |
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
def calculate_compound_interest_investment( | |
principal_amount: float, rate: float, time: int | |
) -> float: | |
""" | |
Returns the compound interest an accrued amount that includes | |
principal plus interest. | |
:param principal_amount: float | |
:param rate: float | |
:param time: int |
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
-- An audit history is important on most tables. Provide an audit trigger that logs to | |
-- a dedicated audit table for the major relations. | |
-- | |
-- This file should be generic and not depend on application roles or structures, | |
-- as it's being listed here: | |
-- | |
-- https://wiki.postgresql.org/wiki/Audit_trigger_91plus | |
-- | |
-- This trigger was originally based on | |
-- http://wiki.postgresql.org/wiki/Audit_trigger |
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 re import findall, M, I | |
import os.path | |
def parse_queries(): | |
""" | |
Irá parsear um arquivo .sql com as queries de SELECT necessárias | |
e irá retornar um dicionário contendo o nome da query no arquivo, como chave | |
e a query especificamente como valor. | |
""" |
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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
func dumpMap(space string, m map[string]interface{}) { | |
for k, v := range m { | |
if mv, ok := v.(map[string]interface{}); ok { |
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
conn = psycopg2.connect("user='eliassoares' host='127.0.0.1' password='mysecretpassword'") | |
cur = conn.cursor() | |
cur.execute('SELECT datname FROM pg_database WHERE datistemplate = false;') | |
rows = cur.fetchall() | |
print(rows) |
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° Configura os nós: | |
-Configurando o nó para busca: | |
CREATE INDEX ON :Person(personID); | |
CREATE INDEX ON :Person(name); | |
-Configurando a chave: | |
CREATE CONSTRAINT ON (p:Person) ASSERT p.personID IS UNIQUE; | |
#Um INDEX não pode ser usado como chave, caso o tenha feito, usa-se: | |
DROP INDEX ON :Person(name); | |
para retirar o index. |
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
# Backup | |
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | |
# Restore | |
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE | |
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
# When you're sure of the format, it's much quicker to explicitly convert your dates than use `parse_dates` | |
# Makes sense; was just surprised by the time difference. | |
import pandas as pd | |
from datetime import datetime | |
to_datetime = lambda d: datetime.strptime(d, '%m/%d/%Y %H:%M') | |
%time trips = pd.read_csv('data/divvy/Divvy_Trips_2013.csv', parse_dates=['starttime', 'stoptime']) | |
# CPU times: user 1min 29s, sys: 331 ms, total: 1min 29s | |
# Wall time: 1min 30s |
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
#Version: 2.0 | |
import urllib | |
import json | |
#Coloque as informações sobre suas comprar aqui: | |
compras = [ |
NewerOlder