https://blog.timescale.com/tutorials/how-to-install-psql-on-mac-ubuntu-debian-windows/
View railway.kt
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 com.example.demo | |
// based on ... | |
// https://www.reddit.com/r/Kotlin/comments/15b16px/little_example_of_railway_oriented_programming_in/ | |
// https://github.com/GabrielLasso/Kotlin-railway-example | |
fun main() { | |
val pipeline: (data: Either<Throwable, Person>) -> Either<Throwable, Response> = | |
(::validate `→` ::save `→` ::notify `→` ::buildResponse) |
View InstantRangeDeserializer.kt
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
/* | |
InstantRangeDeserializer.kt | |
jackson-module-kotlin: InstantRangeDeserializer - How to deserialize ClosedRange<Instant> | |
Type definition error: [simple type, class kotlin.ranges.ClosedRange]; | |
nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: | |
Cannot construct instance of `kotlin.ranges.ClosedRange` (no Creators, like default constructor, exist): |
View SlidingWindowExamples.kt
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
// see: https://itnext.io/sliding-window-algorithm-technique-6001d5fbe8b3 | |
fun main() { | |
intro() | |
`Maximum sum subarray of Size k`() | |
//`Count Occurrences of Anagram`() | |
} | |
fun intro() { |
View JacksonJmesPathExt.kt
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 ObjectMapper.convertValueAsJsonNode(value:Any?):JsonNode = convertValue(value, JsonNode::class.java) | |
inline fun <reified T> JsonNode.jq( | |
query: String, | |
noinline convert: (Any) -> T | |
): T { | |
val isNullable: Boolean = null is T | |
try { | |
val expression: Expression<JsonNode> = JmesPathJackson.compile(query) |
View DoubleExt.kt
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
// see discussion on alternatives here: https://discuss.kotlinlang.org/t/how-do-you-round-a-number-to-n-decimal-places/8843/15 | |
fun Double.round(decimals:Int, roundingMode:RoundingMode=RoundingMode.HALF_EVEN):Double = | |
toBigDecimal().setScale(decimals, roundingMode).toDouble() | |
# ??? | |
fun Double.round2(decimals: Int): Double { | |
val locale:Locale = Locale.US | |
val aTxt:String = String.format(locale, "%.${decimals+1}f", this) | |
val aDouble:Double = aTxt.toDouble() |
View jmespath-groupBy.kt
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 com.fasterxml.jackson.databind.JsonNode | |
import com.fasterxml.jackson.databind.node.ArrayNode | |
import com.fasterxml.jackson.databind.node.JsonNodeFactory | |
import com.fasterxml.jackson.databind.node.ObjectNode | |
import io.burt.jmespath.Adapter | |
import io.burt.jmespath.JmesPath | |
import io.burt.jmespath.JmesPathType | |
import io.burt.jmespath.RuntimeConfiguration | |
import io.burt.jmespath.function.ArgumentConstraints | |
import io.burt.jmespath.function.BaseFunction |
View find_duplicate_row_ids.sql
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
SELECT my_id, COUNT(my_id) | |
FROM my_table | |
GROUP BY my_id | |
HAVING COUNT(my_id) > 1; |
View k8s-create-job-from-cronjob.sh
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
$ kubectl create job --from=cronjob/<CRONJOB-NAME> <NEW-JOB-NAME> | |
e.g.: | |
$ kubectl create job --from=cronjob/my-cron my-cron-manual-001 | |
function k8s-cronjob-run() { | |
source_cronjob_name=$1 | |
[ -z "$source_cronjob_name" ] && echo "Please provide source-cronjob-name !" && return | |
sink_run_id=$(date -u +"%Y-%m-%dt%H.%M.%Sz") |
NewerOlder