Skip to content

Instantly share code, notes, and snippets.

@tomwhoiscontrary
tomwhoiscontrary / index.txt
Created June 12, 2022 20:11
Upgrading from Fedora 34 to Fedora 36
Following https://docs.fedoraproject.org/en-US/quick-docs/dnf-system-upgrade/
# main upgrade
dnf upgrade --refresh
dnf install dnf-plugin-system-upgrade
dnf system-upgrade download --releasever=36
dnf system-upgrade reboot
# refresh all locally modified config files
dnf install rpmconf
@tomwhoiscontrary
tomwhoiscontrary / HasFeature.java
Created April 26, 2022 15:37
Back on my bullshit once more. The minimal, getter-only version of lambda-property-matcher.
import org.hamcrest.FeatureMatcher;
import org.hamcrest.Matcher;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.io.UncheckedIOException;
import java.lang.invoke.SerializedLambda;
import java.util.Objects;
@tomwhoiscontrary
tomwhoiscontrary / DoesWhatTheJavadocSaysTest.java
Created September 1, 2021 19:08
Parsing a sequence of JSON values that are not enclosed in a JSON array - https://github.com/leadpony/joy/issues/14
import jakarta.json.Json;
import jakarta.json.JsonValue;
import jakarta.json.stream.JsonParser;
import org.junit.jupiter.api.Test;
import java.io.StringReader;
public class DoesWhatTheJavadocSaysTest {
@Test
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
public class WhenDoPeriodsStart {
public static void main(String[] args) {
Locale locale = Locale.forLanguageTag(args[0]);
System.out.println("vendor = " + System.getProperty("java.vm.vendor"));
@tomwhoiscontrary
tomwhoiscontrary / journal.2021-06-26T19:20:27.868675+0100.log
Created June 26, 2021 18:57
Machine never recovers from suspend - those logs in full
-- Journal begins at Tue 2020-07-07 21:08:36 BST, ends at Sat 2021-06-26 19:32:45 BST. --
2021-06-26T19:20:27.868675+0100 rife kernel: microcode: microcode updated early to revision 0xea, date = 2021-01-25
2021-06-26T19:20:27.868703+0100 rife kernel: Linux version 5.12.12-300.fc34.x86_64 (mockbuild@bkernel01.iad2.fedoraproject.org) (gcc (GCC) 11.1.1 20210531 (Red Hat 11.1.1-3), GNU ld version 2.35.1-41.fc34) #1 SMP Fri Jun 18 14:30:51 UTC 2021
2021-06-26T19:20:27.868714+0100 rife kernel: Command line: BOOT_IMAGE=(hd0,gpt2)/vmlinuz-5.12.12-300.fc34.x86_64 root=/dev/mapper/fedora_localhost--live-root ro resume=/dev/mapper/fedora_localhost--live-swap rd.lvm.lv=fedora_localhost-live/root rd.luks.uuid=luks-53565114-c06e-4499-9365-4302e0eb1b2c rd.lvm.lv=fedora_localhost-live/swap rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1
2021-06-26T19:20:27.868721+0100 rife kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
2021-06-26T19:20:27.868727+0100 rif
@tomwhoiscontrary
tomwhoiscontrary / colour-scale.html
Created May 12, 2021 20:43
Demo of (ab)using CSS animations to apply a (non-animated!) colour scale
<!DOCTYPE html>
<html>
<head>
<style>
@keyframes colour-scale {
0% {
background-color: red;
}
50% {
@tomwhoiscontrary
tomwhoiscontrary / Class1.java
Last active February 16, 2021 18:44
Some code in need of good names
public class Class1 {
public static <Type1, Type2 extends Collection<Type1>> Type2 method(Supplier<Type2> parameter1, Collection<Type1> parameter2, Collection<Type1> parameter3) {
Type2 variable = Stream.concat(parameter2.stream()
.filter(Predicate.not(parameter3::contains)),
parameter3.stream()
.filter(Predicate.not(parameter2::contains)))
.collect(Collectors.toCollection(parameter1));
return variable;
}
@tomwhoiscontrary
tomwhoiscontrary / Foo.java
Created January 20, 2021 12:32
A function that does something with streams ... but what?
class Foo {
public static <T> Function<T, Stream<T>> foo(Predicate<T> predicate) {
return new Function<>() {
private T previous;
@Override
public Stream<T> apply(T current) {
if (predicate.test(current)) {
if (previous != null) {
T previous = this.previous;
import jakarta.json.JsonObject;
import jakarta.json.spi.JsonProvider;
import jakarta.json.stream.JsonParser;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
public class ParseTest {
@tomwhoiscontrary
tomwhoiscontrary / ThresholdMap.java
Created January 5, 2021 15:55
Crappy threshold maps for dithering, following https://news.ycombinator.com/item?id=25645286
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;