Skip to content

Instantly share code, notes, and snippets.

Dr. Hans-Peter Störr stoerr

Block or report user

Report or block stoerr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stoerr
stoerr / LockAsAutoCloseable.java
Last active Nov 6, 2019
Allows using a java.util.concurrent.lock in a Java try-with-resources statement
View LockAsAutoCloseable.java
import javax.annotation.Nonnull;
import java.util.Objects;
import java.util.concurrent.locks.Lock;
/**
* Allows using a {@link java.util.concurrent.locks.Lock} with a try with resources, e.g.:
* <code> try (LockAsAutoCloseable locked = LockAsAutoCloseable.lock(lock)) { ... } </code> .
*/
@SuppressWarnings("LockAcquiredButNotSafelyReleased")
public class LockAsAutoCloseable implements AutoCloseable {
@stoerr
stoerr / threaddump.jsp
Last active Oct 8, 2019
Configurable dump of all threads with a configurable set of stati, equivalent stacktraces collected
View threaddump.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%--
This JSP lists all threads with stati as configured in a checklist, optionally whose names match a specified regex.
If two threads have the same stacktrace, they are shown together and the stacktrace is printed only once.
--%>
<%@page import="java.util.*"%>
<%@page import="javax.servlet.*"%>
<%@page import="java.io.*"%>
@stoerr
stoerr / PredictVariability.ipynb
Created May 20, 2019
Estimation of mean and variance of a stochastic process with a neural network
View PredictVariability.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stoerr
stoerr / AutomaticTextGenerationCharbased.ipynb
Created May 16, 2019
Simple automatic language like text generation via a Tensorflow neural network
View AutomaticTextGenerationCharbased.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stoerr
stoerr / prepare-commit-msg
Created Apr 12, 2019
Automatically include ticket number from branch name into git commit messages
View prepare-commit-msg
#!/bin/bash
# If you use branch names with JIRA ticket numbers in them, e.g. feature/ABC-4324-do-something,
# this includes automatically the ticket number (ABC-4324) at the start of the the commit message.
# This way, it's later easy to see which change was done for which ticket, without any manual effort.
# You need to copy or link this file into .git/hooks/prepare-commit-msg
# You can customize which branches should be skipped when prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
@stoerr
stoerr / GenerateFelixPom.groovy
Created Feb 21, 2019
Creates a pom.xml in the directory a Sling launchpad runs for all JARs deployed in the Felix OSGI container there, enabling to import these easily into the IDE and download the sources/javadocs as well
View GenerateFelixPom.groovy
import java.util.zip.ZipFile
println("Run in launchpad")
File topfile = new File("sling").canonicalFile
def pom = new FileWriter("pom.xml")
pom.append("""<?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/maven-v4_0_0.xsd">
@stoerr
stoerr / symbMathTermDifferentiate.pl
Last active Aug 2, 2017
Prolog snippet with term replacement system for symbolic differentiation (not quite complete)
View symbMathTermDifferentiate.pl
rule(0+X,X).
rule(X+0,X).
rule(1*X,X).
rule(X*1,X).
rule(1*X,X).
rule(0*_,0).
rule(_*0,0).
rule(sum(_,0),0).
rule((X+Y)*Z, (X*Z)+(Y*Z)).
@stoerr
stoerr / tilesgraph.xslt
Created Sep 29, 2014
Makes graph of tiles 1 definition extensions in dotty / graphviz format
View tilesgraph.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="text" />
<xsl:template match="/" >
<xsl:text>digraph tilesdefs {
ranksep="2";
</xsl:text>
<xsl:for-each select="/tiles-definitions/definition[@extends]">
@stoerr
stoerr / pom2dotty.xslt
Created Sep 29, 2014
Prints dependencies of a multi module maven project as graph in dotty / graphviz format
View pom2dotty.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pom="http://maven.apache.org/POM/4.0.0">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
<!--
Generiert Fragment von dotty-File für die Pom-Abhängigkeiten.
Anwendung:
(
echo "digraph PomDependencies {"
find . -name pom.xml | xargs xsltproc pom2dotty.xslt | sort -u
echo "}"
@stoerr
stoerr / FileDupFinder.scala
Last active Apr 26, 2019
Finds duplicate files (i.e., with the same content) in a given set of directories.
View FileDupFinder.scala
package net.stoerr.dirdupfinder
import java.nio.ByteBuffer
import java.nio.file.{FileSystems, Files, Path, StandardOpenOption}
import java.security.MessageDigest
import sun.misc.BASE64Encoder
import scala.collection.JavaConversions._
You can’t perform that action at this time.