Skip to content

Instantly share code, notes, and snippets.

#run the code
./gradlew run
# output:
dotdotRange: a,b,c,d
untilRange: a,b,c
untilRange new 1.7.20: a,b,c
rangeTo: a,b,c,d
downTo: d,c,b,a
val A_UNTIL_D = ('a' until 'd')
// a,b,c
@OptIn(ExperimentalStdlibApi::class)
val A_NEW_UNTIL_D = ('a' ..< 'd')
// a,b,c
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions { languageVersion = "1.8" }
}
// please see also the accompanying blog post
// https://www.lotharschulz.info/2021/10/14/how-to-create-a-react-frontend-to-debounce-text-input-persistence-in-firebase-firestore/
function Elements() {
const defaultDelayInMillis = 5000; // default delay 5 seconds
const [dbValue, setDBValue] = useState("");
const [delayFieldDisabled, setdelayFieldDisabled] = useState(true)
const [debounceDelay, setDebounceDelay] = useState(defaultDelayInMillis)
const collectionLabel = "data";
// please see also the accompanying blog post
// https://www.lotharschulz.info/2021/10/14/how-to-create-a-react-frontend-to-debounce-text-input-persistence-in-firebase-firestore/
const saveFieldValueDebounced = AwesomeDebouncePromise(
saveFieldValue,
debounceDelay,
{ key: fieldId => fieldId },
);
const saveFieldValue = (fieldId: number, fieldValue: string) => saveToDB(fieldValue);
#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
###################################
# BREW uninstall script for osx_bootstrap.sh script
###################################
SUDO_USER=$(whoami)
#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
# inspired by
# https://gist.github.com/codeinthehole/26b37efa67041e1307db
# https://github.com/why-jay/osx-init/blob/master/install.sh
# https://github.com/timsutton/osx-vm-templates/blob/master/scripts/xcode-cli-tools.sh

Change default Java version on macOS 11 BigSur

javahome() {
  unset JAVA_HOME 
  export JAVA_HOME=$(/usr/libexec/java_home -v "$1");
  java -version
}

alias j1.8='javahome 1.8'