Skip to content

Instantly share code, notes, and snippets.

@Ingwersaft
Ingwersaft / git-li-win-mode.sh
Last active August 23, 2019 07:00
Use Linux Git checkout on windows (copied via stick) with minimal pain
git config core.autocrlf false && \
git config core.eol lf && \
git config core.fileMode false
@Ingwersaft
Ingwersaft / TimecampDailyIndustrialHours.kt
Created March 4, 2019 10:41
Timecamp API: Calculate daily time in industrial hours (minutes are 1/100, not 1/60) - Klaxon as deserialization lib
package com.mkring
import com.beust.klaxon.Converter
import com.beust.klaxon.Json
import com.beust.klaxon.JsonValue
import com.beust.klaxon.Klaxon
import java.net.URL
import java.text.DecimalFormat
import java.time.Month
import java.time.YearMonth
@Ingwersaft
Ingwersaft / gist:68d3ff19abc2ffcf73e61d23b6748a02
Created June 18, 2018 15:23
gradle kotlin dsl: runnable uber jar
tasks.withType<Jar> {
manifest {
attributes["Main-Class"] = "<todo>
}
from(configurations.runtime
.filterNot { it.path.endsWith(".pom") }
.map {
if (it.isDirectory) {
it
} else {
@Ingwersaft
Ingwersaft / resilience4j-kotlin.kt
Created November 29, 2017 08:03
Kotlin: small resilience4j example using higher order functions
fun main(args: Array<String>) {
println("start")
val result = tryy {
circuitBreak {
rateLimit {
timeLimit {
"result string"
}
}
@Ingwersaft
Ingwersaft / Cache.kt
Last active September 17, 2018 08:13
Kotlin: lazy loading write expiring cache delegate (analogous to lazy from stdlib)
package com.oneandone.consumer.acs.utils.caching
import org.slf4j.LoggerFactory
import java.time.Instant
import java.time.temporal.ChronoUnit
import kotlin.reflect.KProperty
fun <T> cached(timeout: Long, timeUnit: ChronoUnit, initializer: () -> T): LazyRefreshCache<T> =
LazyRefreshCache(timeout, timeUnit, initializer)