Skip to content

Instantly share code, notes, and snippets.


Björn Kahlert bkahlert

View GitHub Profile
bkahlert /
Last active Aug 24, 2021
POSIX script to access EXT4 partitions in img files
# Abort script at first error, when a command exits with non-zero status
# (except in until or while loops, if-tests, list constructs)
set -e
# Attempt to use undefined variable outputs error message, and forces an exit
set -u
# Similar to verbose mode (-v), but expands commands
#set -x
dotCipher /
Created Jul 26, 2018
Intellij idea launcher script, that can handle multiple inputs
# Determine where intellij is installed
DEFAULT_IDEA_TOOLBOX_LOCATION=$(ls -1d ~/Library/Application\ Support/JetBrains/Toolbox/apps/*/*/*/IntelliJ\ 2>&1 | tail -n1)
DEFAULT_IDEA_LOCATION=$(ls -1d /Applications/IntelliJ\ 2>&1 | tail -n1)
if [[ $DEFAULT_IDEA_TOOLBOX_LOCATION = *"No such file or directory"* ]]; then
elif [[ $DEFAULT_IDEA_LOCAITON = *"No such file or directory"* ]]; then
Takhion / MultiReceiver.kt
Created Jul 8, 2018
Multiple receivers in Kotlin
View MultiReceiver.kt
val sample: (X, Y, Z) -> Int = multiReceiver { { { x + y + z } } }
fun <A, B, C, R> multiReceiver(f: A.() -> B.() -> C.() -> R) = { a: A, b: B, c: C -> f(a)(b)(c) }
class X(val x: Int)
class Y(val y: Int)
class Z(val z: Int)