Skip to content

Instantly share code, notes, and snippets.

Avatar

Guillaume Husta ghusta

View GitHub Profile
@ghusta
ghusta / NexusArtifactCleanup.groovy
Last active Dec 18, 2015 — forked from oliverdaff/NexusArtifactCleanup.groovy
Script Groovy : NexusArtifactCleanup
View NexusArtifactCleanup.groovy
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 Dec 18, 2015
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
View index.html
<!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 Dec 22, 2015
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
View ServiceLocatorGenerics.java
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 Sep 25, 2013
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).
View JaxbDateAdapter.java
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 Jan 13, 2014
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).
View LocalDateAdapter.java
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 Jan 15, 2014
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).
View LocalDateTimeAdapter.java
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 / Assert-Comparables.md
Created Oct 8, 2015
Java Unit Tests : Assert on Comparables (BigDecimal)
View Assert-Comparables.md

This is UGLY : With JUnit 4

    BigDecimal actual = new BigDecimal("8.0");
    assertTrue(actual.compareTo(new BigDecimal("8.00")) == 0);
    assertEquals(0, actual.compareTo(new BigDecimal("8.00")));

That's too verbose...

This is BEAUTIFUL :

@ghusta
ghusta / DuplicatesFinder.java
Created Nov 19, 2015
DuplicatesFinder - Java 5 code
View DuplicatesFinder.java
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 / BigDecimalUtils.java
Last active Jun 16, 2016
Classe utilitaire pour la classe BigDecimal.
View BigDecimalUtils.java
package fr.gouv.finances.douane.intercom.outils.lang;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
@ghusta
ghusta / AcceptLanguagesRequestInterceptor.java
Last active Mar 17, 2016
RestEasy Interceptor (JAX-RS).Extract current locale from HTTP Request Header : 'Accept-Languages'.
View AcceptLanguagesRequestInterceptor.java
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;