Skip to content

Instantly share code, notes, and snippets.

Avatar

Lukas Eder lukaseder

View GitHub Profile
@lukaseder
lukaseder / count-asterisk-vs-count-1-postgres.sql
Created Sep 19, 2019
COUNT(*) vs COUNT(1) in PostgreSQL
View count-asterisk-vs-count-1-postgres.sql
-- Copyright Data Geekery GmbH
--
-- Licensed 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
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
View postgis-mandelbrot.sql
with recursive
dims (r1, r2, i1, i2, s, it, p) as (values (-2::float, 1::float, -1.5::float, 1.5::float, 0.01::float, 100, 256.0::float)),
sprites (s) as (values (st_makepolygon(st_geomfromtext('linestring (0 0, 0 1, 1 1, 1 0, 0 0)')))),
n1 (r, i) as (select r, i from dims, generate_series((r1 / s)::int, (r2 / s)::int) r, generate_series((i1 / s)::int, (i2 / s)::int) i),
n2 (r, i) as (select r::float * s::float, i::float * s::float from dims, n1),
l (cr, ci, zr, zi, g, it, p) as (
select r, i, 0::float, 0::float, 0, it, p from n2, dims
union all
select cr, ci, zr*zr - zi*zi + cr, 2 * zr * zi + ci, g + 1, it, p from l where g < it and zr*zr + zi*zi < p
),
@lukaseder
lukaseder / git.log
Created Sep 14, 2021
Cherry picking and merging shouldn't produce conflicts per se
View git.log
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ ll
total 1
-rw-r--r-- 1 lukas 197609 12 Sep 14 19:50 test.txt
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ cat test.txt
a
b
c
View postgresql-flat-vs-nested-rows.sql
-- Copyright Data Geekery GmbH
--
-- Licensed 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
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
@lukaseder
lukaseder / PublisherVerificationJUnit.java
Last active Apr 2, 2021
A JUnit 4 to TestNG bridge for the PublisherVerification
View PublisherVerificationJUnit.java
/*
* Copyright Data Geekery GmbH
*
* Licensed 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
*
* Unless required by applicable law or agreed to in writing, software
View JDBCSpeedTest.java
package org.jooq.testscripts;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Statement;
import org.jooq.SQLDialect;
import org.jooq.test.setup.DatabaseSetup;
import org.jooq.test.setup.DatabaseSetup.Config;
import org.jooq.tools.StopWatch;
View TwoMains.java
public class TwoMains {
public static void main(String[] args) {
System.out.println("main");
mаin(args);
}
public static void mаin(String[] args) {
System.out.println("other mаin");
}
}
@lukaseder
lukaseder / SimplifyThis.java
Last active Sep 8, 2020
SimplifyThis.java
View SimplifyThis.java
List<MappedTable> mappedTables1() {
if (mappedTables == null) {
mappedTables = T_BOOK
.getSchema()
.getTables()
.stream()
.map(t -> {
Table<?> l = lookupTable(t.getName());
return l == null ? null : new MappedTable().withInput(t.getName()).withOutput(l.getName());
})
View ListSurprise.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class ListSurprise {
public static void mаin(String[] args) {
System.setSecurityManager(new SecurityManager());
List<Integer> numbers = new ArrayList<>();
Collections.addAll(numbers, 3, 1, 4, 1, 5, 5, 9);
View gist:1bc2ea085a36d275b7e2df3f1ab1ce17
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import sun.misc.Unsafe;