@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<?> handleJakartaValidations(MethodArgumentNotValidException e, HttpServletRequest r) {
Map errors = new HashMap<>();
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
package main |
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
CREATE TABLE cliente ( | |
id INT NOT NULL, | |
nome VARCHAR(45) NOT NULL, | |
sobrenome VARCHAR(45) NOT NULL, | |
idade INT NOT NULL, | |
PRIMARY KEY (id) | |
); | |
CREATE TABLE carro ( | |
id INT NOT NULL, |
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
-- schema do banco | |
CREATE TABLE IF NOT EXISTS departamento ( | |
id INT NOT NULL AUTO_INCREMENT, | |
nome VARCHAR(128) NOT NULL, | |
sobrenome VARCHAR(128) NOT NULL, | |
localizacao VARCHAR(255) NOT NULL, | |
PRIMARY KEY(id) | |
); |
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
CREATE TABLE cliente ( | |
dni VARCHAR(255), | |
nome VARCHAR(255), | |
sobrenome VARCHAR(255), | |
id BIGINT UNIQUE NOT NULL AUTO_INCREMENT, | |
PRIMARY KEY (id) | |
); | |
INSERT INTO cliente (dni,nome,sobrenome) | |
VALUES |
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<profiles version="13"> | |
<profile kind="CodeFormatterProfile" name="GoogleStyle" version="13"> | |
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/> | |
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/> | |
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/> | |
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/> | |
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> | |
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/> | |
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/> |
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
@Override | |
public Vehicle update(Long id, UpdateVehicleDto dto) { | |
Vehicle vehicleToUpdate = findById(id).orElse(null); | |
if (vehicleToUpdate == null) { | |
return null; | |
} | |
// method 1 | |
if (dto.getBrand() != null) vehicleToUpdate.setBrand(dto.getBrand()); | |
if (dto.getModel() != null) vehicleToUpdate.setModel(dto.getModel()); | |
if (dto.getRegistration() != null) vehicleToUpdate.setRegistration(dto.getRegistration()); |
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
// ==UserScript== | |
// @name automute youtube on video ads | |
// @namespace http://tampermonkey.net/ | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.youtube.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com | |
// @grant none | |
// ==/UserScript== |
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
server { | |
listen 8080 default_server; | |
listen [::]:8080 default_server; | |
server_name _; | |
proxy_set_header True-Client-IP $http_true_client_ip; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header Host $host; |
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
/* | |
Como funcionam as estratégias de "encadeamento" e "endereçamento aberto"? | |
> No encadeamento, as colisões são resolvidas armazenando múltiplos itens no mesmo índice (geralmente com uma lista ligada). No endereçamento aberto, novas posições são exploradas dentro do array para armazenar o item colidido. | |
Endereçamento aberto (Open Addressing) é uma técnica utilizada em estruturas de dados como tabelas de dispersão (hash tables) para lidar com colisões. | |
Quando ocorre uma colisão, ou seja, dois elementos diferentes têm o mesmo endereço de hash, o endereçamento aberto procura novas posições dentro do array para armazenar o item colidido. |