Skip to content

Instantly share code, notes, and snippets.

View edwise's full-sized avatar
🎯
Focusing

Eduardo Antón edwise

🎯
Focusing
View GitHub Profile
Timer timer = Timer.builder("timerName")
.publishPercentiles(0.5, 0.95, 0.99)
.tag("tag1", "sdgawehwh")
.register(meterRegistry);
return timer.record(() -> httpClient.call(body));
@edwise
edwise / Serializers.java
Last active February 22, 2019 09:27
Serialize to String Lists with custom objects
/**
* Serialize a collection of custom objects. The properties should be "string compatible".
*
* @param list collection to serialize.
* @param clazz type of the the collection.
* @return collection serialized in string.
*/
public static <T> String serializeCustomObjectsCollection(Collection<T> list, Class<T> clazz) {
return Optional.ofNullable(list)
.map(listValue -> listValue.stream()
@edwise
edwise / saveFileProjectPath.java
Last active March 13, 2018 14:12
Save files on project path
URL localFileUrl = Thread.currentThread()
.getContextClassLoader()
.getResource("subFolder/" + "fileName.txt");
File file = new File(localFileUrl.getPath());
@edwise
edwise / restfullPostWithoutSpringHateoas.java
Last active August 29, 2015 14:15
How to do a RESTful POST without Spring Hateoas (link)
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(
ServletUriComponentsBuilder
.fromCurrentRequest()
.path("/{id}")
.buildAndExpand(entity.getId())
.toUri());
return new ResponseEntity<>(httpHeaders, HttpStatus.CREATED);
@edwise
edwise / intelliJLiveTemplateJunitTestMethod.java
Last active August 29, 2015 14:02
IntelliJ Live Template to create test methods in Junit classes
@Test
public void test$EXPR$() {
$END$
fail("Not yet implemented");
}
@edwise
edwise / excludeFilesJacocoPom.xml
Last active August 22, 2021 16:10
How to exclude files in jacoco coverage (maven configuration)
...
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.mavenplugin.version}</version>
<configuration>
<excludes>
<exclude>**/com/edwise/completespring/config/*</exclude>
</excludes>
</configuration>