Skip to content

Instantly share code, notes, and snippets.

@Crydust
Crydust / gist:09a550e27d2b5cef79bcbe9560a5e522
Created October 4, 2022 19:08
Trim video and convert to codec known by powerpoint
ffmpeg -i input.webm -ss 00:02:11 -t 00:01:40 -c:v libx264 -c:a aac output.mp4
# PowerPoint supports .mp4 files encoded with H.264 video and AAC audio
# -ss = start time
# -t = duration (after start time)
# -c:v = video codec for output
# -c:a = audio codec for output
@Crydust
Crydust / TransformXml.java
Last active June 24, 2022 13:11
transform xml with an xslt in java
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
@Crydust
Crydust / _ValidationScriptsPartial.cshtml
Last active March 28, 2022 17:38
dotnet webapp validation config
<script src="~/lib/jquery-validate/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
@if (",".Equals(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator))
{
<script>
// decimal separator comma instead of point
jQuery.extend(jQuery.validator.methods, {
number: function(value, element) {
return this.optional(element) || /^-?\d+(?:,\d+)?$/.test(value);
@Crydust
Crydust / App.java
Last active April 2, 2021 10:31
HTTPServer post-process filter (written as answer to https://stackoverflow.com/q/14592299/11451)
package spike;
import com.sun.net.httpserver.Filter;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
@Crydust
Crydust / LoggingMap
Last active February 25, 2021 09:58
a logging map which can replace a HashMap and will log when it is being accessed or altered
import static java.util.stream.Collectors.toUnmodifiableSet;
import java.io.Serializable;
import java.util.AbstractMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
@Crydust
Crydust / ClientApp.java
Created January 24, 2021 19:15
Java socket server and client
package spike;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Timer;
import static java.nio.charset.StandardCharsets.UTF_8;
@Crydust
Crydust / regions-fr.csv
Last active June 8, 2020 11:04
The regions and departments of France including their INSEE number and ISO 3166-2 code. (aka Liste des Départements et Régions en France)
Departement INSEE Region INSEE Departement ISO Region ISO Departement Region
01 84 FR-01 FR-ARA Ain Auvergne-Rhône-Alpes
02 32 FR-02 FR-HDF Aisne Hauts-de-France
03 84 FR-03 FR-ARA Allier Auvergne-Rhône-Alpes
04 93 FR-04 FR-PAC Alpes-de-Haute-Provence Provence-Alpes-Côte d'Azur
05 93 FR-05 FR-PAC Hautes-Alpes Provence-Alpes-Côte d'Azur
06 93 FR-06 FR-PAC Alpes-Maritimes Provence-Alpes-Côte d'Azur
07 84 FR-07 FR-ARA Ardèche Auvergne-Rhône-Alpes
08 44 FR-08 FR-GES Ardennes Grand Est
09 76 FR-09 FR-OCC Ariège Occitanie
@Crydust
Crydust / NaiveMavenVersion.java
Created January 30, 2019 10:31
NaiveMavenVersion Comparable
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Only these three version shemes are supported:
* <ul>
* <li>major[.minor[.incremental]][-buildnumber]</li>
* <li>major[.minor[.incremental]][-qualifier]</li>
* <li>qualifier</li>
@Crydust
Crydust / certificates-in-java-cacerts.bat
Created September 11, 2018 13:35
certificates in java cacerts
REM install a certificate
REM =======================
set KEYTOOL=C:\Workspace\opt\Java\jdk1.8.0_162\bin\keytool
set FILE=D:\home\kristof\Downloads\wildca.cer
set KEYSTORE=C:\Workspace\opt\Java\jdk1.8.0_162\jre\lib\security\cacerts
set ALIAS=certinga.wildca.intermediate
%KEYTOOL% -import -trustcacerts ^
-alias %ALIAS% ^
@Crydust
Crydust / Scratch.java
Last active August 31, 2018 09:13
Java versus Go: a performance comparison (see https://www.bernhardwenzel.com/articles/java-vs-go-performance/ )
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.time.Instant;
import java.time.ZonedDateTime;