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 / incident-communication.md
Created March 26, 2026 23:47 — forked from hermogenes/incident-communication.md
Incident Communication Guide

Incident Communication Guide

For Small Teams

Purpose

This guide defines when to declare an incident, who is responsible for communication, and how to communicate externally during an incident.

It also defines how to act technically during an incident, emphasizing mitigation over fixes to reduce risk and downtime.

@rponte
rponte / export_dotenv_via_bash.sh
Created March 11, 2026 14:57
Python | Exporting .env variables via bash
export $(cat .env | xargs) && uv run main.py
@rponte
rponte / CreateChargeForCustomer.py
Last active May 15, 2025 01:07
Example of code in Python to create a charge for a specific customer
async def create_charge(charge: Charge, customer: Customer) -> None:
if not customer.is_active():
raise CustomerInactiveError("The customer is not active.")
if not charge.has_valid_amount():
raise InvalidChargeAmountError("The charge amount must be greater than zero.")
if not charge.has_valid_due_date():
raise InvalidDueDateError("The due date must be in the future.")
@rponte
rponte / 01-BookRequestTest.java
Last active February 22, 2025 02:19
Spring Boot Testing: How to test the Bean Validation annotations in domain and DTO objects without starting the whole Spring Boot Context
import org.assertj.core.groups.Tuple;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validator;
@rponte
rponte / spinlocks.md
Created December 12, 2024 13:51 — forked from tef/spinlocks.md

fair, fine grained, and deadlock free locking

first, a spin lock

you know what a spinlock is, right?

here's a spinlock:

@rponte
rponte / command-llm-server-ports.sh
Last active December 11, 2024 15:17
Shell Script: One-line command combined with LLM (AI) to evaluate servers that are running locally and their criticality
# Brilliant one-liner
(echo "PID COMMAND PORT USER"; lsof -i -P -n | grep LISTEN | awk '{print $2, $1, $9, $3}' | sort -u | head -n 50; echo;) \
| column -t \
| llm "what servers are running on my machine and do some of them look like they could be orphaned things I can shut down"
# Maybe even more brilliant one liner
(echo "PID COMMAND PORT USER"; lsof -i -P -n | grep LISTEN | awk '{print $2, $1, $9, $3}' | sort -u | head -n 50) \
@rponte
rponte / TempClasspathDirCreator.java
Created November 19, 2024 17:41
Helper class to create temp files inside application classpath during the unit tests with Java and jUnit
package base;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@rponte
rponte / 01-SshService.java
Last active December 11, 2024 14:44
Example of Integration Tests with Java, jUnit5 and Apache Mina to execute remote commands via SSH
package br.com.rponte.sample.ssh;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Path;
@rponte
rponte / postgresql_serializable_isolation.sql
Created October 25, 2024 15:05 — forked from nathanl/postgresql_serializable_isolation.sql
PostgreSQL Serializable Isolation - false positives
-- (This code was run in PostgreSQL 9.6.1)
-- Demonstration of how serializable isolation for PostgreSQL, which detects possible
-- interference between concurrent transactions, can produce false positives
-- in psql, create the following table
CREATE TABLE users(
id SERIAL NOT NULL PRIMARY KEY,
username VARCHAR NOT NULL
);
@rponte
rponte / partitioning.md
Last active March 18, 2025 14:44
Patitioning: the third pillar of scalability