This file contains hidden or 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.jivimberg.sqs.published | |
import kotlinx.coroutines.CancellationException | |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.isActive | |
import kotlinx.coroutines.yield | |
import java.lang.Thread.currentThread | |
suspend fun CoroutineScope.repeatUntilCancelled(block: suspend () -> Unit) { | |
while (isActive) { |
This file contains hidden or 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.io.FileOutputStream | |
import java.nio.file.Path | |
import java.util.zip.ZipInputStream | |
tailrec fun ZipInputStream.extract(outputDir: Path, extractedFiles: List<Path>) : List<Path> = | |
nextEntry?.let { ze -> | |
val zf = outputDir.resolve(ze.name).apply { | |
toFile().outputStream().use { | |
fileForZipEntry(it) | |
} |
This file contains hidden or 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
def sum = {a, b -> return a + b } | |
def square = {a -> return a * a } | |
def composition = {f, g, a, b -> f(g(a), g(b))} | |
def sumOfSquares = composition.curry(sum, square) | |
def sumOfSquaresOfTwoLargestNumbers(a, b, c) { | |
if ((a < b) && (a < c)) return sumOfSquares(b, c) | |
else if ((b < a) && (b < c)) return sumOfSquares(a, c) |