Skip to content

Instantly share code, notes, and snippets.

View erikhuizinga's full-sized avatar
🤖
Testing droids...

Erik Huizinga erikhuizinga

🤖
Testing droids...
View GitHub Profile
package com.example
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThrows
import org.junit.Test
import org.junit.function.ThrowingRunnable
/**
* JUnit 4.13 test
*/
@erikhuizinga
erikhuizinga / CoroutineCrashes.kt
Created June 30, 2020 16:42
Demo of Kotlin coroutine crash machinery
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
fun main() =
@erikhuizinga
erikhuizinga / 7-wonders-duel-solo.kts
Last active November 13, 2020 20:10
7 Wonders Duel: Solo helper in Kotlin Script
val setup = """
ℹ️ SETUP
Set up the Age I cards like in a normal game, but sit so you're facing the first row of cards in the structure.
The zone to the left of the card structure is your City. The zone to the right of the structure is the Leader's City. Begin the game by giving 7 coins to yourself and none to the Leader.
Shuffle all the Wonder cards and draw 3. Choose 2 of these cards for yourself and give the third to the Leader.
Do this a second time. You will therefore start with 4 Wonder cards in your city and 2 in the Leader's City.
The Leader's 2 Wonder cards are treated as if already constructed. Immediately apply the following effects if they are on the Leader's Wonders:
@erikhuizinga
erikhuizinga / script.main.kts
Last active March 1, 2021 14:02
UniFlow out of order state publishing
// Run with:
// kotlinc -script script.main.kts
@file:Repository("https://jcenter.bintray.com")
@file:DependsOn("io.uniflow:uniflow-core:0.11.6")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5")
import io.uniflow.core.flow.*
import io.uniflow.core.flow.data.UIEvent
import io.uniflow.core.flow.data.UIState