Skip to content

Instantly share code, notes, and snippets.

View dtonhofer's full-sized avatar
💭
I may be slow to respond because too much is going on

David Tonhofer dtonhofer

💭
I may be slow to respond because too much is going on
View GitHub Profile
@dtonhofer
dtonhofer / DurationPrinter.java
Created July 19, 2022 19:22
A simple printer for the Java "Duration" type
// Licensed under "The Unlicense" - https://unlicense.org/
package backup.helpers;
import org.jetbrains.annotations.NotNull;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.*;
@dtonhofer
dtonhofer / three_water_jugs.mzn
Last active July 16, 2021 21:04
Three water jugs problem in MiniZinc
% Description of problem:
%
% https://mathworld.wolfram.com/ThreeJugProblem.html
%
% "Given three jugs with x pints in the first, y in the second, and z in the third,
% obtain a desired amount in one of the vessels by completely filling up and/or
% emptying vessels into others."
%
% Standard statement:
%
@dtonhofer
dtonhofer / core.clj
Last active October 9, 2019 13:43
"neighbor" function from page 94 of the Joy Of Clojure, 2nd edition, but modified. Also with pre/post conditions using specs, and test code.
; ===
; "neighbor" function from Chapter 5 (page 94) of the Joy Of Clojure, 2nd edition.
; ...modified and spec-ed!
;
; Applicable license is the unlicense: http://unlicense.org
; except for code taken from "Joy of Clojure, 2nd edition" (i.e. "neighbors-orig"),
; which is distributed under the Eclipse License.
;
; In a Leiningen project called "neighbor", this will be file src/neighbor/core.clj
; The project needs to declare these dependencies:
@dtonhofer
dtonhofer / resize_photos.sh
Last active June 20, 2024 10:22
A shell script around the ImageMagick "convert" command. Shrink jpegs in a source directory to 25% of the original width/height.
#!/bin/bash
# This program passes shellcheck (www.shellcheck.net)
# Author: David Tonhofer
# Complexity: Low
# License: Public Domain / "The Unlicense" - https://unlicense.org/
# Also at https://gist.github.com/dtonhofer/6c44186d65d3b15784b64096e60195a0
# ===
#
# Synopsis:
@dtonhofer
dtonhofer / clean_root_homedir.sh
Last active February 3, 2020 17:25
A simple bash script to delete anything that might have accumulated in root's home directory, i.e. /root
#!/bin/bash
# ===
# Author: David Tonhofer
# Rights: Public Domain
# ===
set -o nounset
ROOT=/root
@dtonhofer
dtonhofer / split_ca_bundle.pl
Last active June 18, 2024 10:05
Split a certificate bundle like "/etc/pki/tls/certs/ca-bundle.crt" into individual certificates labeled by issuer
#!/usr/bin/perl
use strict;
use warnings;
# ===
# Gist:
#
# https://gist.github.com/dtonhofer/01018844971235b511d241b537c332ee
#
@dtonhofer
dtonhofer / installing_confluence_using_another_jre_than_the_embedded_one.txt
Last active May 7, 2019 09:01
How to install Atlassian Confluence (using the "installer" download), using another JRE than the embedded one
How to install Atlassian Confluence (using the "installer" download), using another JRE than the embedded one
=============================================================================================================
- When: 2019-04
- For Confluence 6.15.1
- On Linux/Unix (actually Fedora 29)
- See also: https://jira.atlassian.com/browse/CONFSERVER-57895 "Installing Confluence in OpenSUSE Tumbleweed through the installer fails"
So we have a problem because installation of Confluence using the binary INSTALL4J install module fails:
@dtonhofer
dtonhofer / test_dumper.pl
Last active May 7, 2019 10:32
Comparing behaviour of Perl Data::Dumper when using "Pure Perl" and "XS" mode for non-iso-8859-1 codepoints
#!/usr/bin/perl
# ===
# Testing what Perl's Data::Dumper does with "high" characters e.g.
#
# å -> iso-8859-1 : 0xE5
# Unicode UTF-16 : 0x00E5
# Unicode UTF-8 : 0xC3A5
#
# See also: