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 /
Last active January 5, 2024 19:19
StackSpot Action: action responsible for creating a Gitlab repository written in Python

Create Repository Gitlab

Creates a new repository (aka project) in a specific Gitlab group.

How to set up this project

This project was developed with Python v3.9, and it also uses Python's Virtualenv tool. So before working on this project we need to set up it.

Inside this project's folder, execute those commands to configure your environment:

rponte /
Last active January 9, 2024 14:37
Designing fault-tolerant and idempotent APIs with HTTP requests mapped to database's transactions at 1:1 model
* This Spring Boot controller was implemented as an example of a simple but robust idempotent REST API that
* leverages the ACID properties of a relational database.
public class CreateNewUserController {
private UserRepository repository;
rponte /
Last active February 7, 2024 02:36
JPA and Hibernate: Simple and Smart way of using PostgreSQL Advisory Locks with JPQL to prevent Lost Update anomaly
import org.hibernate.LockOptions;
import org.springframework.stereotype.Repository;
import javax.persistence.LockModeType;
import javax.persistence.QueryHint;
import javax.transaction.Transactional;
import java.util.Optional;
rponte /
Last active January 17, 2024 19:57
Spring Boot: example of base test class for testing Repositories
import base.SpringDataJpaIntegrationTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.transaction.TransactionSystemException;
rponte /
Last active May 9, 2024 14:41
AssertJ: Example of a jUnit5 test for asserting Bean Validation errors thrown by Spring Boot Repository
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.ISBN;
import java.util.Objects;
import static org.hibernate.validator.constraints.ISBN.Type.ISBN_13;
rponte /
Last active July 16, 2024 08:19
Git clone and SSL certificate problem: "unable to get local issuer certificate" and "server certificate verification failed. CAfile: none CRLfile: none"

The issue with SSL certificate

Just out of the blue, I started getting this issue ("server certificate verification failed. CAfile: none CRLfile: none") while trying to clone any Github repository on Linux (WSL2):

git clone
Cloning into 'preventing-lost-update-racecondition'...
fatal: unable to access '': server certificate verification failed. CAfile: none CRLfile: none

And also with Window 11 I got "SSL certificate problem: unable to get local issuer certificate":

rponte / simple_schema.sql
Created February 13, 2023 17:06
SQL and Postgres: simple schema that can be used as example
DROP TABLE customers, invoices, items;
CREATE TABLE customers (
CREATE TABLE invoices (
customer_id BIGINT REFERENCES customers (customer_id)
rponte /
Last active January 4, 2023 14:45

Scale breaks hardware. Speed breaks software. Speed at Scale breaks everything. -- via @adrianco & @jedberg

@adrianco: "Scale breaks hardware; speed breaks software; Speed At Scale breaks everything" (haha) #flowcon

Netflix: SPEED at SCALE = breaks EVERYTHING. #yow13

rponte / sql_generator.sql
Created December 7, 2022 19:04
PostgreSQL: generating sample data
INSERT INTO proposal (
id, address, created_at, "document", email, "name", salary, status, updated_at
md5(random()::text || clock_timestamp()::text)::uuid as id
,'Rua das Tabajaras, ' || floor(random() * 9999)::int as address
,localtimestamp as created_at
,left(md5(random()::text), 16) as "document"
,left(md5(random()::text), 6) || '' as email
,'Customer ' || left(md5(random()::text), 22) as "name"