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 os | |
import time | |
from celery import Celery | |
app = Celery('tasks', broker=os.getenv('BROKER_URL', 'redis://localhost/0')) | |
@app.task | |
def envia_email(): | |
... |
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 os | |
import time | |
from celery import Celery | |
app = Celery('tasks', broker=os.getenv('BROKER_URL', 'redis://localhost/0')) | |
@app.task | |
def envia_email(): | |
lista_de_usuarios = [ |
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
lucaspolo@notebook:~$ hyperfine --warmup 3 python fibonacci.py | |
Benchmark #1: python | |
Time (mean ± σ): 44.2 ms ± 1.8 ms [User: 49.1 ms, System: 8.8 ms] | |
Range (min … max): 41.2 ms … 51.0 ms 67 runs | |
Benchmark #2: fibonacci.py | |
Error: Command terminated with non-zero exit code. Use the '-i'/'--ignore-failure' option if you want to ignore this. Alternatively, use the '--show-output' option to debug what went wrong. |
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
lucaspolo@notebook:~$ hyperfine python fibonacci.py | |
Benchmark #1: python | |
Time (mean ± σ): 44.9 ms ± 4.5 ms [User: 50.8 ms, System: 8.2 ms] | |
Range (min … max): 42.1 ms … 71.3 ms 41 runs | |
Warning: The first benchmarking run for this command was significantly slower than the rest (71.3 ms). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run. | |
Benchmark #2: fibonacci.py | |
Error: Command terminated with non-zero exit code. Use the '-i'/'--ignore-failure' option if you want to ignore this. Alternatively, use the '--show-output' option to debug what went wrong. | |
lucaspolo@notebook:~$ |
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
object CasamentoDePadroes extends App { | |
// Pattern matching apicado a recuperação de valores de uma lista | |
val lista = List(1,2,3,4,5) | |
val primeiro :: resto = lista | |
println(primeiro) | |
println(resto) | |
// Utilizando guardas como filtro | |
val pares = for { |
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
object CasamentoDePadroes extends App { | |
case class Pessoa(nome: String, idade: Int); | |
var pessoa = Pessoa("Linus", 51); | |
var mensagem = pessoa match { | |
case Pessoa("Lucas", _) => "Olá programador Lucas" | |
case Pessoa(nome, idade) if idade > 50 => s"Olá Sr(a) $nome" | |
case Pessoa(nome, _) => s"Olá $nome" | |
case _: Pessoa => "Olá desconhecido" |
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
object CasamentoDePadroes extends App { | |
case class Pessoa(nome: String, idade: Int); | |
var pessoa = Pessoa("Linus", 51); | |
pessoa match { | |
case Pessoa("Lucas", _) => println("Olá programador Lucas") | |
case Pessoa(nome, idade) if idade > 50 => println(s"Olá Sr(a) $nome") | |
case Pessoa(nome, _) => println(s"Olá $nome") | |
case _: Pessoa => println("Olá desconhecido") |
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
object CasamentoDePadroes extends App { | |
var x: Any = "Desconhecido porém string"; | |
x match { | |
case "oi" => println("Hello") | |
case "Scala" => println("Hello Scala") | |
case value: String => println(s"This is a string: $value") | |
case _ => println("A strange object") | |
} | |
} |
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 com.company; | |
public class Main { | |
public enum Veiculos { | |
BICICLETA(0), MOTO(1), CARRO(2), ONIBUS(4), CAMINHAO(3); | |
private final float tarifa; | |
Veiculos(float tarifa) { | |
this.tarifa = tarifa; |
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 com.company; | |
public class Main { | |
public enum Veiculos { | |
BICICLETA, MOTO, CARRO, ONIBUS, CAMINHAO | |
} | |
public static void main(String[] args) { | |
var veiculo = Veiculos.CAMINHAO; | |
float valorPedagio = switch (veiculo) { |