Skip to content

Instantly share code, notes, and snippets.

@GeePawHill
GeePawHill / gist:f555b2a91761363f559ff95e41609128
Created February 26, 2024 17:18
The NormalModel "before" picture.
package org.currytree
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
@GeePawHill
GeePawHill / gist:fcdea0e919bf1c53aaee78aaca408015
Created December 27, 2023 19:59
A sample sketch of an idea in code
/*
Can't say this here, business doesn't know Node
class BlockFactory {
fun nodeFor(block:TextBlock):Node {
Make the correct node given that it's a text block and return it.
}
fun nodeFor(block:TodoBlock):Node {
@GeePawHill
GeePawHill / Snippet from build.gradle.kts
Created November 6, 2023 18:14
Actual action file for release-on-push arrangement.
fun makeBuildString(properties: Properties): String {
val build = project.properties["BUILD"]
if (build == null) return "0-DEV"
val numeric_build = Integer.valueOf(build.toString())
val numeric_minor_offset = Integer.valueOf(properties["minor_offset"].toString())
val trueBuild = numeric_build - numeric_minor_offset
return "$trueBuild-RELEASE"
}
tasks.register("generateVersionString") {
class TestTimerFactory : TimerFactory, Timer {
var tick: (now: Long) -> Unit = {}
override fun makeTimer(tick: (now: Long) -> Unit): Timer {
this.tick = tick
return this
}
override fun start() {
package org.geepawhill.admin
import org.apache.commons.io.FileUtils
import java.nio.file.Files
import java.nio.file.Path
class ContentFolder(val root: Path) {
operator fun get(first: String, vararg parts: String): String {
val resolvedPath = root.resolve(Path.of(first, *parts))
return this[resolvedPath]
@GeePawHill
GeePawHill / Kotlin Code snippet
Created February 19, 2023 03:53
gph-html snippets
label {
selectorAs("check-label") {
padding.top += 20.px
font_size += 30.px
color += white
float += right
line_height += 80.px
margin.right += 40.px
declarations["cursor"] = "pointer"
display += block
val page = HtmlPageDelegate.page {
head {
stylesheet {
selector("*") {
display += block
}
}
}
body {
div("stinky") {
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import kotlin.reflect.KClass
import kotlin.reflect.full.isSuperclassOf
/*
Marker interface. Anything that's a message can be sent across the wire.
*/
interface Message
@GeePawHill
GeePawHill / gist:e37fac2a11604801a617061b77a03f6f
Created September 22, 2022 15:59
Third Version of Test Code
@Test
fun `sulfuras never changes`() {
assertBeforeAndAfter(SULFURUS_NAME, Int.MAX_VALUE, 80, Int.MAX_VALUE,80)
}
@Test
fun `sulfuras never changes even with weird values`() {
// NOTE: Gilded rose does not enforce quality or sellin for sulfuras
assertBeforeAndAfter(SULFURUS_NAME,-1,-3,-1,-3)
}
@GeePawHill
GeePawHill / gist:4ccd8718129723be636e324808f54682
Created September 22, 2022 15:52
Second rework of test.
@Test
fun `sulfuras never changes`() {
val item = updateQuality(Item(SULFURUS_NAME, Int.MAX_VALUE, 80))
with(item) {
assertThat(name).isEqualTo(SULFURUS_NAME)
assertThat(sellIn).isEqualTo(Int.MAX_VALUE)
assertThat(quality).isEqualTo(80)
}
}