Skip to content

Instantly share code, notes, and snippets.

View bijay-shrestha's full-sized avatar
👨‍🎓
MSCS Compro

Bijay Shrestha bijay-shrestha

👨‍🎓
MSCS Compro
View GitHub Profile
@bijay-shrestha
bijay-shrestha / MicroservicesConfigurations.md
Last active August 24, 2022 12:39
Microservices Setup

Eureka Server

YAML

server:
  port: 9091

eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
@bijay-shrestha
bijay-shrestha / application.yml
Last active August 16, 2022 19:18
H2 Database
spring:
datasource:
url: jdbc:h2:mem:testdb
h2:
console:
enabled: true
@bijay-shrestha
bijay-shrestha / DailyMealUtils.java
Created July 8, 2022 20:33
Native Query Parse Example
package edu.miu.annapurnabe;
import edu.miu.annapurnabe.dto.response.MealResponseDetailDTO;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
/**
* * An array is defined to be odd-heavy if it contains at least one odd element and every odd
* * element is greater than every even element. So {11, 4, 9, 2, 8} is odd-heavy because the two odd elements (11 and 9)
* * are greater than all the even elements.
* *
* * And {11, 4, 9, 2, 3, 10} is not odd-heavy because the even element
* * 10 is greater than the odd element 9. Write a function called isOddHeavy that accepts an integer array and
* * returns 1 if the array is odd-heavy; otherwise it returns 0.
* *
* * Some other examples: {1} is odd-heavy, {2} is not
/**
*
* Print numbered Flag
* 1
* 2 3
* 4 5 6
* 7 8 9 10
* 11 12 13 14 15
*
*/
/**
* * Print a numbered flag
* * 1
* * 12
* * 123
* * 1234
* * 12345
*/
package com.basic.practice;
/**
* * Write a function sumIsPower with signature boolean sumIsPower(int[] arr)
* * which outputs true if the sum of the elements in the input array arr is a power of 2, false otherwise.
* *
* * Recall that the powers of 2 are 1, 2, 4, 8, 16, and so on.
* * In general a number is a power of 2 if and only if it is of the form 2^n for some non-negative integer n.
* *
* * You may assume (without verifying in your code) that all elements in the array
* * are positive integers.
* *
/**
*
* Print Nepal Flag in your console.
*/
package com.basic.practice;
public class NepalFlag {
public static void main(String[] args) {
printFlag();
/**
* * Write a function named countDigit that returns the number of times that a given digit appears in a
* * positive number.
* *
* * For example countDigit(32121, 1) would return 2 because there are two 1s in 32121.Other examples:
* * countDigit(33331, 3) returns 4
* * countDigit(33331, 6) returns 0
* * countDigit(3, 3) returns 1
* *
* * The function should return -1 if either argument is negative, so
/**
* * Write a function named minDistance that returns the smallest distance between two factors of a number.
* *
* * For example, consider 13013 = 1*7*11*13. Its factors are 1, 7, 11, 13 and 13013.
* * minDistance(13013) would return 2 because the smallest distance between any two factors is 2 (13 - 11 = 2).
* *
* * As another example, minDistance (8) would return 1 because the factors of 8 are 1, 2, 4, 8
* * and the smallest distance between any two factors is 1 (2 – 1 = 1).
* *
* * The function signature is