This file contains 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 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 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 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) { |
This file contains 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
const redisParameterGroup = new elasticache.CfnParameterGroup(this, 'redisParameterGroup', { | |
cacheParameterGroupFamily: 'redis7', | |
description: 'Redis Cluster Parameter Overrides', | |
properties: { | |
timeout: '120', // Close connection if client is idle for a given number of seconds | |
}, | |
}); | |
const redisPrimaryReplicationGroup = new elasticache.CfnReplicationGroup(this, 'redisPrimaryReplicationGroup', { | |
replicationGroupDescription: '{CLUSTER_DESCRIPTION}', |
This file contains 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.elasticache; | |
import lombok.extern.log4j.Log4j2; | |
import redis.clients.jedis.Jedis; | |
import javax.net.ssl.SSLParameters; | |
import javax.net.ssl.SSLSocketFactory; | |
import java.net.URI; | |
/** |
This file contains 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 pathlib import Path | |
from urllib.request import Request, urlopen | |
class Crawl: | |
# Download the HTML Content of the URL and return absolute path of the HTML file | |
@staticmethod | |
def fetch(outputDirectory,url): | |
try: | |
# Create the output directory if not exists |
This file contains 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 os | |
from google.cloud import pubsub | |
from concurrent.futures import TimeoutError | |
project_id = "your-project-id" | |
topic_id = "topic-id-from-gcp-console" | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "path-to-your-credential-json-file" | |
publisher = pubsub.PublisherClient() |
This file contains 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.ArrayList; | |
import java.util.Collections; | |
import java.util.Scanner; | |
public class MergeTwoSortedArray { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
Scanner userInput = new Scanner(System.in); | |
This file contains 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.Scanner; | |
public class MissingNumber { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
Scanner input = new Scanner(System.in); | |
System.out.println("Please enter the value of N"); | |
int N = Integer.parseInt(input.nextLine()); | |
int expectedSum = (N * (N+1))/2; |
NewerOlder