- Node v16.15.0 (LTS)
- NPM v8.5
- Docker Compose v1.29
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
-- todos os registros | |
SELECT * FROM tracks; | |
-- musica de maior duração | |
SELECT * FROM tracks ORDER BY duration DESC LIMIT 1; | |
-- mais antiga | |
SELECT * FROM tracks ORDER BY release_date ASC LIMIT 1; | |
-- musica maior nome | |
SELECT *, length(name) AS char_qtt FROM tracks ORDER BY LENGTH(name) DESC LIMIT 1; | |
SELECT *, MAX(LENGTH(name)) as maior_nome FROM tracks; | |
-- album menor nome |
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
-- todos os registros | |
-- musica de maior duração | |
-- mais antiga | |
-- musica maior nome | |
-- album menor nome |
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
// src/components/Posts.js | |
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
class Posts extends React.Component { | |
render(){ | |
const { posts } = this.props; | |
return ( |
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
enum PizzaFlavour { | |
CALABREZA = 'CALABREZA', | |
FRANGO_CATUPIRY = 'FRANGO_CATUPIRY', | |
NORDESTINA = 'NORDESTINA', | |
} | |
type PizzaFlavourKey = keyof typeof PizzaFlavour; | |
const pizzaFlavourPriceMap: Map<PizzaFlavourType, number> = new Map<PizzaFlavourKey, number>([ | |
[PizzaFlavour.CALABREZA, 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
export default class Person { | |
constructor( | |
protected readonly _name: string, | |
protected _birthDate: Date | |
) { | |
} | |
private calcAge(){ | |
const timeDiff = Math.abs(Date.now() - new Date(this._birthDate).getTime()); |
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
export default class Person { | |
public readonly age: number | |
constructor( | |
protected readonly _name: string, | |
protected readonly birthDate: Date | |
) { | |
this.age = this.calcAge(birthDate) | |
// idade só é calculada na construção, então se o birthDate mudar, a idade não será atualizada | |
// faz sentido caso o birthDate não deva ser mudado também |
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
// Vamos ver os seguintes topicos hoje | |
// arrays/tuplas, como tipar objetos, como usar aliases (que já vimos levemente ontem), classes, interfaces e generics | |
// vamos incrementar o exemplo da aula passada | |
// Vamos criar uma arquivo trybeClass.ts | |
let trybeClass: Object = {}; | |
// Já tipamos nossa aula. Mas qual o problema aqui? |
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
// ativa o modo estrito do JS | |
'use strict'; | |
// importa libs para a configuração do Sequelize | |
const fs = require('fs'); | |
const path = require('path'); | |
const Sequelize = require('sequelize'); | |
// recupera o nome do arquivo "index.js" | |
const basename = path.basename(__filename); |
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
function isValidCPF(cpf) { | |
// Validar se é String | |
if (typeof cpf !== 'string') return false | |
// Tirar formatação | |
cpf = cpf.replace(/[^\d]+/g, '') | |
// Validar se tem tamanho 11 ou se é uma sequência de digitos repetidos | |
if (cpf.length !== 11 || !!cpf.match(/(\d)\1{10}/)) return false | |