Skip to content

Instantly share code, notes, and snippets.

@tacsio
tacsio / gist:d3d7ead929b9c3865a8557a25a27263c
Created April 13, 2023 23:57
VM Options Intelij console colors spring
-Dspring.output.ansi.enabled=ALWAYS
For Spring Applications use JAVA_TOOL_OPTIONS enviroment.
-XX:MaxRAMPercentage=75
sealed class Shape permits Circle, Rectangle {
double getArea() {
return switch(this) {
case Circle(double r) -> Math.PI * r * r;
case Rectangle(double h, double w) -> h * w;
}
}
}
logging:
pattern:
console: "%clr(%d{HH:mm:ss.SSS}){blue} %clr(---){cyan} %clr([%15.15t]){yellow} %clr(:){red} %clr(%m){magenta}%n"
# kubectl
cd /usr/local/bin/
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
cd -
#kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.14.0/kind-linux-amd64
chmod +x ./kind
@tacsio
tacsio / Main.java
Last active November 19, 2022 16:33
Carrossel das Cores | Hexagono Colorido
import java.util.*;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {
Peca[] pecas = new Peca[7];
pecas[0] = new Peca(1, new Cor[]{Cor.BRANCO, Cor.AZUL, Cor.VERDE, Cor.AMARELO, Cor.VERMELHO, Cor.LARANJA});
pecas[1] = new Peca(2, new Cor[]{Cor.BRANCO, Cor.VERDE, Cor.VERMELHO, Cor.AMARELO, Cor.AZUL, Cor.LARANJA});
pecas[2] = new Peca(3, new Cor[]{Cor.BRANCO, Cor.VERMELHO, Cor.AMARELO, Cor.LARANJA, Cor.VERDE, Cor.AZUL});
pecas[3] = new Peca(4, new Cor[]{Cor.BRANCO, Cor.AZUL, Cor.VERMELHO, Cor.LARANJA, Cor.VERDE, Cor.AMARELO});
@tacsio
tacsio / gist:59f8c9e7594bf989d23c07b457a4c9cf
Created November 17, 2022 11:09
Docker healthcheck status
docker inspect --format "{{json .State.Health }}" <container-name>
echo $CI_COMMIT_REF_NAME | awk -v t=$TAG -F _ '{ if (t == $AMBIENTE) { print "ambientex" } else { print tolower($1)}}'
@tacsio
tacsio / ListenerSample.java
Created August 21, 2022 15:34 — forked from timpamungkasudemy/ListenerSample.java
Sample Listener if you don't have __TypeID__ but have other header (for example : type)
public class ListenerSample {
// Adjust the header name if required, on @Header parameter
@RabbitListener(queues = "q.finance.invoice")
public void listenInvoiceCreated(@Payload String message, @Header(AmqpHeaders.DELIVERY_TAG) long tag,
@Header("type") String type) throws IOException {
if (StringUtils.equalsIgnoreCase(type, "invoice.paid")) {
log.info("Delegate to invoice paid handler");
} else if (StringUtils.equalsIgnoreCase(type, "invoice.created")) {
log.info("Delegate to invoice created handler");
@tacsio
tacsio / InvoiceListener.java
Created August 21, 2022 15:34 — forked from timpamungkasudemy/InvoiceListener.java
Sample Listener if you don't have __TypeID__ but have other header (for example : type)
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;
import com.course.finance.message.invoice.InvoiceCreatedMessage;
import com.course.finance.message.invoice.InvoicePaidMessage;