Skip to content

Instantly share code, notes, and snippets.

View fbaligand's full-sized avatar

Fabien Baligand fbaligand

View GitHub Profile
@fbaligand
fbaligand / dev-tools-command.json
Created November 7, 2023 09:51
Chain Watcher with array injection
PUT _watcher/watch/my_chain_watch
{
"trigger": {
"schedule": {
"interval": "30m"
}
},
"input": {
"chain": {
"inputs": [
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"my-object": {
"type": "object",
"properties": {
"prop1": {
"type": "string",
"default": "prop1"
package org.logstash.log;
import java.util.Map;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.lookup.StrLookup;
@Plugin(name = "logstash", category = "Lookup")
public class LogstashLookup implements StrLookup {
@fbaligand
fbaligand / DisableLazyLoadingDozerFieldMapper.java
Last active January 25, 2018 21:20
Composant Java permettant de dire à dozer de manière générale, de ne pas copier les collections Hibernate non initialisées
package dozer;
import org.dozer.CustomFieldMapper;
import org.dozer.classmap.ClassMap;
import org.dozer.fieldmap.FieldMap;
import org.hibernate.Hibernate;
/**
* FieldMapper Dozer permettant de désactiver la copie des proxys Hibernate non initialisés (entité ou collection)
*/
@fbaligand
fbaligand / log4j.properties
Created March 16, 2013 11:32
Fichier de configuration LOG4J, configurable dynamiquement par system properties : niveau de log racine, appender par défaut (console, rollingfile ou dailyrollingfile), répertoire de log
# ROOT LOGGER
log4j.rootLogger=${log4j.rootLevel},${log4j.rootAppender}
# APPENDER CONSOLE
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p;%d{dd/MM/yyyy HH:mm:ss};[%c{1}];%m%n
# APPENDER ROLLING FILE
log4j.appender.rollingfile=org.apache.log4j.RollingFileAppender
@fbaligand
fbaligand / Log4jManagement.java
Created March 16, 2013 11:22
Composant Spring permettant de consulter/modifier la configuration LOG4J de son application via JMX
package com.fbaligand.log4j.jmx;
import java.util.Enumeration;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedOperationParameter;
@fbaligand
fbaligand / log4j-reload.jsp
Created March 16, 2013 11:14
Page JSP permettant de modifier à chaud, sa configuration LOG4J
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@page import="org.springframework.util.FileCopyUtils"%>
<%@page import="java.io.InputStream"%>
<%@page import="java.util.Properties"%>
<%@page import="java.io.StringReader"%>
<%@page import="org.apache.log4j.PropertyConfigurator"%>
<%@page import="org.apache.log4j.LogManager"%>
<%!
/**
* variable statique contenant la configuration LOG4J actuellement chargée en mémoire
@fbaligand
fbaligand / iso-to-utf8.xml
Last active December 15, 2015 00:49
Script ANT permettant de convertir l'encoding d'une arborescence de fichiers, de ISO-8859-1 vers UTF-8
<?xml version="1.0" encoding="UTF-8"?>
<project name="native2ascii" default="native2ascii" basedir=".">
<property name="srcEncoding" value="ISO-8859-1" />
<property name="destEncoding" value="UTF-8" />
<property name="srcDir" value="${basedir}/input" />
<property name="destDir" value="${basedir}/output" />
<property name="tempDir" value="${basedir}/temp" />
@fbaligand
fbaligand / dbunit-to-sql.xsl
Last active December 15, 2015 00:49
XSLT permettant de transformer un fichier XML DBUnit en script SQL d'insertion
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" media-type="text/sql"/>
<xsl:template match="dataset">
<xsl:apply-templates select="./*"/>
</xsl:template>
<xsl:template match="dataset/*">
<xsl:text>insert into </xsl:text>