Skip to content

Instantly share code, notes, and snippets.

View ghusta's full-sized avatar

Guillaume Husta ghusta

  • Toulouse, France
  • 17:32 (UTC +01:00)
  • X @ghusta
View GitHub Profile
@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 / Assert-Comparables.md
Created October 8, 2015 10:07
Java Unit Tests : Assert on Comparables (BigDecimal)

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 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 / BigDecimalUtils.java
Last active June 16, 2016 14:01
Classe utilitaire pour la classe BigDecimal.
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 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;