Skip to content

Instantly share code, notes, and snippets.

View retheviper's full-sized avatar
🏠
Working from home

Youngbin Kim retheviper

🏠
Working from home
View GitHub Profile
@retheviper
retheviper / CoroutineNetworkRequestController.kt
Last active May 5, 2022 13:14
Spring MVC coroutine example
@RestController
@RequestMapping("/requests")
class CoroutineNetworkRequestController {
private val url = "https://en.wikipedia.org/api/rest_v1/page/summary"
private val logger = LogManager.getLogger(CoroutineNetworkRequestController::class.java)
/**
* do request with async and awaitAll
*/
@retheviper
retheviper / GetTen.kt
Last active April 1, 2022 12:27
1, 3, 3, 7 to 10
import kotlin.random.Random
fun main() {
while (true) {
val (result, expression) = calculate()
if (result == 10.0) {
println("${expression.removeSurrounding("(", ")")} = ${result.toInt()}")
break
}
}
@retheviper
retheviper / MontyHall.kt
Created October 23, 2021 03:53
Monty hall problem is kotlin
import kotlin.system.measureTimeMillis
const val GOAT = "goat"
const val CAR = "car"
const val OUT = "out"
val RANGE = (0..2)
/**
* put a car behind one door
*/
@retheviper
retheviper / MimeTypes.kt
Last active June 21, 2023 06:52 — forked from dptsolutions/MimeTypes.kt
Standard MIME type constants ready to use in a Kotlin project
/**
* See [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml) of IANA.
*/
object MimeTypes {
enum class Application(val extensions: Array<String>, val mimeType: String) {
/** AbiWord document */
ABI_WORD(arrayOf(".abw"), "application/x-abiword"),
/** Archive document (multiple files embedded) */