Skip to content

Instantly share code, notes, and snippets.


Benoit Maggi bmaggi

  • Bordeaux, France
View GitHub Profile
bmaggi / JunitMigrationGrep.Md
Created Mar 2, 2021
Simple grep Junit 4 to Junit 5
View JunitMigrationGrep.Md
JUnit 4 Junit 5
org.junit.Test org.junit.jupiter.api.Test
class ExampleTest {
void myTest( String ex) {
bmaggi /
Created Dec 16, 2020
Junit 5 Custom Parameter Source with Boolean as Example
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.ArgumentsProvider;
public class BooleanArgumentsProvider implements ArgumentsProvider, AnnotationConsumer<BooleanSource> {
BooleanArgumentsProvider() {

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

bmaggi /
Created Oct 9, 2019
a simple way to lock key in Redis using Redisson
import org.redisson.Redisson;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import java.util.concurrent.TimeUnit;
class RedissonManualLock {
// a simple way to lock key in Redis using Redisson
bmaggi /
Created Oct 9, 2019
Small reminder that orElse parameter is evaluated
import java.util.Optional;
public class FunIsOptional {
public static void main(String[] args) {
Integer i = 0;
System.out.println(Optional.of(i).map(v -> v++).orElse(i--));
// => res = 0 (orElse is evaluated even when not empty)
bmaggi /
Created Apr 5, 2019
Example of date change (France,Brasil)
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.util.Date;
import java.util.TimeZone;
class TimeChange {
public static void main(String[] args) throws ParseException {
timeForward("Europe/Paris", "2019-03-31 01:59:59", Duration.ofSeconds(2).toMillis()); // FRANCE +1
bmaggi / JavaRandom
Last active Jul 26, 2019
Java Random primitive generation (basic Api only)
View JavaRandom
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import java.time.Instant;
class JavaRandom {
public static void main(String[] args) {