Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/docker-build-and-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Docker Build and Deploy

on:
push:
branches:
- main # Trigger on pushes to the main branch

jobs:
build-and-run:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Docker
uses: docker/setup-buildx-action@v3

- name: Build Docker Image
run: docker build -t custom-sql-server -f docker/mssql.Dockerfile .

- name: Push Docker Image (Optional)
env:
DOCKER_USER: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASS: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
docker tag custom-sql-server username/custom-sql-server:latest
docker push username/custom-sql-server:latest

- name: Run Docker Container
run: |
docker stop my-custom-sql-server || true
docker rm my-custom-sql-server || true
docker run -d --name my-custom-sql-server -p 1433:1433 custom-sql-server
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
venv_kri/
.venv_kri/
.venv_test/
venv_kri_vscode/
tests/
.env
Expand All @@ -9,3 +10,4 @@ __pycache__/
.mypy_cache/
.pytest_cache/
.vscode/
.venv_jupyter
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: detect-secrets
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Use the official Microsoft SQL Server image from the Docker Hub
FROM mcr.microsoft.com/mssql/server:2022-latest

# Set environment variables
ENV ACCEPT_EULA=Y
ENV SA_PASSWORD=YourStrong!Passw0rd
ENV MSSQL_PID=Express

# Expose the SQL Server port
EXPOSE 1433

# Run SQL Server process
CMD /opt/mssql/bin/sqlservr
57 changes: 29 additions & 28 deletions NumpyProject/image_manipulation.ipynb

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions cmds
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# capture all library in requirement txt file
pipdeptree --freeze --warn silence | grep -E '^[a-zA-Z0-9\-_]+' > requirements.txt
pipdeptree --freeze --warn silence | grep -E '^[a-zA-Z0-9\-_]+' | cut -d'=' -f1 > requirements.txt

# for windows
pipdeptree --freeze --warn silence | findstr /R "^[a-zA-Z0-9\-_]" > requirements.txt

#execute docker mongodb in container
docker run -d --name mongodb-container -p 27017:27017 mongo

#execute docker mongodb in container with volume
docker compose down && docker compose -f docker-compose.yml up -d --build

#docker compose cmd
docker compose -f docker-compose.yml up -d --build

#execute FastAPI server
uvicorn app.main:app --reload

#Kill port in linux if occupied by VSCode
sudo lsof -i :8000
kill -9 <PID>

# to stop mongodb
net stop MongoDB

#docker compose validation
docker-compose config

#If the output doesn't show any errors, your file is valid. Then you can start the services:
docker-compose up --build

#If you want to run the services in the background, you can use the -d flag:
docker compose up -d --build

# -f is used for custom filename for docker compose
docker compose -f docker-compose.yml up -d --build

docker run -it chatbot_backend-fastapi_application /bin/bash

# This is test

# Run the command to fetch the latest references from GitHub
git fetch --prune

# Identify local branches not tracked on GitHub
git branch -vv | grep ': gone' | awk '{print $1}'

# Run the following command to delete all untracked local branches
git branch -vv | grep ': gone' | awk '{print $1}' | xargs -r git branch -d

# Upgrade pip cmd
python.exe -m pip install --upgrade pip
28 changes: 15 additions & 13 deletions code/python_files/json_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,21 @@
]
}

# Extracting maximum claim amount for each patient
max_claims = {}
for patient in raw_data['patients']:
patient_id = patient['patient_id']
max_claim = max(claim['claim_amount'] for claim in patient['claims'])
max_claims[patient_id] = max_claim

def search_json(data, key):
for i in data:
print(type(i), i)
print(type(data[i]), data[i])
if data[i] is list:
for j in data[i]:
print(type(j), j)
print(type(j[i]), j[i])
if j[i] == key:
return j
else:
return search_json(j, key)
print(max_claims)


print(search_json(raw_data, 'P001'))
patient_input = 'P002'
max_claim = None
for patient in raw_data['patients']:
if patient['patient_id'] == patient_input:
max_claim = max(claim['claim_amount'] for claim in patient['claims'])
break

print(f"Maximum claim amount for patient {patient_input}: {max_claim}")
14 changes: 14 additions & 0 deletions docker/mssql.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use the official SQL Server 2022 image as the base image
FROM mcr.microsoft.com/mssql/server:2022-latest

# Set environment variables
ENV ACCEPT_EULA=Y
ENV MSSQL_SA_PASSWORD=YourStrong@Passw0rd
# Change to Developer/Standard/Enterprise if needed
ENV MSSQL_PID=Developer

# Expose the SQL Server port
EXPOSE 1433

# Start SQL Server when the container starts
CMD ["/opt/mssql/bin/sqlservr"]
23 changes: 23 additions & 0 deletions extraction/fb1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import requests
from bs4 import BeautifulSoup

# URL of the Facebook friends page
url = input("Enter Facebook URL about friends \
list https://www.facebook.com/[friends_name]/friends")

# Headers (replace cookies with authenticated session cookies)
headers = {
"User-Agent": "Your User-Agent",
"Cookie": "Your-Cookie"
}

# Fetch the page
response = requests.get(url, headers=headers)

