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 XCTest | |
final class TaskGroupExtensionTest: XCTestCase { | |
func testWhenAll() async throws { | |
// 모든 Task 가 완료될 때 까지 기다리고 인자 순서대에 맞춰서 결괏값 목록 반환 | |
// Act | |
let results = await TaskGroup.whenAll( | |
{ await self.fetchTestDataAsync(numberOfInvocation: 0, delay: .microseconds(100)) }, | |
{ await self.fetchTestDataAsync(numberOfInvocation: 1, delay: .microseconds(100)) }, | |
{ await self.fetchTestDataAsync(numberOfInvocation: 2, delay: .microseconds(100)) }, |
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 im.toss.home.batch | |
import io.github.resilience4j.kotlin.ratelimiter.executeSuspendFunction | |
import io.github.resilience4j.ratelimiter.RateLimiter | |
import io.github.resilience4j.ratelimiter.RateLimiterConfig | |
import io.github.resilience4j.ratelimiter.RateLimiterRegistry | |
import mu.KotlinLogging | |
import org.junit.jupiter.api.Test | |
import java.time.Duration | |
import java.time.LocalDateTime |
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.lang.Exception | |
fun main() { | |
runrunrun { | |
defer { println("HI") } | |
defer { println("HI") } | |
defer { println("HI") } | |
println("HELLO") | |
println("HELLO") |
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
type NativeMethodRequest<TParams> = { | |
invocationId: string; | |
methodName: string; | |
params?: TParams; | |
}; | |
type NativeMethodResponse = { | |
invocationId: string; | |
callbackType: 'resolve' | 'reject'; | |
value?: any; |
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 Foundation | |
extension DispatchTimeInterval { | |
func asTimeInterval() -> TimeInterval { | |
switch self { | |
case let .nanoseconds(value): return Double(value) / 1_000_000_000 | |
case let .microseconds(value): return Double(value) / 1_000_000 | |
case let .milliseconds(value): return Double(value) / 1_000 | |
case let .seconds(value): return Double(value) | |
case .never: return Double.infinity |
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
fun anyOf( | |
items: Collection<Predicate>, | |
): BooleanBuilder = BooleanBuilder().andAnyOf(*items.toTypedArray()) | |
fun anyOf( | |
vararg args: Predicate?, | |
): BooleanBuilder = andAnyOf(args.filterNotNull()) | |
fun allOf( | |
items: Collection<Predicate>, |
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 com.fasterxml.jackson.databind.ObjectMapper | |
import org.springframework.core.convert.TypeDescriptor | |
import org.springframework.core.convert.converter.GenericConverter | |
import org.springframework.stereotype.Component | |
@Component | |
class JsonConverter( | |
private val objectMapper: ObjectMapper | |
) : GenericConverter { | |
override fun getConvertibleTypes() = mutableSetOf( |
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 kotlinx.coroutines.sync.Semaphore | |
import java.util.concurrent.ConcurrentLinkedQueue | |
open class ObjectPool<T : Any>( | |
capacity: Int, | |
private val instanceFactory: () -> T, | |
) { | |
private val semaphore = Semaphore(permits = capacity) | |
private val queue = ConcurrentLinkedQueue<T>() |
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
class JsonObjectSpliterator<T>( | |
private val mapper: ObjectMapper, | |
private val inputStream: InputStream, | |
private val clazz: Class<T> | |
) : Spliterators.AbstractSpliterator<T>(Long.MAX_VALUE, NONNULL or IMMUTABLE) { | |
private val parser: JsonParser by lazy { | |
mapper.createParser(inputStream.reader(Charsets.UTF_8)).also { | |
check(it.nextToken() === JsonToken.START_ARRAY) { "Expected content to be an array" } | |
} | |
} |
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
fun WebView.disableTouchCalloutAndUserSelect() { | |
this.evaluateJavascript(""" | |
(function() { | |
const head = document.getElementsByTagName('head')[0]; | |
const style = document.createRange().createContextualFragment(` | |
<style type="text/css"> | |
*:not(input):not(textarea) { | |
-webkit-touch-callout: none; | |
-webkit-user-select: none; | |
} |
NewerOlder