Skip to content

Instantly share code, notes, and snippets.

View jabrena's full-sized avatar

Juan Antonio Breña Moral jabrena

View GitHub Profile
@jabrena
jabrena / new-spring-boot-project.sh
Last active November 12, 2020 08:41
Create a new Spring Boot project from terminal
curl https://start.spring.io/starter.zip -d dependencies=web,devtools,lombok,configuration-processor,security,actuator,testcontainers \
-d bootVersion=2.3.4.RELEASE -o my-project.zip
#https://docs.spring.io/initializr/docs/current/reference/html/#command-line
#https://start.spring.io/
@jabrena
jabrena / MyClass.java
Created September 7, 2020 12:43
Java Puzzler
public class MyClass {
public static void main(String args[]) {
Object object = (byte) ~
(char) -
(int) +
(long) -1;
System.out.println(object);
if (object instanceof Integer)
@jabrena
jabrena / RemoveFilePOCTest.java
Created July 3, 2020 19:24
An example using JGit
import lombok.extern.slf4j.Slf4j;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.transport.PushResult;
import org.junit.jupiter.api.Test;
import java.io.File;
@jabrena
jabrena / CoresDemo.java
Last active June 6, 2020 20:13
CoresDemo
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Supplier;
@jabrena
jabrena / MotorEncoderTest.java
Created September 3, 2019 20:19
Modern syntax for Robots with Java 8+
package example;
import ev3dev.actuators.lego.motors.EV3LargeRegulatedMotor;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@jabrena
jabrena / DonQuijote.java
Last active August 19, 2019 21:00
DonQuijote.java
package example.programming;
import ev3dev.robotics.tts.Espeak;
/**
* Java example to show the new language feature (Java 13): Text block
*
* Original text: https://cvc.cervantes.es/literatura/clasicos/quijote/edicion/parte1/cap01/default.htm
*/
public class DonQuijoteDemo {
@jabrena
jabrena / README.md
Last active January 23, 2019 06:19
API Multiple items affected in a resource

API General design:

POST /api/companies/items GET /api/companies/items GET /api/companies/items/{id} DELETE /api/companies/items/{id} PUT /api/companies/items/{id}

PATCH /api/companies/items/

public class ThreadDeathCatch {
public static void main(String[] args) {
try {
Thread t = new Thread(() -> {
try {
Thread.sleep(2500);
} catch (Throwable ex) {
System.out.println("Caught in run: " + ex);
}
});
@jabrena
jabrena / MotorEncoderTest.java
Last active November 1, 2018 12:47
ExecutorService and Motors
package examples.actuators;
import ev3dev.actuators.lego.motors.EV3LargeRegulatedMotor;
import ev3dev.actuators.lego.motors.Motor;
import lejos.hardware.port.MotorPort;
import lejos.robotics.RegulatedMotor;
import lejos.utility.Delay;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.ExecutorService;