Skip to content

Instantly share code, notes, and snippets.

View DanielThomas's full-sized avatar

Danny Thomas DanielThomas

View GitHub Profile
@DanielThomas
DanielThomas / npm-registry.vcl
Created February 19, 2021 01:19
Varnish Plus configuration for public NPM registry
vcl 4.1;
import edgestash;
import goto;
import xbody;
backend default none;
sub vcl_init {
new registry = goto.dns_director("https://registry.npmjs.org");
@DanielThomas
DanielThomas / HashIndex.java
Last active April 22, 2025 01:47
A hash index for primitive numeric values in Java using a twin prime, double hashed hash table
/*
* Copyright 2024 Netflix Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@DanielThomas
DanielThomas / HashIndexTest.java
Last active April 21, 2025 23:48
Tests for HashIndex.java
/*
* Copyright 2024 Netflix Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import java.time.Duration;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.IntStream;
import java.util.stream.Stream;
/**
* Demonstrate potential for deadlock on a {@link ReentrantLock} when there is both a synchronized and
* non-synchronized path to that lock, which can allow a virtual thread to hold the lock, but
* other pinned waiters to consume all the available workers.
Thread responsible for flushing CountBoundedQueue:
#107 "AsyncReporter{com.netflix.tracing.reporter.UdpBytesMessageSender@7a65e842}"
java.base/jdk.internal.misc.Unsafe.park(Native Method)
java.base/java.util.concurrent.locks.LockSupport.park(LockSupport.java:221)
java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:754)
java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1761)
zipkin2.reporter.internal.CountBoundedQueue.drainTo(CountBoundedQueue.java:81)
zipkin2.reporter.internal.AsyncReporter$BoundedAsyncReporter.flush(AsyncReporter.java:241)
zipkin2.reporter.internal.AsyncReporter$Flusher.run(AsyncReporter.java:352)
@DanielThomas
DanielThomas / cds-classpath-mismatch.sh
Created August 20, 2024 05:24
Shared class paths mismatch due to Class-Path manifest entries
#!/bin/bash -xe
dir=$(mktemp -d)
cd "$dir"
touch manifest-empty.txt
cat << EOF > manifest-guice-all.txt
Class-Path: guice-grapher-5.1.0.jar guice-assistedinject-5.1.0.jar guice-dagger-adapter-5.1.0.jar guice-jmx-5.1.0.jar guice-jndi-5.1.0.jar guice-persist-5.1.0.jar guice-struts2-5.1.0.jar guice-servlet-5.1.0.jar guice-spring-5.1.0.jar guice-throwingproviders-5.1.0.jar guice-5.1.0.jar asm-9.6.jar guava-30.1-jre.jar failureaccess-1.0.1.jar listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
EOF