Skip to content

Instantly share code, notes, and snippets.

View pierrefevrier's full-sized avatar

Pierre FEVRIER pierrefevrier

View GitHub Profile
@pierrefevrier
pierrefevrier / Impl.java
Created January 21, 2017 14:13
Inject a list property via Spring
@Value("#{'${my-property}'.split(',')}")
private Collection<String> myCollection;
@pierrefevrier
pierrefevrier / CustomObjectMapper.java
Created January 21, 2017 14:17
Jackson Custom Object Mapper
// Création de l'object mapper
ObjectMapper objectMapper = new ObjectMapper();
// Ne pas générer les valeurs nulles
objectMapper.setSerializationInclusion(Include.NON_NULL);
// Ignore les attributs supplémentaires dans les flux JSON
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
// Gestion des dates Java 8 (java.time.*)
@pierrefevrier
pierrefevrier / pluginCustomConf.xml
Created January 21, 2017 14:26
Spring Boot Custom Surefire conf
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Tests.java</include>
<include>**/*Test.java</include>
<include>**/Test*.java</include>
<include>**/TU*.java</include>
<include>**/TI*.java</include>
@pierrefevrier
pierrefevrier / Test.java
Last active April 20, 2017 12:56
Unit test organization
/**
* Link to the specification
*
* <dl>
* <dt>GIVEN</dt>
* <dd>xxxxxx</dd>
* <dd>yyyyyy</dd>
* <dt>WHEN</dt>
* <dd>service xxx is called</dd>
* <dt>THEN</dt>
@pierrefevrier
pierrefevrier / nginx.conf
Last active January 21, 2017 14:39
NGinx proxify an app deployed on several instances
upstream app_name_servers {
server 192.168.1.1:8080;
server 192.168.1.2:8080;
}
location / {
rewrite /(.*) /app_name/$1 break;
proxy_pass http://app_name_servers;
}
@pierrefevrier
pierrefevrier / feedly.opml
Last active February 1, 2024 10:34
Backup Feedly
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Pierre subscriptions in feedly Cloud</title>
</head>
<body>
<outline text="Maison" title="Maison">
<outline type="rss" text="Jeedom – Le Blog" title="Jeedom – Le Blog" xmlUrl="https://blog.jeedom.com/feed/" htmlUrl="https://blog.jeedom.com"/>
</outline>
@pierrefevrier
pierrefevrier / .bash_profile
Last active January 24, 2020 20:44
Mac bash config
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
final Optional<Item> foundItem = myCollection.stream()
.filter(item -> item.isTheOneIWant())
.reduce((a, b) -> {
throw new RuntimeException("More than item item found !");
});
@pierrefevrier
pierrefevrier / sed.sh
Last active May 26, 2017 13:45
Sed usefull samples
# ===================================================================
# EXTRACT PART OF A STRING
# ===================================================================
typeset -r STRING='my_key="my_value"'
typeset -r SUBSTRING=$(echo "$STRING" | sed -rn 's/^.*my_key="(.+)".*$/\1/p')
echo "$SUBSTRING"
# my_value
# ===================================================================
@pierrefevrier
pierrefevrier / cut.sh
Created May 19, 2017 12:27
Cut usefull samples
# ===================================================================
# EXTRACT PARTS OF A STRING
# ===================================================================
typeset -r STRING='1.0.0-just-a-test'
# GET THE FIRST PART ONLY (=1.0.0)
echo "$STRING" | cut -d '-' -f1
# GET THE LAST PART ONLY (=just-a-test)