Skip to content

Instantly share code, notes, and snippets.

View ghusta's full-sized avatar

Guillaume Husta ghusta

  • Toulouse, France
  • 03:25 (UTC +02:00)
  • X @ghusta
View GitHub Profile
@ghusta
ghusta / DuplicatesFinder.java
Created November 19, 2015 11:01
DuplicatesFinder - Java 5 code
package fr.husta.collections;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
@ghusta
ghusta / NexusArtifactCleanup.groovy
Last active December 18, 2015 01:39 — forked from oliverdaff/NexusArtifactCleanup.groovy
Script Groovy : NexusArtifactCleanup
import groovyx.net.http.*;
import static groovyx.net.http.ContentType.*;
import static groovyx.net.http.Method.*;
class NexusArtifactCleanup {
/**
* Settings in which to run script.
*/
def settings = [
@ghusta
ghusta / index.html
Last active December 18, 2015 07:29
Open new popup window without address bars nor toolbars in firefox & IE (uses Javascript). See also http://www.w3schools.com/jsref/met_win_open.asp
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Index</title>
<script type="text/javascript">
var _MsgWindowOpenError = 'Un mécanisme de blocage des fenêtres instantanées a été détecté dans votre navigateur Web. Ce type de mécanisme empêche le bon fonctionnement de cette application. Désactivez le mécanisme de blocage des fenêtres instantanées ou autorisez les fenêtres liées à ce site.';
var _MsgWindowOpenError2 = 'Attention le filtre anti-popups est activé ou le niveau de sécurité de Internet Explorer n\'est pas correctement configuré.';
@ghusta
ghusta / ServiceLocatorGenerics.java
Last active December 22, 2015 00:09
ServiceLocatorGenerics : a ServiceLocator for finding EJB 2 via JNDI, using Java 5 Generics. It makes it possible to invoke : MyEJBHome remoteHome = ServiceLocatorGenerics.getEjbRemoteHome("jndiName", MyEJBHome.class); without having to do a casting
package fr.husta.ejbutils.servicelocator;
import javax.ejb.EJBHome;
import javax.ejb.EJBLocalHome;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
/**
@ghusta
ghusta / JaxbDateAdapter.java
Created September 25, 2013 15:46
DateAdapter, useful to convert String to Date and conversely, for use with JAXB 2.0. Can be used when customizing XML Schema to Java Representation Binding (XJC).
package com.developpez.hugo.ws.adapters;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.xml.bind.annotation.adapters.XmlAdapter;
/**
* DateAdapter, useful to convert String to Date and conversely, for use with JAXB 2.0.
@ghusta
ghusta / LocalDateAdapter.java
Created January 13, 2014 17:05
LocalDateAdapter, useful to convert String to Joda Time's LocalDate and conversely, for use with JAXB 2.0. Can be used when customizing XML Schema to Java Representation Binding (XJC).
package xml.adapters.jodatime;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import org.joda.time.LocalDate;
/**
* LocalDateAdapter, useful to convert String to Joda Time's LocalDate and conversely, for use with JAXB 2.0.
* <br>
* Can be used when customizing XML Schema to Java Representation Binding (XJC).
*
@ghusta
ghusta / LocalDateTimeAdapter.java
Created January 15, 2014 09:43
LocalDateTimeAdapter, useful to convert String to Joda Time's LocalDateTime and conversely, for use with JAXB 2.0. Can be used when customizing XML Schema to Java Representation Binding (XJC).
package xml.adapters.jodatime;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import org.joda.time.LocalDateTime;
/**
* LocalDateTimeAdapter, useful to convert String to Joda Time's LocalDateTime and conversely, for use with JAXB 2.0.
* <br>
* Can be used when customizing XML Schema to Java Representation Binding (XJC).
@ghusta
ghusta / AcceptLanguagesRequestInterceptor.java
Last active March 17, 2016 16:14
RestEasy Interceptor (JAX-RS).Extract current locale from HTTP Request Header : 'Accept-Languages'.
package com...rest.support.interceptors;
import java.util.List;
import java.util.Locale;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.ext.Provider;
import org.jboss.resteasy.annotations.interception.Precedence;
@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.
*
@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
{