Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@marschall
marschall / oracle_calendar.sql
Created August 2, 2019 08:16
Shows the Oracle calendar is not proleptic
WITH calendar(date_value) AS (
SELECT TIMESTAMP '1582-09-30 00:00:00'
FROM dual
UNION ALL
SELECT date_value + 1
FROM calendar
WHERE date_value <= TIMESTAMP '1582-10-16 00:00:00'
)
SELECT date_value
FROM calendar;
@marschall
marschall / PortableDecimalFormatTest.java
Created March 5, 2019 10:14
Portable Decimal Formatting
class PortableDecimalFormatTest {
@Test
void decimalFormat() {
Locale switzerland = new Locale("de", "CH");
DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(switzerland);
format.applyPattern("#,##0.00");
DecimalFormatSymbols decimalFormatSymbols = format.getDecimalFormatSymbols();
decimalFormatSymbols.setGroupingSeparator('\'');
// important because #getDecimalFormatSymbols() returns a clone
@marschall
marschall / SwissDecimalFormatTest.java
Created March 5, 2019 09:05
Decimal Formatting Changes in Java 11
class SwissDecimalFormatTest {
@Test
void decimalFormat() {
Locale switzerland = new Locale("de", "CH");
DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(switzerland);
format.applyPattern("#,##0.00");
String formatted = format.format(new BigDecimal("1234567.8"));
assertEquals("1'234'567.80", formatted);
@marschall
marschall / val.jsh
Created March 30, 2018 08:57
val is not a keyword
class val {}
val val = new val()
@marschall
marschall / jmc-jpms-warning.txt
Created September 22, 2017 15:35
JMC JPMS Warning
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.emf.ecore.xmi.impl.XMLHandler (file:/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/missioncontrol/plugins/org.eclipse.emf.ecore.xmi_2.12.0.v20160420-0247.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getEncoding()
WARNING: Please consider reporting this to the maintainers of org.eclipse.emf.ecore.xmi.impl.XMLHandler
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
@marschall
marschall / Graal
Created August 20, 2017 19:35
UUID parsing performance
$java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Graal VM (build 25.71-b01-internal-jvmci-0.30, mixed mode)
Result "com.github.marschall.charsequences.ParseUuidBenchmark.parseJdk":
2.411 ±(99.9%) 0.014 ops/us [Average]
(min, avg, max) = (2.124, 2.411, 2.462), stdev = 0.043
CI (99.9%): [2.396, 2.425] (assumes normal distribution)
@marschall
marschall / glassfish-all-jdeprscan.txt
Created October 13, 2016 14:21
jdeprscan on application servers
class com/sun/ejb/containers/EJBContextImpl uses type java/security/Identity deprecated FOR REMOVAL
class com/sun/ejb/containers/EJBContextImpl uses method in type java/security/Identity deprecated FOR REMOVAL
class com/sun/ejb/containers/EJBContextImpl method getCallerIdentity has return type Ljava/security/Identity; deprecated FOR REMOVAL
class com/sun/ejb/containers/EJBContextImpl method isCallerInRole has parameter type Ljava/security/Identity; deprecated FOR REMOVAL
class com/sun/enterprise/security/PolicyLoader uses type javax/security/auth/Policy deprecated FOR REMOVAL
class com/sun/enterprise/security/PolicyLoader uses method in type javax/security/auth/Policy deprecated FOR REMOVAL
class com/sun/enterprise/security/PolicyLoader uses method in type javax/security/auth/Policy deprecated FOR REMOVAL
class com/sun/enterprise/security/ssl/GlassfishSSLSupport uses type [Ljavax/security/cert/X509Certificate; deprecated FOR REMOVAL
class com/sun/enterprise/security/ssl/GlassfishSSLSupport uses type javax/sec
$JAVA_HOME/bin/jdeprscan --for-removal --release 9 oracle-javaee-api-7.0.jar
interface javax/ejb/EJBContext method getCallerIdentity has return type Ljava/security/Identity; deprecated FOR REMOVAL
interface javax/ejb/EJBContext method isCallerInRole has parameter type Ljava/security/Identity; deprecated FOR REMOVAL
@marschall
marschall / FasterGame.java
Created September 10, 2016 09:46 — forked from jackmott/FasterGame.java
Faster Java Game
class Vector
{
public float x, y, z;
public Vector(float x, float y, float z)
{
this.x = x;
this.y = y;
this.z = z;
}
public class SequenceableCollection {
public static <T> List<T> streamContents(Supplier<List<T>> constructor, Consumer<Consumer<T>> block) {
List<T> result = constructor.get();
block.accept(each -> result.add(each));
return result;
}
public static List<String> example(ResultSet rs) {
return streamContents(ArrayList::new, (accumulator) -> {