Skip to content

Instantly share code, notes, and snippets.

View rponte's full-sized avatar
🏠
Working from home

Rafael Ponte rponte

🏠
Working from home
View GitHub Profile
@rponte
rponte / messaging-and-eventing-platforms.md
Created January 21, 2022 18:09 — forked from clemensv/messaging-and-eventing-platforms.md
Elements of Messaging and Eventing Platforms
title
Elements of Messaging and Eventing Platforms

This document provides a brief overview of the essential elements of a messaging and eventing platform and how they relate to each other.

Message and Event Broker Categories

@rponte
rponte / CacheStore.java
Last active July 18, 2022 13:16
Simple CacheStore using Guava Cache
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
@Component
public class CacheStore {
@rponte
rponte / parametros-jvm-heap-metaspace-gc.md
Last active June 4, 2022 01:40
Conhecendo e setando parâmetros da JVM

Conhecendo e setando parâmetros da JVM

Material de suporte rápido para conhecer e setar parâmetros de JVM mais comuns relacionados a propriedades da JVM, configuração de frameworks e libs, aplicação e tuning de memória heap e metaspace, além da definição do algoritimo de GC e algumas configurações para troubleshooting.

Introdução

Todos os comandos aqui são executados via linha de comando, mas podem ser definidos na sua IDE, variável de ambiente (JAVA_OPTS) ou no seu servidor de integração contínua (CI).

Rodando uma aplicação (jar):

@rponte
rponte / CustomExceptionHandler.java
Created October 7, 2021 12:35
Spring Boot: custom and simple exception handler (using the default payload generated by Spring)
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest;
import java.time.LocalDateTime;
import java.util.Map;
@rponte
rponte / modern-unix.md
Created August 3, 2021 18:54
Modern Unix: ferramentas de linha de comando uteis
@rponte
rponte / Proposal.kt
Last active April 10, 2022 12:43
JPA and Hibernate: best way to mapping a primary key as UUID in MySQL 8.x
@Entity
class Proposal(
val name: String,
//
@Column(columnDefinition = "binary(16)") // this works but uses a MySQL's specific type
val customerId: UUID
) {
@Id
@GeneratedValue
@rponte
rponte / .wslconfig
Created June 10, 2021 16:36
WSL 2 Config
[wsl2]
memory=4GB
swap=16GB
localhostFowarding=true
@rponte
rponte / notes-on-rate-limiting-strategies-techniques.md
Last active March 20, 2024 09:44
Notes on Gloogle Cloud Rate-limiting strategies and techniques

Gloogle Cloud: Rate-limiting strategies and techniques

Sever-side

  • Even in the cases where the rate limiting is implemented entirely on the server side, the client should be engineered to react appropriately.
  • Decisions about failing open or failing closed are mostly relevant on the server side, but knowledge of what retry techniques the clients use on a failed request might influence your decisions made about server behavior.
  • In HTTP services, the most common way that services signal that they are applying rate limiting is by returning a 429 status code in the HTTP response. A 429 response can provide additional details about why the limit is applied (for example, a freemium user has a lower quota, or the system is undergoing maintenance).
  • Build your system with robust error handling in case some part of your rate-limiting strategy fails, and understand what users of your service will receive in those situations. [...] U