Skip to content

Instantly share code, notes, and snippets.

View mfuerstenau's full-sized avatar

M. Fürstenau mfuerstenau

  • Germany/Deutschland, Duisburg, Essen, Gelsenkirchen
View GitHub Profile
@mfuerstenau
mfuerstenau / TransactionHandler.java
Created November 2, 2024 17:42
A Service to execute arbitrary code in Spring with MongoDB in transactions, existing or new.
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.function.Supplier;
@Service
public class TransactionHandler {
@Transactional(propagation = Propagation.REQUIRED)
@mfuerstenau
mfuerstenau / Vagrantfile
Created June 27, 2024 09:29
Vagrantfile um n Boxen mit gleichem existierenden Schlüssel zu erzeugen
# -*- mode: ruby -*-
# vi: set ft=ruby :
default_box = "rockylinux/9"
default_cpus = 2
default_mem = 1024
nodes = [
{
ip_addr: '192.168.56.10',
@mfuerstenau
mfuerstenau / SimpleDisjunctionDISI.java
Created September 1, 2021 22:56
Heap based disjunction of multiple DocIdSetIterator instances
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.BitSetIterator;
import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.RoaringDocIdSet;
import java.io.IOException;
public class SimpleDisjunctionDISI extends DocIdSetIterator
{
private final DISIWrapper[] heap;
@mfuerstenau
mfuerstenau / StreamAsIterable.java
Last active August 21, 2016 12:54
Streams can be iterated over in Java 8
public class StreamAsIterable
{
public static void main (String[] args)
{
for (String s : (Iterable<String>) Stream.of ("This", "is", "a", "stream")::iterator)
{
System.out.println (s);
}
}
}
@mfuerstenau
mfuerstenau / zigzag-encoding.README
Last active December 3, 2024 18:25
ZigZag encoding/decoding explained
ZigZag-Encoding
---------------
Maps negative values to positive values while going back and
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
(i >> bitlength-1) ^ (i << 1)
with "i" being the number to be encoded, "^" being
XOR-operation and ">>" would be arithemtic shifting-operation