Skip to content

Instantly share code, notes, and snippets.

View cescoffier's full-sized avatar
⚗️
Quarking...

Clement Escoffier cescoffier

⚗️
Quarking...
View GitHub Profile
@cescoffier
cescoffier / AsyncInputStream.java
Last active March 11, 2024 10:20
Async Input Stream VertX Read Stream
/*
* #%L
* Wisdom-Framework
* %%
* Copyright (C) 2013 - 2014 Wisdom Framework
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.2.0
//DEPS org.eclipse.jgit:org.eclipse.jgit:5.8.1.202007141445-r
import org.eclipse.jgit.api.ListBranchCommand;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
@cescoffier
cescoffier / HostEdit.java
Created June 26, 2023 09:06
A JBang script to edit your /etc/hosts file (add and remove entries)
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.7.4
import java.io.File;
import java.io.IOException;
import java.lang.System.Logger.Level;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
@cescoffier
cescoffier / Retry.java
Last active March 31, 2023 06:45
Various examples of retries with Mutiny
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.smallrye.reactive:smallrye-mutiny-vertx-web-client:1.1.0
//DEPS io.smallrye.reactive:mutiny:0.7.0
//DEPS org.slf4j:slf4j-nop:1.7.30
package io.vertx.mutiny.retry;
import io.smallrye.mutiny.Uni;
import io.vertx.mutiny.core.Vertx;
@cescoffier
cescoffier / cleanup_maven_repository.sh
Created January 9, 2012 11:45
A shell script to cleanup your local maven repository. It removes all snapshot from more than 6 months
#!/bin/sh
M2_REPO=${HOME}/.m2
OLDFILES=/tmp/deleted_artifacts.txt
AGE=181 # more or less 6 months and it's a palindromic prime number, so it's cool
echo "==== To be Deleted Jars ====" >> ${OLDFILES}
find "${M2_REPO}" -name '*-SNAPSHOT*jar' -atime +${AGE} -exec dirname {} \; >> ${OLDFILES}
echo "==== To be Deleted Wars/Ears ====" >> ${OLDFILES}
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.quarkus:quarkus-smallrye-reactive-messaging-kafka:1.9.0.CR1
//DEPS io.quarkus:quarkus-smallrye-health:1.9.0.CR1
//DEPS org.testcontainers:kafka:1.15.0-rc2
//JAVAC_OPTIONS -parameters
//JAVA_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager
//JAVA_OPTIONS -Dmp.messaging.outgoing.movies-out.connector=smallrye-kafka -Dmp.messaging.outgoing.movies-out.topic=movies -Dmp.messaging.outgoing.movies-out.value.serializer=org.apache.kafka.common.serialization.StringSerializer
//JAVA_OPTIONS -Dmp.messaging.incoming.movies.connector=smallrye-kafka -Dmp.messaging.incoming.movies.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer -Dmp.messaging.incoming.movies.auto.offset.reset=earliest
//JAVA_OPTIONS -Dmp.messaging.incoming.movies.failure-strategy=dead-letter-queue
//JAVA_OPTIONS -Dmp.messaging.incoming.dead-letter-topic-movies.connector=smallrye-kafka -Dmp.messaging.incoming.dead-letter-topic-movies.value.deserializer=org.apache.k
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.smallrye.reactive:smallrye-mutiny-vertx-web-client:1.1.0
//DEPS io.smallrye.reactive:mutiny:0.7.0
//DEPS org.slf4j:slf4j-nop:1.7.30
package io.vertx.mutiny.pagination;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
@cescoffier
cescoffier / CollectionCodecs.java
Created December 7, 2017 14:37
Example how to use Collection Codec with Vert.x Web Client
package com.example.demo;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.codec.BodyCodec;
import io.vertx.ext.web.codec.impl.BodyCodecImpl;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.smallrye.reactive:smallrye-mutiny-vertx-web-client:1.1.0
//DEPS io.smallrye.reactive:mutiny:0.7.0
//DEPS org.slf4j:slf4j-nop:1.7.30
package io.vertx.mutiny.quotes;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.smallrye.reactive:smallrye-mutiny-vertx-redis-client:1.1.0
//DEPS io.smallrye.reactive:mutiny:0.7.0
//DEPS org.testcontainers:testcontainers:1.14.3
//DEPS org.slf4j:slf4j-nop:1.7.30
package io.vertx.mutiny.redis;
import io.smallrye.mutiny.Multi;