Skip to content

Instantly share code, notes, and snippets.

@jmini
jmini / decodeDiagram.java
Created May 9, 2022 22:02
Decode drawio compressed xml
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS com.github.vlsi.mxgraph:jgraphx:4.2.2
//JAVA 8
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URLDecoder;
@jmini
jmini / runTests.java
Created March 8, 2022 06:53
Write and execute Junit 5 unit tests directly in Jbang
///usr/bin/env jbang "$0" "$@" ; exit $?
// Junit console to start the test engine:
//DEPS org.junit.platform:junit-platform-console:1.8.2
// engine to run the tests (tests are written with Junit5):
//DEPS org.junit.jupiter:junit-jupiter-engine:5.8.2
import static org.junit.jupiter.api.Assertions.fail;
@jmini
jmini / runTests.java
Created January 27, 2022 22:14
Re-run Junit 5 tests present in a Jar
///usr/bin/env jbang "$0" "$@" ; exit $?
// jar containing the Junit5 tests:
//DEPS com.company.test:lib:1.3.2
// Junit console to start the test engine:
//DEPS org.junit.platform:junit-platform-console:1.8.2
// engine to run the tests (tests are written with Junit5):
//DEPS org.junit.jupiter:junit-jupiter-engine:5.8.2
@jmini
jmini / CreateWebserver.java
Created December 28, 2021 11:53
Create a docker image with Jib
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS com.google.cloud.tools:jib-core:0.20.0
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import com.google.cloud.tools.jib.api.Containerizer;
import com.google.cloud.tools.jib.api.DockerDaemonImage;
@jmini
jmini / pom.xml
Created December 7, 2021 21:11
Maven file to download some Gradle dependencies
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mvntmp</groupId>
<artifactId>mvntmp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
@jmini
jmini / SpoonMain.java
Created March 25, 2021 08:13
Spoon test with compile errors
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS fr.inria.gforge.spoon:spoon-core:8.4.0
//DEPS org.slf4j:slf4j-simple:1.7.30
import java.util.List;
import java.util.Set;
import spoon.Launcher;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtField;
@jmini
jmini / example.java
Created July 16, 2020 05:24
Write an OpenAPI spec with Java code (instead of YAML or JSON directly)
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.smallrye:smallrye-open-api-core:2.0.3
import static org.eclipse.microprofile.openapi.OASFactory.*;
import org.eclipse.microprofile.openapi.models.OpenAPI;
import io.smallrye.openapi.runtime.io.Format;
import io.smallrye.openapi.runtime.io.OpenApiSerializer;
@jmini
jmini / generateCode.java
Last active May 20, 2020 04:09
Generate the Java code to create an OpenAPI document
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.openapitools.empoa:empoa-swagger-core:1.1.0
//DEPS org.openapitools.empoa:empoa-javapoet:1.1.0
//DEPS io.swagger.parser.v3:swagger-parser:2.0.20
//DEPS org.slf4j:slf4j-simple:1.7.30
import org.eclipse.microprofile.openapi.models.OpenAPI;
import org.openapitools.empoa.javapoet.JavaFileConverter;
import org.openapitools.empoa.swagger.core.internal.SwAdapter;
@jmini
jmini / README.md
Created November 29, 2018 07:20
JStack execution when Eclipse is frozen (EGit history view)
@jmini
jmini / report.xml
Created April 21, 2018 13:15
Report issues in a file
<?xml version="1.0" encoding="UTF-8"?>
<issues>
<issue
name="Lines should not be longer than 80 characters"
severity="Warning"
message="Line 2 is too long (length: 105)"
category="STYLE"
summary="The line length should be less than or equal to 80."
explanation="In a text file (ending with `.txt`) the line should not be longer than 80 characters ..."
location="/_absolute_path_to_/some-file.txt"