Skip to content

Instantly share code, notes, and snippets.

View file.dat
1 0.000000
2 0.301030
3 0.477121
4 0.602060
5 0.698970
6 0.778151
7 0.845098
8 0.903090
9 0.954243
10 1.000000
@tomwhoiscontrary
tomwhoiscontrary / index.txt
Created Jun 12, 2022
Upgrading from Fedora 34 to Fedora 36
View index.txt
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 Apr 26, 2022
Back on my bullshit once more. The minimal, getter-only version of lambda-property-matcher.
View HasFeature.java
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 Sep 1, 2021
Parsing a sequence of JSON values that are not enclosed in a JSON array - https://github.com/leadpony/joy/issues/14
View DoesWhatTheJavadocSaysTest.java
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
View WhenDoPeriodsStart.java
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 Jun 26, 2021
Machine never recovers from suspend - those logs in full
View journal.2021-06-26T19:20:27.868675+0100.log
-- 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
Demo of (ab)using CSS animations to apply a (non-animated!) colour scale
View colour-scale.html
<!DOCTYPE html>
<html>
<head>
<style>
@keyframes colour-scale {
0% {
background-color: red;
}
50% {
@tomwhoiscontrary
tomwhoiscontrary / Class1.java
Last active Feb 16, 2021
Some code in need of good names
View Class1.java
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 Jan 20, 2021
A function that does something with streams ... but what?
View Foo.java
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;
View ParseTest.java
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 {