Skip to content

Instantly share code, notes, and snippets.

View struberg's full-sized avatar

Mark Struberg struberg

  • Vienna
View GitHub Profile
@struberg
struberg / gist:4baae580d140e83a2e8cab98db97e7be
Last active January 14, 2022 16:53
Weird JAXB Calendar and Date parsing
/*
I came across a rather nasty timezone glitch with JAXB calendar parsing.
Over here in Europe we have a time offset of +2:00 during summer (CEST) and +1:00 during winter (CET).
That means if we create a Date and Calendar with say 2022-07-23 it will automatically detect this as +2:00 offset.
And on 2022-01-01 it will detect an offset of +1:00. Perfectly fine.
Now let's subtract one day: if I take a Calendar of 2022-04-01_00:00:00 it will detect +2:00.
Subtracting a single day will end up at 2022-03-31_00:00:00 and offset +1:00. Perfectly fine still
@struberg
struberg / MapSortTest
Created May 21, 2021 18:52
bench a few ways to sort a Map. Especially compare speed of TreeMap vs sorted Streams
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@struberg
struberg / french_app_activity_2019-07-26.csv
Created July 26, 2019 09:49
french APP activity 2019-07-26
Group CATTENOM 4 Fortuitous 07-26-19 02:28 07-27-19 01:00 1300 MW 0 MW
Group GOLFECH 2 Fortuitous 07-26-19 01:58 07-26-19 18:00 1310 MW 0 MW
Group GOLFECH 1 Fortuitous 07-26-19 01:56 07-26-19 18:00 1310 MW 0 MW
Group TRICASTIN 4 Planned 07-26-19 00:00 07-27-19 00:00 915 MW 180 MW
Group DAMPIERRE 3 Fortuitous 07-25-19 22:40 07-26-19 23:00 890 MW 770 MW
Group BUGEY 2 Fortuitous 07-24-19 19:44 07-27-19 18:00 910 MW 0 MW
Group GOLFECH 1 Planned 07-23-19 17:30 07-29-19 01:00 1310 MW 0 MW
Group GOLFECH 2 Planned 07-23-19 16:30 07-29-19 00:00 1310 MW 0 MW
Group BLAYAIS 4 Planned 07-23-19 11:30 08-31-19 02:00 910 MW 780 MW
Group GRAND MAISON 12 Planned 07-22-19 07:00 07-26-19 17:00 157 MW 0 MW
public interface DocServer {
@ConfigProperty(name="serverport", defaultValue = "8080")
int port();
String host();
@ConfigProperty(defaultValue = "/doc")
String path();
}
@struberg
struberg / MySvcClient.java
Created December 6, 2018 15:51
Meecrowave JAX-RS Client via Interface
@ApplicationScoped
public class MySvcClient {
@javax.enterprise.inject.Produces
@RequestScoped
@RemoteClient //x that's our circuit breaker, adding log correlation, etc
public MySvc getMySvc() {
String serviceUrl = config.getValue("my.app.endpoints.mySvc", String.class); //mp-config for getting the endpoint url
return org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(serviceUrl, MySvc.class);
@struberg
struberg / exclude_java.net_settings.xml
Created August 21, 2018 07:35
mirrorOf section to exclude the java.net maven repo and redirect all requests to maven.central
<mirrors>
<mirror>
<id>new.apache.snapshots</id>
<name>ignore jave.net repo and mirror to maven.central</name>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>m1.java.net,maven2-repository.dev.java.net,Java.net Maven 2,java.net.m2,m1.java.net,glassfish-repo-archive,java.net2,glassfish</mirrorOf>
</mirror>
</mirrors>
@struberg
struberg / bvalperformance.adoc
Created March 21, 2018 08:37
BeanValidation Performance

Wer mist mist mist…​

I did not change much from our previous test. Just updated to

  • Apache BVal 1.1.2

  • Hibernate Validator 5.4.2.Final

$> svn co https://svn.apache.org/repos/asf/bval/sandbox/jsr303-impl-bench
$> mvn clean install
@struberg
struberg / pom.xml
Created March 17, 2018 20:59
owasp dependency check for maven
<profiles>
<profile>
<id>cve-check</id>
<build>
<plugins>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>3.1.1</version>
<executions>
INFORMATION: OpenWebBeans Container has started, it took [106] ms.
took ms: 1521
Observer_000
Observer_002
Observer_004
Observer_006
Observer_007
Observer_008
Observer_009
Observer_010
@struberg
struberg / JaxWsRegistrationExtension.java
Created June 9, 2017 09:59
Register JAX-WS in Meecrowave. Just playing around with it for now
public class JaxWsRegistrationExtension implements Extension {
private List<AnnotatedType> webServices = new ArrayList<>();
public void collectWebServices(@Observes @WithAnnotations(WebService.class) ProcessAnnotatedType<?> pat) {
if (pat.getAnnotatedType().isAnnotationPresent(Path.class) && !pat.getAnnotatedType().getJavaClass().isInterface()) {
webServices.add(pat.getAnnotatedType());
}
}