Skip to content

Instantly share code, notes, and snippets.

@bastman
bastman / generics.kt
Last active December 23, 2019 07:15
kotlin generics playground
// The ins and outs of Kotlin: https://kotlin.christmas/2019/22
// https://medium.com/@elye.project/in-and-out-type-variant-of-kotlin-587e4fa2944c
// https://kotlinlang.org/docs/reference/generics.html
// https://www.reddit.com/r/Kotlin/comments/dtfba1/covariance_vs_invariance/
// https://i.imgur.com/oKD9hPL.png
// https://docs.google.com/document/d/13eRz9uu8EuAUagcwEvLDUoWYB7TOyMgJWJyFLJnSB10/
// https://typealias.com/guides/ins-and-outs-of-generic-variance/
@bastman
bastman / minutest-testfactory-example.kt
Last active December 19, 2019 09:05
kotlin-minutest: the missing docs ... how to use @testfactory
// see: https://github.com/dmcg/minutest/blob/master/docs/README.md
// see: https://github.com/dmcg/minutest/blob/master/docs/installation.md
// gradle dependency (jcenter): testImplementation("dev.minutest:minutest:1.9.+")
// how to use?
class FooTests {
@TestFactory
fun `some dynamic tests`() = rootContext {
test(name="a test") {
@bastman
bastman / nullable.kt
Created October 31, 2019 12:17
kotlin reified T is nullable ?
// https://gist.github.com/dant3/1c5f8ba8555cadb0c418523de7857e50
inline fun <reified T> isNullable(): Boolean = null is T
@bastman
bastman / awesome-shell.md
Last active October 16, 2019 07:49
awesome shell implementations
@bastman
bastman / FooTest.kt
Last active October 15, 2019 13:05
jackson-module-kotlin-issue-130
package com.example
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import org.junit.jupiter.api.Test
/**
@bastman
bastman / BlobStorageUri.kt
Created August 7, 2019 07:30
BlobStorageUri (kotlin, jackson)
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonValue
data class BlobStorageUri(
val account: String,
val container: String,
val key: String
) {
val uri: String
@bastman
bastman / psql_sslmode.sh
Created May 3, 2019 05:57
psql set sslmode
# https://stackoverflow.com/questions/14021998/using-psql-to-connect-to-postgresql-in-ssl-mode
$ export PGSSLMODE=prefer
$ psql ...