# Parse with BeautifulSoup
soup = BeautifulSoup(response.text, "html.parser")

# Extract friend names
names = [tag.text for tag in soup.find_all("a", class_="friend-class-name")]
# Replace 'friend-class-name' with the actual class name.
print(names)
25 changes: 25 additions & 0 deletions extraction/fb2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import requests
import os
from dotenv import load_dotenv

load_dotenv()

ACCESS_TOKEN = os.getenv("FB_ACCESS_TOKEN")

if not ACCESS_TOKEN:
raise ValueError("Access token not found in environment variables.")

URL = "https://graph.facebook.com/v12.0/me/friends"

params = {
"access_token": ACCESS_TOKEN
}

response = requests.get(URL, params=params)

if response.status_code == 200:
data = response.json()
friends = [friend["name"] for friend in data.get("data", [])]
print(friends)
else:
print(f"Error: {response.status_code}, {response.text}")
50 changes: 50 additions & 0 deletions extraction/fb3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
import os
from dotenv import load_dotenv

load_dotenv()
# Replace with your Facebook credentials
FB_EMAIL = os.getenv("FB_USERNAME")
FB_PASSWORD = os.getenv("FB_PASSCODE")

# Path to ChromeDriver
CHROMEDRIVER_PATH = "C:\Program Files\Google\Chrome\Application"

# Initialize WebDriver
driver = webdriver.Chrome(CHROMEDRIVER_PATH)

try:
# Navigate to Facebook login page
driver.get("https://www.facebook.com/login")

# Log in to Facebook
email_input = driver.find_element(By.ID, "email")
password_input = driver.find_element(By.ID, "pass")
login_button = driver.find_element(By.NAME, "login")

email_input.send_keys(FB_EMAIL)
password_input.send_keys(FB_PASSWORD)
login_button.click()

# Wait for the page to load
time.sleep(5)

# Navigate to friends page
driver.get("https://www.facebook.com/me/friends")

# Wait for the friends page to load
time.sleep(5)

# Extract friend names
friends = driver.find_elements(By.XPATH, "//a[contains(@href, 'friend_id')]")
friend_names = [friend.text for friend in friends if friend.text]

print("Friends List:")
print(friend_names)

finally:
# Close the browser
driver.quit()
36 changes: 36 additions & 0 deletions general/fString.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mThe kernel failed to start due to the missing module '_sqlite3'. Consider installing this module.\n",
"\u001b[1;31mClick <a href='https://aka.ms/kernelFailuresMissingModule'>here</a> for more info."
]
}
],
"source": [
"print('krishna')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv_jupyter",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
20 changes: 20 additions & 0 deletions general/fString.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: str = "Krishna Bhunia"
age: int = 18
print(f"{name=},{age=},quick maths {24 * 7=}")

var :int = 10
print(f"{var = }")
print(f"decimal {var = :d}")
print(f"binary {var = :b}")
print(f"octal {var = :o}")
print(f"XOR {var = :x}")
print(f"{var = :X}")
print(f"{var = :e}")
print(f"{var = :E}")
print(f"{var = :f}")
print(f"{var = :F}")
print(f"{var = :g}")
print(f"{var = :G}")
print(f"{var = :n}")
print(f"{var = :%}")
print(f"{var = :_}")
8 changes: 8 additions & 0 deletions interview questions/square_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
inp = [1,2,3,4]
sq = [16,1,9,4]

for i in inp:
if i**2 in sq:
print(i,"present")
else:
print(i,"not present")
4 changes: 4 additions & 0 deletions interview questions/third_largest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
l = [3,5,2,9,8,1]

l = sorted(l, reverse=True)
print(l[2])
15 changes: 15 additions & 0 deletions interview/Longest unique substring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
inp = 'aaabcdefghaannpouiytrewsdrtgft'
char_ind = {}
first = 0
maxlen = 0
maxstr = ''
for last in range(len(inp)):
if inp[last] in char_ind and char_ind[inp[last]] >= first:
first = char_ind[inp[last]] + 1
char_ind[inp[last]] = last

if maxlen < last - first + 1:
maxlen = last - first + 1
maxstr = inp[first:last+1]

print(f"Longest unique substring : '{maxstr}' having Length : {maxlen}")
18 changes: 18 additions & 0 deletions interview/anagrams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
anagrams = ['taste', 'art', 'inlets', 'stressed', 'glean', 'dog', 'feat', 'desserts',
'notes', 'brag', 'below', 'night', 'part', 'care', 'silent', 'tops',
'angle', 'study', 'vase', 'listen', 'earth', 'hater', 'tar', 'god',
'trap', 'angel', 'stop', 'race', 'live', 'state', 'tinsel', 'baker',
'evil', 'iceman', 'grab', 'fate', 'stone', 'elbow', 'break', 'rat', 'cinema']

anagrams_d: dict[str, list[str]] = {}

for n in anagrams:
sorted_word = ''.join(sorted(list(n)))
if sorted_word in anagrams_d:
anagrams_d[sorted_word].append(n)
else:
anagrams_d[sorted_word] = [n]

anagrams_d = {value[0]: value for key, value in anagrams_d.items()}

print(anagrams_d)
Loading
Loading