Skip to content

Instantly share code, notes, and snippets.

View corneil's full-sized avatar

Corneil du Plessis corneil

View GitHub Profile
@corneil
corneil / SpelTests.kt
Created August 12, 2019 14:18
Spring Spel fails
import org.junit.Assert.assertEquals
import org.junit.Test
import org.springframework.core.convert.TypeDescriptor
import org.springframework.expression.spel.SpelParserConfiguration
import org.springframework.expression.spel.standard.SpelExpressionParser
import org.springframework.expression.spel.support.SimpleEvaluationContext
class PropertyHolder(val properties: Map<String, Any>)
class SpelTests {
@corneil
corneil / preconditions.kt
Created August 28, 2019 20:49
precondition extension functions with @ResponseStatus on Exception for Spring MVC.
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.ResponseStatus
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
@ResponseStatus(HttpStatus.PRECONDITION_FAILED)
class PreconditionException(message: String) : Exception(message)
@ExperimentalContracts
@Throws(EntityNotFoundException::class)
@corneil
corneil / angular-enter-key-submit.md
Created September 22, 2019 18:49
Angular form submission on enter key.

While playing with Ionic I came across an error when pressing enter in a form.

onloadwff.js:71 Uncaught TypeError: Cannot read property 'type' of undefined
    at setFieldValue (onloadwff.js:71)
    at HTMLFormElement.formKeydownListener (onloadwff.js:71)

You would expect the form to submit if one of the buttons is a submit button.

I tried by adding (keydown.enter)="submitForm()" (ngSubmit)="submitForm()" to the form element. But now enter causes the submitForm to be called twice.

@corneil
corneil / find_table_col.sql
Created September 3, 2021 05:53
Find a DB2 table name and column from SQLCODE=-407, SQLSTATE=23502
SELECT C.TABSCHEMA, C.TABNAME, C.COLNAME
FROM SYSCAT.TABLES AS T, SYSCAT.COLUMNS AS C
WHERE T.TBSPACEID = -- TBSPACEID
AND T.TABLEID = -- TABLEID
AND C.COLNO = -- COLNO
AND C.TABSCHEMA = T.TABSCHEMA
AND C.TABNAME = T.TABNAME
@corneil
corneil / mvn-get-version.sh
Last active October 26, 2022 11:38
Shell script to extract Maven project version for use in CI tools.
#!/usr/bin/env bash
VERSIONS=$($SCDIR/mvnw exec:exec -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive -q | sed 's/\"//g' | sed 's/version=//g')
for v in $VERSIONS; do
VERSION=$v
done
echo "$VERSION"
@corneil
corneil / simple-json.sh
Created October 26, 2022 11:37
Prepare JSON for saving in ENV.
jq -c . $1

Keybase proof

I hereby claim:

  • I am corneil on github.
  • I am corneil (https://keybase.io/corneil) on keybase.
  • I have a public key ASCoDAx2zqO9T5p7T7GGgSjEh3jFmUzdzUomM-tVbgeg_Qo

To claim this, I am signing this object:

@corneil
corneil / build-modified-modules.sh
Last active January 19, 2023 11:10
Determine changed modules in multi-module Maven Project in GitHub Actions
#!/bin/bash
function itemInModules() {
local e
for e in ${MODULES}; do
if [[ "$e" == "$ITEM" ]]; then
echo "1"
return 0
fi
done
echo "0"
@corneil
corneil / README.md
Last active March 24, 2023 11:54
Importing one git project into another.

If you want to import one project into another and the resulting project will be a subfolder into the parent the following steps will allow you preserve history and tags.

The tags from sub-project are prefixed as part of the process.

The scripts assume the 2 projects are on disk with the same parent folder.

Be careful on the merged project because some of the historical commits only reference the sub project and branching from the wrong sha can cause confusion.

@corneil
corneil / sdk-java.sh
Last active January 31, 2024 18:40
Easily select java version and distribution with sdkman
#!/bin/bash
function sdkj() {
if [ "$1" == "" ]; then
echo "Expected Version prefix"
exit 1
fi
PREFIX=$1
CONTAINS=$2
# list candidates in the order they were installed. Last matching installed will be selected.
CANDIDATES=$(ls -tr ~/.sdkman/candidates/java/)