Skip to content

Instantly share code, notes, and snippets.

View ramannanda9's full-sized avatar

Ramandeep Singh ramannanda9

View GitHub Profile
class MetricsProvider(abc.ABC):
@abc.abstractmethod
def name():
pass
@abc.abstractmethod
def fetch_metrics(tags:Dict[str,str], strategy: Strategy)->Dict[str, Metric]:
#should fetch metrics, combination happens on server side as per strategy i.e. rolling average to reduce load in data transfer
pass
@abc.abstractmethod
def append_metrics(tags: Dict[str, str], values: Union[Any, pd.Series]) -> None:
@ramannanda9
ramannanda9 / menu.py
Created October 24, 2021 21:18
Menu.py
import atexit
import copy
import dataclasses
import logging
import os
from main import User, UserManager
logging.basicConfig(level=logging.INFO)
# use the below logger
@ramannanda9
ramannanda9 / user.py
Last active October 24, 2021 21:19
Example User API
# This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
import dataclasses
import json
import logging
from json import JSONEncoder
from typing import Dict, List
@ramannanda9
ramannanda9 / FunctionalTP.java
Created March 28, 2020 05:26
FunctionTP - to test basics
package com.orastack;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ramannanda9
ramannanda9 / StonesProblem.java
Created February 9, 2019 23:51
Stones Problem
class StonesProblem {
int[][] stageScore=null;
public boolean stoneGame(int[] piles) {
stageScore= new int[piles.length+2][piles.length+2];
// stoneGameRec(0, piles, true,0,piles.length-1)>0
return stoneGameBottomUp(piles)>0;
}
public int stoneGameRec(int sumSoFar, int [] piles, boolean positive, int begin, int end){
if(stageScore[begin][end]!=0){
/*package whatever //do not write package name here */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
class GFG {
public int getMinDistance(String[] words,String word1,String word2){
val conf = new NeuralNetConfiguration.Builder().regularization(true).l2(0.001).weightInit(WeightInit.RELU)
.updater(new Adam(0.01, 0.9, .98, 1e-8)).
optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).
convolutionMode(ConvolutionMode.Strict).list().
layer(0, new ConvolutionLayer.Builder(7, 7).nIn(1).stride(1, 1)
.nOut(25).activation(Activation.IDENTITY).build())
.layer(1, new SubsamplingLayer.Builder(PoolingType.MAX).
kernelSize(2, 2).stride(2, 2).build()).
layer(2, new ConvolutionLayer.Builder(6, 6).stride(1, 1).nOut(64).
activation(Activation.IDENTITY).build()).
@ramannanda9
ramannanda9 / TailRecursionFilter.scala
Created July 31, 2017 20:09
Filter with Tail Recursion
def filter[K](list: List[K], f: K => Boolean): List[K] = {
@tailrec
def filterRec(list: List[K], f: K => Boolean): List[K] = list match {
case Nil => list
case list: List[K] => if (f(list.head)) filterRec(list.head :: list.tail, f) else filterRec(list.tail, f)
}
filterRec(list, f)
}
val listToFilter = 2 :: 5 :: Nil
@ramannanda9
ramannanda9 / MaxSumInTree.java
Created July 31, 2017 19:58
Get maximum independent branch sum
public class MaxSumInTree{
int left(int i) {
return (2 * i + 1);
}
int right(int i) {
return (2 * i + 2);
}
long findMax(int n, String tree) {
@ramannanda9
ramannanda9 / filter.scala
Last active July 31, 2017 19:51
filter in scala
def filter[K](arr: List[K], f: K => Boolean): List[K] = arr match {
case Nil => arr
case list: List[K] => if (f(list.head)) list.head :: filter(list.tail, f) else filter(list.tail, f)
}
val listToFilter = 2 :: 5 :: Nil
listToFilter.filter(_ > 2)