Skip to content

Instantly share code, notes, and snippets.

View lukaseder's full-sized avatar

Lukas Eder lukaseder

View GitHub Profile
void test() {
// Filling collections with values, similar to
// Collections.fill();
List<Optional<Number>> optionalList1 = new ArrayList<>();
List<Number> list1 = new ArrayList<>();
fillOptional(optionalList1, 1);
fillOptional(optionalList1, 1.0);
@lukaseder
lukaseder / gist:10462127
Last active August 29, 2015 13:59
Ain't no SQL hard enough (for jOOQ)
CommonTableExpression<Record2<Integer, String>> t1 = name("t1").fields("f1", "f2").as(select(val(1), val("a")));
CommonTableExpression<Record2<Integer, String>> t2 = name("t2").fields("f3", "f4").as(select(val(2), val("b")));
// Try renaming the CTEs and their columns when referencing them
Table<Record2<Integer, String>> b1 = t1.as("a1", "i1", "s1");
Table<Record2<Integer, String>> b2 = t2.as("a2", "i2", "s2");
Result<?> result4 =
create().with(t1)
@lukaseder
lukaseder / serialise.scala
Last active August 29, 2015 14:00
Will it serialise deterministically?
conn => {
conn.sendQuery(tableInsert(1)).flatMap {
_ =>
conn.sendQuery(tableInsert(2))
}
conn.sendQuery(tableInsert(3)).flatMap {
_ =>
conn.sendQuery(tableInsert(4))
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Copyright (c) 2009-2015, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* This work is dual-licensed
* - under the Apache Software License 2.0 (the "ASL")
* - under the jOOQ License and Maintenance Agreement (the "jOOQ License")
* ===========================================================================
* You may choose which license applies to you:
Aug 26, 2015 2:39:45 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.0.0.Final}
Aug 26, 2015 2:39:45 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Aug 26, 2015 2:39:45 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Aug 26, 2015 2:39:46 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.0.Final}
Aug 26, 2015 2:39:46 PM org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator initiateService
WARN: HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
@lukaseder
lukaseder / gist:e02f08d50c960f968a7e
Created January 25, 2016 17:15
jOOQ Benchmarks
package org.jooq.test.benchmark;
import static org.jooq.example.db.h2.Tables.AUTHOR;
import static org.jooq.example.db.h2.Tables.BOOK;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@lukaseder
lukaseder / Undenotable.java
Created July 7, 2016 14:44
Undenotable types
public class Undenotable {
private interface Secret {}
public <T extends Integer & Secret> T m1() {
return null;
}
public void m2() {
m1();
}
@lukaseder
lukaseder / BetterMapKeyValueCollectionWithJava8.java
Last active August 29, 2016 14:22
Better Map Key/Value collection with Java 8
@Test
public void testBlah() {
Map<Integer, String> map = new HashMap<>();
map.put(10, "apple");
map.put(20, "orange");
map.put(30, "banana");
map.put(40, "watermelon");
map.put(50, "dragonfruit");
// Using Java 8 Stream
@lukaseder
lukaseder / SQL Server EXISTS vs COUNT(*).sql
Created September 18, 2016 17:15
SQL Server EXISTS vs COUNT(*).sql
USE sakila;
DECLARE @ts DATETIME;
DECLARE @repeat INT = 10000;
DECLARE @i INT;
DECLARE @dummy VARCHAR;
DECLARE @s1 CURSOR;
DECLARE @s2 CURSOR;
@lukaseder
lukaseder / sql-developer-not-starting.txt
Created October 2, 2016 17:39
SQL Developer not starting
2016-10-02 19:38:53
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.102-b14 mixed mode):
"Thread-3" #29 daemon prio=5 os_prio=0 tid=0x0000000019574000 nid=0x1964 in Object.wait() [0x000000001d91f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
at java.util.prefs.AbstractPreferences$EventDispatchThread.run(AbstractPreferences.java:1482)
- locked <0x00000000f65d55a0> (a java.util.LinkedList)