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 / replace_characters.py
Created December 20, 2017 10:23
Replace the characters in the string
#Characters to replace
escape_table = {
"&" : " ",
"#" : "1"
}
#Initial string
text = "asd&#"
#Final string
new = "".join(escape_table.get(c,c) for c in text)
@dragneelfps
dragneelfps / GraphViews.java
Created January 19, 2018 18:13
Top, Bottom, Left and Right Views for a Graph
package graphs;
import java.util.*;
class Graph{
Node root = null;
Graph(){
}
static class Node{
int data;
Node left, right;
@dragneelfps
dragneelfps / .gitignore
Created January 22, 2019 18:10
Git Ignore for Android Projects [https://stackoverflow.com/a/17803964]
#built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@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(
@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 / 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 / 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 / commands.md
Created July 19, 2020 11:34
unix = powershell

unix = powershell

which = Get-Command or gcm

@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 / 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()