Skip to content

Instantly share code, notes, and snippets.

View mikybars's full-sized avatar

Miguel Ibars mikybars

  • Madrid
  • 08:52 (UTC +01:00)
View GitHub Profile
@mikybars
mikybars / pom.xml
Last active September 14, 2021 10:59
[Custom Java inside Maven] Maven Enforcer plugin lets you define custom conditions in a lightweight Java. https://maven.apache.org/enforcer/enforcer-rules/evaluateBeanshell.html #maven #java
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>check-coverage</id>
<phase>install</phase>
<goals>
export FZF_CTRL_R_OPTS="$FZF_CTRL_R_OPTS
--header='ctrl-e to query explainshell.com'
--bind \"ctrl-e:execute(curl -sLG -o /dev/null -w '%{url_effective}' --data-urlencode cmd={} https://explainshell.com/explain | xargs open)\"
"
@mikybars
mikybars / mvn.sh
Last active September 17, 2021 09:08
[Java version in current Maven project] #maven
mvn --offline --quiet \
help:evaluate -DforceStdout -Dexpression=maven.compiler.source
@mikybars
mikybars / brew-rollback.md
Last active February 28, 2020 10:09
Rollback to a previous Homebrew formula version
@mikybars
mikybars / git-show.sh
Last active January 26, 2020 09:17
Use cases for git show
# View a commit by id (without an id it defaults to HEAD i.e. the last commit)
$ git show 512b26a
# View only the list of modified files in the commit
$ git show 512b26a --name-only
# View the DIFF of the file(s) inside the commit
$ git show 512b26a pom.xml
# View the CONTENTS of the file at a certain revision
$ git show 512b26a:pom.xml
@mikybars
mikybars / minikube.sh
Last active December 2, 2019 16:33
Minikube CheatSheet
# Bootstrap
$ minikube profile minikube
$ minikube config set memory 6144
$ minikube config set cpus 2
$ minikube config set vm-driver hyperkit # MacOS
$ minikube start
# List profiles
$ minikube profile list
|----------|-----------|---------------|-----------|--------------------|
@mikybars
mikybars / logback.xml
Created December 2, 2019 10:47
Include Maven variables like project.version in resource files
<appender name="stdoutAsync" class="net.logstash.logback.appender.LoggingEventAsyncDisruptorAppender">
<waitStrategyType>liteBlocking</waitStrategyType>
<appender class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<timeZone>UTC</timeZone>
<version>@project.version@</version>
</encoder>
</appender>
</appender>
@mikybars
mikybars / TaskController.java
Created November 26, 2019 10:08
Mapstruct for PATCH operations
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageNotReadableException;
@mikybars
mikybars / pom.xml
Last active September 16, 2025 13:19
Maven Surefire, Failsafe plugins with Jacoco for unit and integration testing with code coverage. https://natritmeyer.com/howto/reporting-aggregated-unit-and-integration-test-coverage-with-jacoco/
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${surefire.jacoco.args}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@mikybars
mikybars / mvn_install_local_jar.sh
Last active November 15, 2019 09:01
How to add local jar files to a Maven project? Install the JAR into your local Maven repository
# https://stackoverflow.com/a/4955695
$ mvn install:install-file \
-Dfile=<path-to-file> \
-DgroupId=<group-id> \
-DartifactId=<artifact-id> \
-Dversion=<version> \
-Dpackaging=<packaging>