Skip to content

Instantly share code, notes, and snippets.

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

Sourabh dragneelfps

💻
Developer @ Expedia
View GitHub Profile
@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) {
@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 / fun.kt
Created April 3, 2021 11:51
rounding doubles in kotlin
fun Double.round(places: Int) = BigDecimal(this).setScale(places, RoundingMode.HALF_EVEN).toDouble()
@dragneelfps
dragneelfps / README.md
Created November 19, 2020 06:53
Git signing
  • gpg --gen-key
  • git config --global user.signingkey 0A46826A
  • git config --global commit.gpgsign true (Optional, enable sign always)
  • git commit -S -m "foobar (Optional, for manual sign commit)
  • Copy output of git --armor --export 0A46826A to github/gitlab settings etc
  • Have fun
@dragneelfps
dragneelfps / commands.md
Created July 19, 2020 11:34
unix = powershell

unix = powershell

which = Get-Command or gcm

@dragneelfps
dragneelfps / publishing.kt
Created March 29, 2020 08:01
Helper for publishing artifact to maven
fun Project.configurePublishing(artifactId: String, android: Boolean = false) {
var publishingExtension: PublishingExtension? = null
apply<MavenPublishPlugin>()
apply<SigningPlugin>()
configure<PublishingExtension> {
publishingExtension = this
publications {
create<MavenPublication>("mavenRelease") {
this.artifactId = artifactId
if (android) {
@dragneelfps
dragneelfps / log_ex.kt
Last active February 21, 2020 09:16
New kind of logging and exception mapping. WIP
package com.expedia.ord.recon
import java.util.*
fun main(args: Array<String>) {
val helloApp = HelloApp()
helloApp.work()
helloApp.funstuff("skiing")
try {
val asd = helloApp.otherstuff(10)
@dragneelfps
dragneelfps / fancy_fab.dart
Created May 19, 2019 04:15
Toggle-able fab with multiple options
import 'package:flutter/material.dart';
typedef void OnPressed(String id);
class FancyFab extends StatefulWidget {
final OnPressed onPressed;
FancyFab({@required this.onPressed});
@override
@dragneelfps
dragneelfps / nested_menu.dart
Last active May 19, 2019 03:20
Show nested menu for PopupMenuButon
Future<T> showNestedMenu<T>(
{@required BuildContext context,
@required GlobalKey<State> popupButtonKey,
@required List<PopupMenuEntry<T>> items}) async {
final RenderBox popupButtonObject =
popupButtonKey.currentContext.findRenderObject();
final RenderBox overlay = Overlay.of(context).context.findRenderObject();
final position = RelativeRect.fromRect(
Rect.fromPoints(