-
Roll-your-own lazy singleton
public final class Single { private static Single INSTANCE; private Single() {}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.aquadc.util; | |
import java.util.Comparator; | |
import java.util.Objects; | |
import java.util.Optional; | |
import java.util.stream.Collector; | |
/** | |
* Stats of a stream of objects, including {@linkplain #size()}, {@linkplain #min()}, and {@linkplain #max()}. | |
* <p>This is intended to be used with {@link java.util.stream.Stream#collect}, for example</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.collections.immutable.PersistentMap | |
import kotlinx.collections.immutable.PersistentSet | |
import kotlinx.collections.immutable.persistentSetOf | |
import kotlinx.collections.immutable.toPersistentMap | |
import org.assertj.core.api.Assertions.assertThat | |
import org.junit.Test | |
class Day18ManyWorldsInterpretation { | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: app/src/main/java/com/techyourchance/multithreading/demonstrations/designcoroutines/ProducerConsumerBenchmarkUseCase.kt | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- app/src/main/java/com/techyourchance/multithreading/demonstrations/designcoroutines/ProducerConsumerBenchmarkUseCase.kt (revision ce962bc96a3224ae27ff8c94ba658946362ce852) | |
+++ app/src/main/java/com/techyourchance/multithreading/demonstrations/designcoroutines/ProducerConsumerBenchmarkUseCase.kt (date 1572347476000) | |
@@ -1,17 +1,16 @@ | |
package com.techyourchance.multithreading.demonstrations.designcoroutines | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
public abstract class BundleKey<T> { | |
@NonNull final String key; | |
BundleKey(@NonNull String key) { | |
this.key = key; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Collection; | |
import java.util.Comparator; | |
import java.util.Deque; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.ListIterator; | |
import java.util.NavigableSet; | |
import java.util.Queue; | |
import java.util.Set; | |
import java.util.SortedSet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Java(?) way | |
interface Fraction<E extends Exception> { | |
int numerator() throws E; | |
int denominator() throws E; | |
} | |
class FracStatic implements Fraction<RuntimeException> // don't force catching | |
class FracSum<E1, E2> implements Fraction<EitherException<E1, E2>> // impossible due to type erasure | |
// Kotlin, Scala, Rust way |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::env; | |
use std::io; | |
use std::io::Write; | |
use std::str::FromStr; | |
#[macro_use] | |
extern crate lazy_static; | |
fn main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.aquadc.recycler; | |
import android.content.Context; | |
import android.graphics.Rect; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.AttributeSet; | |
import android.view.View; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# preverify is useful only for J2ME | |
# R8 doesn't preverify by default | |
#-dontpreverify | |
-optimizationpasses 5 | |
# this seems to be enough | |
# remove indirection | |
-allowaccessmodification |