Skip to content

Instantly share code, notes, and snippets.

@bastman
bastman / Jackson.kt
Last active April 23, 2019 06:45
kotlin jackson patchable deserializer
package com.example.config
import com.example.Patchable
import com.example.PatchableDeserializer
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.springframework.context.annotation.Bean
@bastman
bastman / azcopy_osx_install.sh
Created March 27, 2019 11:15
azcopy_osx_install.sh : download azure azcopy
#!/usr/bin/env bash
cd /tmp
wget -O azcopyv10.tar https://aka.ms/downloadazcopy-v10-mac
tar -xf azcopyv10.tar
cd azcopy_darwin_amd64_10.0.8
cp azcopy /usr/local/bin/
cd -
azcopy --help
@bastman
bastman / ExampleTest.kt
Last active June 4, 2023 21:25
junit5: Testfactory DSL (kotlin) - dynamic, nested tests ...
package com.example
import com.example.testutils.junit5.testFactory
import com.example.testutils.springTest.BootWebMockMvcTest
import mu.KLogging
import org.amshove.kluent.shouldEqual
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestFactory
import org.springframework.beans.factory.annotation.Autowired
import java.math.BigDecimal
@bastman
bastman / exposed-tricks.kt
Last active June 26, 2023 12:32
exposed tricks
# =========
# demo: https://github.com/JetBrains/Exposed/tree/master/src/test/kotlin/demo
# dml tests: https://github.com/JetBrains/Exposed/blob/master/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/DMLTests.kt
# ===== GIS
https://github.com/JetBrains/Exposed/issues/459
# === native
@bastman
bastman / html-dom-selectors-xpath.txt
Last active February 27, 2019 15:37
e2e-html-dom-selectors-xpath
document.querySelector('#region > div > div:nth-child(1) > span')
in chrome dev tools you can execute:
$x('//*[@id="region"]/div/div[1]/span')
which should be similar to ...
function getElementByXpath(path) {
@bastman
bastman / sql-Query-order-of-execution.sql
Last active February 19, 2019 06:12
sql - Query order of execution
see: https://sqlbolt.com/lesson/select_queries_order_of_execution
1. FROM and JOINs
2. WHERE
3. GROUP BY
4. HAVING
5. SELECT
6. DISTINCT
7. ORDER BY
8. LIMIT / OFFSET
@bastman
bastman / postgres_copy_column.sql
Last active February 19, 2019 12:18
postgres: add column to table - as copy of other colum
scenario
======================
given:
table wf_test
- wf_id (PK NOT NULL)
should become:
@bastman
bastman / public-apis.txt
Created February 16, 2019 07:05
public (free) apis
https://github.com/toddmotto/public-apis
@bastman
bastman / OptionalToNullable.kt
Created February 14, 2019 08:45
Kotlin: fun Optional<T>.toNullable():T?
import java.util.*
fun <T : Any> Optional<T>.toNullable(): T? = when (isPresent) {
true -> get()
false -> null
}
fun foo(x:Optional<Int>):Int? = x.toNullable()
@bastman
bastman / testcafe.sh
Last active November 25, 2019 17:55
testcafe docker example
# clone the testcafe example repo
$ git clone git@github.com:DevExpress/testcafe.git
$ cd testcafe
# run docker headless
$ docker run --rm -it -v ${PWD}:/tests tomdesinto/testcafe:latest testcafe 'chromium:headless --no-sandbox' '/tests/examples/basic/test.js'
# run docker chrome
$ docker run --rm -it -v ${PWD}:/tests tomdesinto/testcafe:latest testcafe 'chromium --no-sandbox' '/tests/examples/basic/test.js'