This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EnvironmentConfig(BaseModel): | |
environment: str = "development" | |
@classmethod | |
def from_env(cls, explicit_env: Optional[str] = None): | |
""" | |
Create an instance of the config, prioritizing explicitly provided environment | |
over environment variable, with a default fallback. | |
""" | |
# Check for explicitly provided environment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
NewerOlder