Skip to content

Instantly share code, notes, and snippets.

@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
@DaHoC
DaHoC / SQLInjectionSample.java
Last active July 21, 2022 10:00
Example code demonstrating SQL injection attack and prevention hereof. Requires a database.
package de.janhendriks;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.ServletException;
@DaHoC
DaHoC / Timespan.java
Last active September 24, 2019 14:43
Calculate potential overlap for 2 given timespans with begin and end
package de.playground.test;
import java.time.Instant;
public class TimespanOverlap {
private Instant begin;
private Instant end;
public TimespanOverlap(Instant begin, Instant end) {
@DaHoC
DaHoC / Java8Tests.java
Created July 10, 2014 09:59
Java 8 playground
package de.janhendriks.java8test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;