Skip to content

Instantly share code, notes, and snippets.

View lukaseder's full-sized avatar

Lukas Eder lukaseder

View GitHub Profile
@lukaseder
lukaseder / short-circuiting-bool-or.sql
Last active February 22, 2024 09:31
short-circuiting-bool-or.sql
create table t (b boolean);
create table f (b boolean);
insert into t select true from generate_series(1, 1000000);
insert into f select false from generate_series(1, 1000000);
DO $$
DECLARE
v_ts TIMESTAMP;
v_repeat CONSTANT INT := 100;
rec RECORD;
@lukaseder
lukaseder / connect-by-vs-with-recursive-oracle.sql
Created November 17, 2022 14:25
connect-by-vs-with-recursive-oracle.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 / postgis-mandelbrot.sql
Created November 14, 2021 10:03
PostGIS Mandelbrot
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 September 14, 2021 17:57
Cherry picking and merging shouldn't produce conflicts per se
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
-- 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 April 2, 2021 09:46
A JUnit 4 to TestNG bridge for the PublisherVerification
/*
* 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
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;
@lukaseder
lukaseder / SimplifyThis.java
Last active September 8, 2020 08:02
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());
})
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");
}
}
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);