This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.javalin.rendering.template | |
import io.javalin.http.Context | |
import io.javalin.rendering.FileRenderer | |
import io.javalin.rendering.util.RenderingDependency.PEBBLE | |
import io.javalin.util.DependencyUtil | |
import io.javalin.util.OptionalDependency | |
import io.pebbletemplates.pebble.PebbleEngine | |
import io.pebbletemplates.pebble.loader.ClasspathLoader | |
import java.io.StringWriter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## Re: https://stackoverflow.com/questions/48644841/multiple-addn-hosts-conf-in-dnsmasq | |
## | |
## You may specify multiple addn-hosts on dnsmasq.conf | |
addn-hosts=/srv/dnsmasq/dns-configs/db.10.0.31.hosts | |
addn-hosts=/srv/dnsmasq/dns-configs/db.10.0.32.hosts | |
## : | |
## : | |
## etc | |
## : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bugs | |
import kotlin.random.Random.Default.nextBoolean | |
object IncorrectConditionIsAlwaysFalse { | |
private fun conditionA() = nextBoolean() | |
private fun conditionB() = nextBoolean() | |
data class Action(val list: List<Int>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Barcode Webfont Example</title> | |
<link href="https://fonts.googleapis.com/css2?family=Libre+Barcode+39+Extended+Text&display=swap" rel="stylesheet"> | |
<style type="text/css"> | |
.barcode39 { | |
font-family: 'Libre Barcode 39 Extended Text', cursive; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub investigatePrinterPaperSizeSituation() | |
Dim printerList As PrinterSettings.StringCollection = PrinterSettings.InstalledPrinters() | |
For Each printer As String In printerList | |
_logger.logInfo("found printer: " & printer) | |
Dim settings As PrinterSettings = new PrinterSettings() | |
'' So...., check this out: | |
settings.PrinterName = printer | |
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.DayOfWeek | |
import java.time.LocalDate | |
fun LocalDate.lastDayOfWeek(dow: DayOfWeek): LocalDate { | |
val minus = (this.dayOfWeek.value + 7 - dow.value) % 7 | |
return this.minusDays(minus.toLong()) | |
} | |
fun LocalDate.firstDayOfWeek(dow: DayOfWeek): LocalDate { | |
val plus = (dow.value + 7 - this.dayOfWeek.value) % 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class AccessRequirement<R> { | |
fun isSatisfiedByRoles(callerRoles: Set<R>): Boolean { | |
return when (this) { | |
is AlwaysAllow -> true | |
is NeverAllow -> false | |
is RequireRole -> callerRoles.contains(role) | |
is AnyOfRoles -> (callerRoles intersect anyOfRoles).isNotEmpty() | |
is AllOfRoles -> callerRoles.containsAll(allOfRoles) | |
is AnyOfAccessRequirements -> anyOf.any { it.isSatisfiedByRoles(callerRoles) } | |
is AllOfAccessRequirements -> allOf.all { it.isSatisfiedByRoles(callerRoles) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package testing | |
import com.fasterxml.jackson.databind.ObjectMapper | |
import org.junit.jupiter.api.Assertions.assertEquals | |
import org.junit.jupiter.api.Test | |
import java.util.* | |
class TestJacksonWithOptional { | |
val defaultObjectMapper = ObjectMapper().apply { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun inputStreamToTrimmedString(inputStream: InputStream): String { | |
val baos = ByteArrayOutputStream() | |
val buffer = ByteArray(128) | |
inputStream.bufferedSequence(buffer) { bytesRead -> baos.write(buffer, 0, bytesRead) } | |
return baos.toString("UTF-8").trim() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adapted from https://stackoverflow.com/a/51419993/516910 | |
package to.pubsub.util | |
import com.fasterxml.jackson.databind.PropertyNamingStrategy | |
import com.fasterxml.jackson.databind.cfg.MapperConfig | |
import com.fasterxml.jackson.databind.introspect.AnnotatedField | |
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod | |
class BooleanNamingStrategy : PropertyNamingStrategy() { |
NewerOlder