Skip to content

Instantly share code, notes, and snippets.

View leofernandesmo's full-sized avatar

Leo Fernandes leofernandesmo

View GitHub Profile
@leofernandesmo
leofernandesmo / ControleEstoque.java
Created April 3, 2024 21:38
Depure o código abaixo, localize o erro e faça as correções
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class ControleEstoque {
private static Map<String, Integer> estoque = new HashMap<>();
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
@leofernandesmo
leofernandesmo / atualizacao.ejs
Last active April 2, 2024 18:21
Código de exemplo de um CRUD simples com Node, Express, EJS e MySQL
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Atualizar Usuário</title>
</head>
<body>
<h1>Atualizar Usuário</h1>
<form action="/usuarios/atualizar/<%= usuario.id %>" method="POST">
@leofernandesmo
leofernandesmo / ExemploThread.java
Created February 8, 2024 00:42
Exemplo simples de Threads em Java
public class ExemploThread {
private static int sharedVariable = 0;
public static void main(String[] args) {
MyThread t1 = new MyThread();
MyThread t2 = new MyThread();
t1.val = 1;
t2.val = 2;
t1.start();
t2.start();
@leofernandesmo
leofernandesmo / Exemplo02.java
Last active February 8, 2024 00:13
Exemplo de código que mostra passagem de parâmetro em Java.
/*
Exemplo de código que mostra passagem de parâmetro em Java.
https://www.devmedia.com.br/entenda-que-os-parametros-sao-passados-por-valor-e-nao-por-referencia/5015
*/
class Exemplo02 {
int var1;
String nome;
public static void main(String args[]) {
Exemplo02 e = new Exemplo02();
e.nome = "Maria";
package br.edu.ifal.pweb01;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
package br.ufal.edge;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
const list = [
{
id: 1,
titulo: 'Livro do desassossego',
autor: 'Fernando Pessoa',
isbn: 8535908498,
resumo: 'O narrador principal (mas não exclusivo) das centenas de fragmentos que compõem este livro é o "semi-heterônimo" Bernardo Soares. Ajudante de guarda-livros na cidade de Lisboa...',
ano_lancamento: 2006
},
{
class StackClass {
private int[] stackRef;
private int maxLen, topIndex;
public StackClass() { // Um construtor
stackRef = new int [100];
maxLen = 99;
topIndex = -1;
}
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Manipulando o DOM</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<!-- fonte -->
import json
def escreve(newData):
with open('person.json', 'r') as json_file:
oldData = json.load(json_file)
with open('person.json', 'w') as json_file:
oldData.append(newData)
jsoned_data = json.dumps(oldData, indent=True)
json_file.write(jsoned_data)