Skip to content

Instantly share code, notes, and snippets.

View wellingtonpgp's full-sized avatar
🎯
Focusing

Wellington Pereira Gonçalves wellingtonpgp

🎯
Focusing
View GitHub Profile
private static String adicionarMascaraCnpfCpf(String valor) {
if (valor.length() == 14) {
Pattern pattern = Pattern.compile("(\\d{2})(\\d{3})(\\d{3})(\\d{4})(\\d{2})");
Matcher matcher = pattern.matcher(valor);
if (matcher.find()) {
return matcher.replaceAll("$1.$2.$3/$4-$5");
}
}
@wellingtonpgp
wellingtonpgp / Setup
Created December 20, 2021 20:00
setup
STS: https://github.com/spring-projects/sts4/wiki/Previous-Versions
GITHUB: https://desktop.github.com/
JAVA: https://jdk.java.net/java-se-ri/11
Lombook: https://projectlombok.org/download
Maven (Maven 3.6.2): https://maven.apache.org/download.cgi
Docker: https://docs.docker.com/desktop/windows/install/
----------------------------------------------------------
EclEmma Java Code Coverage
Ferramenta de cobertura de código.
DBeaver Ferramenta para conexão com banco de dados e edição de comandos SQL.
CREATE TABLE pessoa (
id serial NOT NULL,
nome text,
interesses jsonb,
informacoes_adicionais jsonb
);
INSERT INTO pessoa VALUES (1, 'João', '["futebol", "natação"]', '{"idade": 28, "time": "Chapecoense"}');
INSERT INTO pessoa VALUES (2, 'Maria', '["leitura", "programação", "dança"]', '{"idade": 39, "trabalha-com-programacao": true, "area": "back-end"}');
INSERT INTO pessoa VALUES (3, 'Ana', '["programação"]', '{"idade": 29, "trabalha-com-programacao": false, "area": "front-end", "areas-de-interesse": ["mobile", "design"]}');
[alias]
ci = commit
co = checkout
cm = checkout master
cb = checkout -b
st = status -sb
sf = show --name-only
lg = log --pretty=format:'%Cred%h%Creset %C(bold)%cr%Creset %Cgreen<%an>%Creset %s' --max-count=30
incoming = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' ..@{u})
outgoing = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' @{u}..)
public class Main {
public static void main(String[] args) {
double investimento = 5000.00;
double juros = 0.01;
double valorFinal = investimento * Math.pow(1 + juros, 12);
System.out.println(valorFinal);
}
}
Atalhos do IntelliJ
----------------------------------------------------------------------------------
templates:
----------------------------------------------------------------------------------
psvm - primeira letra - public static void main
sout - System.out.println
CONTROL + J - live template (usar "Save as live template" para criar novos)
----------------------------------------------------------------------------------
atalhos:
----------------------------------------------------------------------------------
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
public class _Stream {
public static void main(String[] args) {
List<Person> people = List.of(
new Person("Jonh", MALE),
new Person("Maria", FEMALE),
new Person("Aisha", FEMALE),
new Person("Alex", MALE),
new Person("Alice", FEMALE),
new Person("Bob", PREFER_NOT_TO_SAY)
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
public class Main {
public static void main(String[] args) {
List<Integer> lista = new ArrayList<>();