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, yaml | |
def load_yaml(file_path: str, context: dict = None): | |
def string_constructor(loader, node): | |
t = string.Template(node.value) | |
value = t.substitute(context) | |
return value | |
l = yaml.SafeLoader | |
l.add_constructor('tag:yaml.org,2002:str', string_constructor) |
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 sys | |
# List comprehension | |
list_comprehension = [i for i in range(10_000_000)] | |
print(f"List comprehension memory: {sys.getsizeof(list_comprehension) / (1024 * 1024)} MB") | |
# Yield generator | |
def generator(): | |
for i in range(10_000_000): | |
yield i |
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 pyspark.sql import SparkSession | |
spark = ( | |
SparkSession | |
.builder | |
.appName("spark_parameterized_queries") | |
.getOrCreate() | |
) | |
##### Criando dois datasets de teste ##### |
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
apiVersion: v2 | |
name: datahub-prerequisites | |
description: A Helm chart for packages that Datahub depends on | |
type: application | |
# This is the chart version. This version number should be incremented each time you make changes | |
# to the chart and its templates, including the app version. | |
version: 0.0.14 | |
dependencies: | |
- name: elasticsearch | |
version: 7.17.3 |
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 configPossibilities = [ [ 1 ], [ 1, 2 ], [ 1, 2, 3, 4 ] ] | |
const configPossibilities2 = { | |
ID_LINHA: [ 1 ], | |
ID_IMPLEMENTO: [ 1 , 2 ], | |
ID_COMPOSICAO: [ 1 , 2 , 3 , 4 ] | |
} | |
const desiredResult = [ | |
[1, 1, 1 ], |
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
// Somando valores de arrays (.reduce) | |
const numeros2 = [1, 2, 3] | |
function soma (x, y) { | |
return x + y | |
} | |
const somaDosNumeros2 = numeros2.reduce(soma) | |
console.log(somaDosNumeros2) // 6 |
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
// Objeto Inicial | |
const refeicaoArray = [ | |
{ id: 1, descricao: 'Café da Manhã', calorias: 420 }, | |
{ id: 2, descricao: 'Almoço', calorias: 580 } | |
] | |
// Removendo item no array refeicoes (.filter) | |
function filtro (refeicao) { | |
if (refeicao.id === 2) { | |
return true |
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
// array inicial | |
const refeicaoArray = [ | |
{ id: 1, descricao: 'Café da Manhã', calorias: 420 }, | |
{ id: 2, descricao: 'Almoço', calorias: 580 } | |
] | |
const novaRefeicao = { | |
id: 3, | |
descricao: 'Café da Tarde', | |
calorias: 280 |
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
// Atualizando item no array (.map) | |
const numeros = [1, 2, 3] | |
function dobrar (num) { | |
return num * 2 | |
} | |
const dobrarEs6 = num => num *2 | |
const numerosVezesDois = numeros.map(dobrarEs6) |
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
// Arrays Iniciais | |
const refeicaoArray = [ | |
{ id: 1, descricao: 'Café da Manhã', calorias: 420 }, | |
{ id: 2, descricao: 'Almoço', calorias: 580 } | |
] | |
const novaRefeicao = { | |
id: 3, | |
descricao: 'Café da Tarde', | |
calorias: 280 |
NewerOlder