Skip to content

Instantly share code, notes, and snippets.

View maxs-rose's full-sized avatar
🐉
Rawr

Max Rose maxs-rose

🐉
Rawr
View GitHub Profile
@maxs-rose
maxs-rose / ReflectionSpeedTest.java
Created April 22, 2023 13:18
Speet test comparison of Reflection and a Standard method call in Java
class ReflectionSpeedTest {
public static void main(String[] args) {
var obj = new Test(new Random().nextInt());
Function<Test, Integer> methodRef = Test::getValue;
int COUNT = 100000000;
int r = 0;
// Warmup
for (var i = 0; i < COUNT; i++) {
methodRef.apply(obj);
@maxs-rose
maxs-rose / ExcludeTransitiveDependenciesFilterMultiProject.groovy
Last active December 26, 2022 12:23
Properly generate only top level dependencies for multi project gradle builds when using https://github.com/jk1/Gradle-License-Report
import com.github.jk1.license.ModuleData
import com.github.jk1.license.ProjectData
import com.github.jk1.license.filter.DependencyFilter
import org.gradle.api.artifacts.ConfigurationContainer
import org.gradle.api.artifacts.ResolvedDependency
import java.util.stream.Collectors
import java.util.stream.Stream
public class ExcludeTransitiveDependenciesFilterMultiProject implements DependencyFilter {
@maxs-rose
maxs-rose / Events.kt
Created May 31, 2020 15:57
Lightweight C# style events in Kotlin
fun <T> event() = SetEvent<T>()
fun <T> namedEvent() = MapEvent<T>()
object EventBus {
//to use
val exampleSetEvent = event<int>()
}
open class SetEvent<T> private constructor(private val backing: MutableSet<(T) -> Unit>) : AbstractEvent<T>(), MutableCollection<(T) -> Unit> by backing {
constructor() : this(HashSet())