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
@OptIn(FlowPreview::class) | |
fun <A> Flow<A>.ambUsingJobsToCancelRacersAndEmittingFailures( | |
vararg others: Flow<A> | |
): Flow<Either<Throwable, A>> = flow { | |
val parentJob = currentCoroutineContext()[Job]!! | |
(listOf(this@ambUsingJobsToCancelRacersAndEmittingFailures) + others).foldIndexed( | |
Pair(emptyList<Job>(), emptyList<Flow<Pair<Int, Either<Throwable, A>>>>()) | |
) { index, acc, curr -> | |
val job = Job(parentJob) | |
val flow = curr.map { Pair(index, it.right() as Either<Throwable, A>) } |
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
@file:Suppress("UNREACHABLE_CODE") | |
package com.lagostout.extensions | |
interface SystemUnderTest { | |
companion object | |
} | |
//fun SystemUnderTest.f1(): String = "f1" + f2() // Test this first without testing f2 | |
//fun SystemUnderTest.f2(): String = "f2" // Test this second without testing f1 |
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
fun resolveDeepLink( | |
lifecycleScope: LifecycleCoroutineScope, | |
lifecycle: Lifecycle, | |
handler: DefaultScreenDeepLinkHandler, | |
provider: String, | |
json: JSONObject, | |
) { | |
val cancellable = cancelOnLifecycleStopAndRetryOnStartApiCallbackTask<Boolean>( | |
lifecycle, lifecycleScope, { | |
// Do something with result |
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.coroutines.* | |
import java.util.concurrent.ThreadLocalRandom | |
fun main() { | |
val job = GlobalScope.launch { | |
Thread.sleep(1000) | |
try { | |
println(1) | |
withContext(CoroutineName("foo")) { | |
val rnd = ThreadLocalRandom.current() |
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 chapter8.sec3.listing3 | |
import arrow.core.getOrElse | |
import arrow.core.toOption | |
import chapter8.Falsified | |
import chapter8.MaxSize | |
import chapter8.Passed | |
import chapter8.RNG | |
import chapter8.Result | |
import chapter8.SimpleRNG |
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
@file:Suppress("FunctionName") | |
package com.lagostout.bytebybyte.dynamicprogramming | |
import kotlin.math.absoluteValue | |
import kotlin.math.sign | |
object MatrixPath { | |
fun computeWithRecursionAndBruteForce( |
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 com.sense360 | |
class HomeGuesser { | |
/** | |
* A location, consisting of latitude and longitude. | |
* Rounds coordinates provided to 3 decimal places. | |
* Compares by value, not reference. | |
*/ | |
static class Location { |