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
| import boto3 | |
| from botocore.exceptions import ClientError | |
| import os | |
| def upload_file_to_s3(file_path, bucket_name): | |
| s3_client = boto3.client('s3') | |
| object_name = os.path.basename(file_path) | |
| try: | |
| # Upload the file |
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
| import java.io.IOException; | |
| import java.util.UUID; | |
| import jakarta.servlet.FilterChain; | |
| import jakarta.servlet.ServletException; | |
| import jakarta.servlet.http.HttpServletRequest; | |
| import jakarta.servlet.http.HttpServletResponse; | |
| import lombok.NonNull; | |
| import lombok.extern.slf4j.Slf4j; | |
| import org.slf4j.MDC; |
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 org.geeks; | |
| public class StockSpan { | |
| public static void main(String[] args) { | |
| int[] arr = {10, 4, 5, 90, 120, 80}; | |
| int[] span = new int[arr.length]; | |
| for (int i = 0; i < arr.length; i++) { | |
| int count = 0; | |
| for (int j = i; j >= 0; j--) { |
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 org.geeks; | |
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| import java.util.LinkedHashMap; | |
| /* | |
| For detailed elaboration of the problem with examples refer below link | |
| https://www.geeksforgeeks.org/problems/print-anagrams-together/1 | |
| */ | |
| public class Anagrams { |
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 org.geeks; | |
| import java.util.HashMap; | |
| /* | |
| Problem statement with Sample examples can be referred from | |
| https://www.geeksforgeeks.org/problems/majority-element-1587115620/1?page=1&company=Atlassian&sortBy=submissions | |
| */ |
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 org.RateLimiter; | |
| import java.util.ArrayDeque; | |
| import java.util.Deque; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| public class RateLimit { | |
| Map<String, Deque> userRequestMap = new HashMap<>(); |
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
| import requests | |
| import os | |
| def fetchExchangeRate(currencyDate, baseCurrency, currencySymbol): | |
| """ | |
| Method to fetch open Currency exchange rate of base currency (1 Unit) to a currencySymbol | |
| Reference : https://docs.openexchangerates.org/reference/api-introduction | |
| Args: | |
| currencyDate: Date for which you need open exchange rate. | |
| baseCurrency: ISO currency code |
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
| from openai import OpenAI | |
| # Read OpenAI API Key from environment variable | |
| api_key = os.environ.get("OPENAI_API_KEY") | |
| client = OpenAI(api_key=api_key) | |
| def translate_text(text): | |
| model = "gpt-4-turbo-preview", | |
| response = client.chat.completions.create( | |
| model="gpt-3.5-turbo-0125", |
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
| # File showing usage of openaiUtil.py | |
| import openaiUtil | |
| # Press the green button in the gutter to run the script. | |
| if __name__ == '__main__': | |
| print(" Welcome") | |
| print(openaiUtil.question_image(openaiUtil.generate_payload("image_folder_path"))) |
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
| import java.util.LinkedHashMap; | |
| import java.util.Map; | |
| public class LRUCache { | |
| int capacity; | |
| LinkedHashMap<String,String> cache; | |
| public LRUCache(int capacity) { |
NewerOlder