Skip to content

Instantly share code, notes, and snippets.

View ghusta's full-sized avatar

Guillaume Husta ghusta

  • Toulouse, France
  • 06:42 (UTC +02:00)
  • X @ghusta
View GitHub Profile
@ghusta
ghusta / JpaRepositoryItemReader.java
Created May 15, 2017 11:12
Spring Batch (ItemReader) + Spring Data JPA (JpaRepository) integration
import java.util.concurrent.CopyOnWriteArrayList;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.database.AbstractPagingItemReader;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
@ghusta
ghusta / JpaRepository.ftl
Created May 2, 2017 15:10
Spring Data JPA JpaRepository Freemarker Template for Hibernate Tools
/*
* GΓ©nΓ©rΓ© par Hibernate Tools ${version} le ${date}
* avec FreeMarker ${.version}
*/
${pojo.getPackageDeclaration()}
import ${pojo.getQualifiedDeclarationName()};
<#assign classbody>
<#assign pkType = pojo.getJavaTypeName(clazz.identifierProperty, true) />
@ghusta
ghusta / Dockerfile
Last active February 6, 2019 18:19
Tomcat 8 + Docker : add custom directory in classpath (Method #2 : define CLASSPATH in bin/setenv.sh)
FROM tomcat:8.5-jre8
# $CATALINA_HOME is defined in tomcat image
ADD target/my-webapp*.war $CATALINA_HOME/webapps/my-webapp.war
# Application config
RUN mkdir $CATALINA_HOME/app_conf/
ADD src/main/config/test.properties $CATALINA_HOME/app_conf/
# Create "$CATALINA_HOME/bin/setenv.sh"
@ghusta
ghusta / Dockerfile
Last active August 12, 2022 20:39
Tomcat 8 + Docker : add custom directory in classpath (Method #1 : modify conf/catalina.properties)
FROM tomcat:8.5-jre8
# $CATALINA_HOME is defined in tomcat image
ADD target/my-webapp*.war $CATALINA_HOME/webapps/my-webapp.war
# Application config
RUN mkdir $CATALINA_HOME/app_conf/
ADD src/main/config/test.properties $CATALINA_HOME/app_conf/
# Modify property 'shared.loader' in catalina.properties
@ghusta
ghusta / SimpleDateFormat_ThreadSafe.java
Last active November 24, 2016 12:59
SimpleDateFormat is not thread-safe, so give one to each thread [Java]
// SimpleDateFormat is not thread-safe, so give one to each thread
private static final ThreadLocal<SimpleDateFormat> DATE_FORMAT_ISO_DATE = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
}
};
@ghusta
ghusta / mvn-install-file
Last active October 18, 2016 14:22
Maven : Installing Secondary Artifacts (jar, sources, javadoc)
mvn install:install-file -Dfile=my-sources.jar -DgroupId=commons-dbcp -DartifactId=commons-dbcp -Dversion=1.2 -Dpackaging=jar -Dclassifier=sources
@ghusta
ghusta / gist:344b14b4d6f7f99baa69380cea5a5519
Last active June 17, 2016 08:47 — forked from alimd/gist:3344523
All github Emoji (Smiles)

All github Emoji (Smiles)

ali.md/emoji

:bowtie: | πŸ˜„ | πŸ˜† | 😊 | πŸ˜ƒ | ☺️ | 😏 | 😍 | 😘 | :kissing_face: | 😳 | 😌 | πŸ˜† | 😁 | πŸ˜‰ | :wink2: | πŸ‘… | πŸ˜’ | πŸ˜… | πŸ˜“

😩 | πŸ˜” | 😞 | πŸ˜– | 😨 | 😰 | 😣 | 😒 | 😭 | πŸ˜‚ | 😲 | 😱 | :neckbeard: | 😫 | 😠 | 😑 | 😀 | πŸ˜ͺ | πŸ˜‹ | 😷

😎 | 😡 | πŸ‘Ώ | 😈 | 😐 | 😢 | πŸ˜‡ | πŸ‘½ | πŸ’› | πŸ’™ | πŸ’œ | ❀️ | πŸ’š | πŸ’” | πŸ’“ | πŸ’— | πŸ’• | πŸ’ž | πŸ’˜ | ✨

@ghusta
ghusta / LocalDateToDateConverter.java
Created June 10, 2016 11:42
Dozer Converter to convert org.joda.time.LocalDate to java.util.Date.
package ...util.dozer.converters.time;
import java.util.Date;
import org.dozer.DozerConverter;
import org.joda.time.LocalDate;
/**
* <b>Converter Dozer</b> : Convert a {@link LocalDate} to {@link Date}.
*/
@ghusta
ghusta / EnumUtils.java
Created March 30, 2016 13:34
Utils for Enums with Java 5
import java.lang.reflect.Field;
import org.apache.commons.lang.StringUtils;
/**
* InspirΓ© de {@link com.google.common.base.Enums} et {@link org.apache.commons.lang3.EnumUtils}.
*/
public class EnumUtils
{
@ghusta
ghusta / BigDecimalComparison.java
Last active March 23, 2016 09:50
Comparison of BigDecimal, working with Builder Pattern (isLessThan, isGreaterThan, etc)
package fr.husta.util.bigdecimal;
import java.math.BigDecimal;
public class BigDecimalComparison
{
/**
* Initiate the comparison.
*