Skip to content

Instantly share code, notes, and snippets.

View dragneelfps's full-sized avatar
💻
Developer @ Uber

Sourabh dragneelfps

💻
Developer @ Uber
View GitHub Profile
@dragneelfps
dragneelfps / trie.kt
Created May 6, 2021 04:40
TRIE data structure in Kotlin
class Trie() {
private data class Node(val children: MutableList<Node?> = MutableList(26) { null }, var leaf: Boolean = false)
private val root = Node()
/** Inserts a word into the trie. */
fun insert(word: String) {
var curr = root
for(ch in word) {
@dragneelfps
dragneelfps / SpringLikeHoconProfile.kt
Last active January 23, 2022 13:28
Replicating `spring.active.profiles`
fun profileAwareConfig(): Config {
val logger = LoggerFactory.getLogger("ProfileAwareConfig")
val profiles = (System.getProperty("ktor.active.profiles") ?: "").split(",")
val combinedConfig = profiles.fold(ConfigFactory.defaultApplication()) { config, profile ->
val profileConfig = ConfigFactory.parseResourcesAnySyntax("application-$profile")
profileConfig.withFallback(config)
}
if (logger.isDebugEnabled) {