Skip to content

Instantly share code, notes, and snippets.

@schauder
schauder / gist:d20f07369c093d9a24e421ac9a1bd6d2
Created September 20, 2023 13:22
ResultSetExtractor for quickly logging a ResultSet
jdbc.query(sql, singletonMap("id", aggregate.id), new ResultSetExtractor<Object>() {
@Override
public Object extractData(ResultSet rs) throws SQLException, DataAccessException {
int columns = rs.getMetaData().getColumnCount();
for (int i = 1; i <= columns; i++) {
if (i > 1) {
System.out.print(", ");
}
System.out.print(rs.getMetaData().getColumnLabel(i));
@schauder
schauder / xletics-packliste.adoc
Last active September 17, 2022 16:34
Xletics und Tough Mudder Packliste

Zwingend

  • Ticket, ausgedruckt

  • Haftungsausschluss

  • Ausweis

Fast zwingend

  • Laufschuhe, viel Profil - anziehen

  • Laufhose, lang

  • Laufshirt, 1x langärmlig

Basis

I take the following as my definition of Truth:

The opinion which is fated to be ultimately agreed to by all who investigate, is what we mean by the truth, and the object represented in this opinion is the real. --by Charles Sanders Peirce.

I considere the following to be a given.

There is no way to know the actual Truth of any relevant statement[1].


1. A statement like "I think therefore I am" might be knowable True but isn’t relevant for anyone but the person stating it.
@schauder
schauder / truth.adoc
Created May 16, 2020 15:41
Thoughts about the evaluation of Truthfulness

Basis

I take the following as my definition of Truth:

The opinion which is fated to be ultimately agreed to by all who investigate, is what we mean by the truth, and the object represented in this opinion is the real. --by Charles Sanders Peirce.

I considere the following to be a given.

There is no way to know the actual Truth of any relevant statement[1].


1. The statement "I think therefore I am" might be knowable True but aren’t relevatn for anyone but the person stating them.
@schauder
schauder / gist:bfb445cdc30ae4f3615cac300ac558fb
Last active July 27, 2018 22:49
Resources about Ethics (in software development)
https://twitter.com/johnsnolan/status/1019871024387641344
https://blog.jonrshar.pe/2018/Jul/17/coed-ethics-2018.html
https://medium.com/code-for-america/the-problem-with-dull-knives-whats-the-defense-department-got-to-do-with-code-for-america-aefe6fe0bf1f
Take a look:
https://www.google.de/search?q=introduction+ethics&rlz=1C5CHFA_enDE730DE731&oq=introduction+ethics
https://www.youtube.com/watch?v=Ssks6y7Xskw Die Maschine erbt ihre Werte von der Gesellschaft in der sie existiert.
https://weaponsofmathdestructionbook.com/
https://www.youtube.com/watch?time_continue=1&v=bmEVrIKCYtU
@schauder
schauder / ResultSetMocking.java
Last active August 16, 2017 08:40
Mocking a ResultSet
static ResultSet mockResultSet(List<String> columns, Object... values) {
Assert.isTrue( //
values.length % columns.size() == 0, //
String //
.format( //
"Number of values [%d] must be a multiple of the number of columns [%d]", //
values.length, //
columns.size() //
) //
@schauder
schauder / MultithreadingWithReactor.java
Created April 15, 2017 09:17
A couple of example tests about Multithreading with Reactor
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.time.Duration;
import org.junit.Test;
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;
@schauder
schauder / GroupWhenKeyFunctionChanges
Last active March 24, 2017 10:56
Reactor Thingies
// Do not use this: since the ChangeTrigger has state it can fail in all kinds of funny ways !!!!!
// similar to Flux::groupBy but closes the GroupedFlux whenever a different key value appears potentially opening another one for the same value later.
@Test
public void groupOnSwitch() {
StepVerifier
.create(
groupOnSwitch(
Flux.just("one", "two", "twenty", "tissue", "berta", "blot", "thousand"),
class $12DynamicWithPixieDustTest extends LambdaBasedTests {{
List<Integer> ints = asList(Integer.MAX_VALUE, Integer.MIN_VALUE, -1, 0, 1, 2, 10);
for (Integer i : ints) {
for (Integer j : ints) {
test(format("adding integers is commutative (%d, %d)", i,j), () -> {
assertEquals(i + j, j + i);
});
}
}
@schauder
schauder / SysoutRule.java
Last active April 23, 2016 14:43
A JUnit rule for testing output to `System.out`
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
public class SysoutRule implements TestRule {
private ByteOutputStream out;
public void contains(String string) {