Skip to content

Instantly share code, notes, and snippets.

@DaHoC
DaHoC / pom.xml
Created January 30, 2023 12:25
Dependency conversion issue reproducer
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>SpringKafkaDependencyIssue</artifactId>
<version>1.0-SNAPSHOT</version>
@DaHoC
DaHoC / AsyncWaitForConditionWithCountDownLatch.java
Created January 6, 2023 13:01
AsyncWaitForConditionWithCountDownLatch
/**
* Generic method that properly awaits a given condition to become true within a given timeout.
* This is superior to {@code sleep()} methods because it returns early when the condition is met.
*
* @param boolSupplier the supplier for evaluating the condition, should return {@code true} if condition is met, {@code false} otherwise
* @param timeout timeout number
* @param timeUnit timeout unit
* @return {@code true} if condition is met within given time, {@code false} otherwise
*/
private boolean waitForCondition(final BooleanSupplier boolSupplier, long timeout, final TimeUnit timeUnit) {
package com.kaput.littlehelper;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;
/**
* Helper class to be able to use a{@link Iterator} (i.e. {@link java.util.stream.Stream}) with {@link Enumeration}.
* This can be useful, i.e.:
@DaHoC
DaHoC / JUnitReportTestDurationPieChart.html
Created March 21, 2019 15:01
JUnit test reports (e.g. exported by Eclipse) overview of testsuite durations
<html>
<head>
<title>JUnit Test Report Pie Chart over test durations</title>
<meta content="">
<style></style>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
// Load google charts
google.charts.load('current', {'packages':['corechart']});
// google.charts.setOnLoadCallback(drawChart);
@DaHoC
DaHoC / BackpropagationOfError.tex
Created January 21, 2019 08:35
Derivation of "backpropagation of error" formula for a Multi-Layer-Perceptron, written in LaTeX
\documentclass[10pt, a4paper]{article}
\usepackage[english,ngerman]{babel}
\usepackage{amsmath, amssymb, wasysym}
\usepackage{textcomp}
\usepackage{graphicx} % Graphics package
%\usepackage{graphs} % c.f. http://www8.cs.umu.se/~drewes/graphs/
\usepackage{tikz}
\usepackage[T1]{fontenc}
% \usepackage[latin9]{inputenc} % Encoding
@DaHoC
DaHoC / testIpRange.php
Last active December 18, 2018 12:53
IP range check in PHP - This function checks if a given IP address is in a given IP range. It should be much more efficient than the ip2long / long2ip functions that come with PHP that can only be used for IPv4 and have polynomial costs
<?php
/*
> CONTACT:
Jan Hendriks
http://www.gawe-design.de
info@gawe-design.de
> DESCRIPTION:
The functions (you can also use them via php-include) checks if a given IP is in a given IP range
These functions are much more efficient than the ip2long / long2ip functions from php that can only be used for IP v4 and have polynomial costs
These functions are about O(number of positions), e.g. IP v.4: O(4); (I think)
import org.primefaces.component.orderlist.OrderList;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import java.util.List;
import java.util.Objects;
/**
* Generic converter for primefaces component (orderList).
@DaHoC
DaHoC / PfPicklistConverter.java
Last active February 15, 2018 12:37
Primefaces Picklist converter
import org.primefaces.component.picklist.PickList;
import org.primefaces.model.DualListModel;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import java.util.List;
import java.util.Objects;
/**
@DaHoC
DaHoC / opencv_2class_boosting_example.cpp
Created September 8, 2015 09:56
Simple demo program showing how to use boosting in openCV
/*
* Simple demo program showing how to use boosted training in openCV
* File: opencv_2class_boosting_example.cpp
* Author: Jan Hendriks, JanHendriks@web.de, http://www.janhendriks.de
*
* Created on 18. August 2011, 13:55
*/
#include <cstdlib>
#include "opencv/cv.h"
@DaHoC
DaHoC / ximage2opencvimage.cpp
Last active July 26, 2018 13:47
Example program showing conversion of an image in the X11 XImage format to the openCV format IplImage (by demonstrating the XImage2OpenCVImage function below). The minimalistic program takes a screenshot of a specified area using XGetImage(...), converts the resulting XImage to IplImage and shows the resulting openCV image until the user presses…
/**
* Example program showing conversion of an image in the X11 XImage format to the openCV format IplImage
* (by demonstrating the XImage2OpenCVImage function below)
* The minimalistic program takes a screenshot of a specified area using XGetImage(...),
* converts the resulting XImage to IplImage and shows the resulting openCV image until the user presses a key.
*
* Compile with opencv linker flags (`pkg-config --libs opencv`) e.g.
* $ g++ ximage2opencvimage.cpp -L `pkg-config --libs opencv` -o ximage2opencvimage && ./ximage2opencvimage
*
* @File: ximage2opencvimage.cpp