Skip to content

Commit

Permalink
Revert "Add todo list application"
Browse files Browse the repository at this point in the history
  • Loading branch information
kishanrajput23 authored Nov 28, 2023
1 parent 46c0be8 commit e2886f9
Show file tree
Hide file tree
Showing 902 changed files with 662,406 additions and 38 deletions.
123 changes: 123 additions & 0 deletions "Python PDF Sorter"
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import os
import re
import PyPDF2
import tkinter as tk
from tkinter import filedialog, scrolledtext

class PDFSorterGUI:
def __init__(self, root):
self.root = root
self.root.title("PDF Sorter")
self.root.geometry("600x400")

# Initialize variables
self.keyword_to_directory_map = {}
self.min_size_bytes = 0
self.start_page = 1
self.end_page = 1

# Create UI elements
self.create_ui()

def create_ui(self):
# Labels and Textboxes
folder_label = tk.Label(self.root, text="Select Folder:")
folder_label.pack()
self.folder_entry = tk.Entry(self.root)
self.folder_entry.pack()

keywords_label = tk.Label(self.root, text="Keywords (comma-separated):")
keywords_label.pack()
self.keywords_entry = tk.Entry(self.root)
self.keywords_entry.pack()

size_label = tk.Label(self.root, text="Minimum Size (bytes):")
size_label.pack()
self.size_entry = tk.Entry(self.root)
self.size_entry.pack()

page_range_label = tk.Label(self.root, text="Page Range (e.g., 1-5):")
page_range_label.pack()
self.page_range_entry = tk.Entry(self.root)
self.page_range_entry.pack()

# Sort button
sort_button = tk.Button(self.root, text="Sort PDFs", command=self.sort_pdfs)
sort_button.pack()

# Log area
self.log_text = scrolledtext.ScrolledText(self.root, wrap=tk.WORD, width=50, height=10)
self.log_text.pack()

def sort_pdfs(self):
folder_path = self.folder_entry.get()
keywords = self.keywords_entry.get()
size_str = self.size_entry.get()
page_range_str = self.page_range_entry.get()

# Parse keywords
keyword_list = [kw.strip() for kw in keywords.split(',')]
self.keyword_to_directory_map.clear()
for keyword in keyword_list:
self.keyword_to_directory_map[keyword] = "/path/to/sorted/directory" # Replace with actual directory paths

# Parse minimum size
try:
self.min_size_bytes = int(size_str)
except ValueError:
self.log_text.insert(tk.END, "Invalid minimum size value.\n")
return

# Parse page range
page_range = page_range_str.split('-')
if len(page_range) != 2:
self.log_text.insert(tk.END, "Invalid page range format.\n")
return
try:
self.start_page = int(page_range[0])
self.end_page = int(page_range[1])
except ValueError:
self.log_text.insert(tk.END, "Invalid page range values.\n")
return

# Sort the PDFs
self.sort_pdfs_by_criteria(folder_path)

def sort_pdfs_by_criteria(self, folder_path):
for root, _, files in os.walk(folder_path):
for file in files:
if file.endswith(".pdf"):
pdf_file_path = os.path.join(root, file)

try:
with open(pdf_file_path, "rb") as pdf_file:
pdf_reader = PyPDF2.PdfFileReader(pdf_file)
file_size = os.path.getsize(pdf_file_path)
num_pages = pdf_reader.getNumPages()

if file_size < self.min_size_bytes:
continue

if not (self.start_page <= num_pages <= self.end_page):
continue

text = ""
for page_num in range(num_pages):
page = pdf_reader.getPage(page_num)
text += page.extractText()

for keyword, destination_directory in self.keyword_to_directory_map.items():
if re.search(keyword, text, re.IGNORECASE):
destination_file = os.path.join(destination_directory, file)
os.rename(pdf_file_path, destination_file)
self.log_text.insert(tk.END, f"Moved {file} to {destination_directory}\n")
break

except Exception as e:
self.log_text.insert(tk.END, f"Error processing PDF: {file}\n")
print(e)

if __name__ == "__main__":
root = tk.Tk()
app = PDFSorterGUI(root)
root.mainloop()
Binary file added .DS_Store
Binary file not shown.
11 changes: 11 additions & 0 deletions .github/workflows/OTP_verifier/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# OTP VERIFICATION

## What is OTP verification

#### What is SMS OTP verification? OTP or One Time Password is a temporary authentication code sent via SMS to a user's registered mobile number. When a user logs in to an app or makes a transaction online, the system will automatically generate and send an OTP.

---



![OTP verification](otp-verification-form.jpg)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions .github/workflows/OTP_verifier/otp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
import math
import random
import smtplib

digits="0123456789"
OTP=""
for i in range(6):
OTP+=digits[math.floor(random.random()*10)]
otp = OTP + " is your OTP"
msg= otp
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
s.login("Your Gmail Account", "You app password")
emailid = input("Enter your email: ")
s.sendmail('&&&&&&&&&&&',emailid,msg)
a = input("Enter Your OTP >>: ")
if a == OTP:
print("Verified")
else:
print("Please Check your OTP again")
31 changes: 31 additions & 0 deletions .github/workflows/StarCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This is a basic workflow to help you get started with Actions

name: Star validation

# Controls when the workflow will run
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
- edited
schedule:
- cron: "5 * * * *"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow checks if a user has starred a repository and takes actions
starcheck:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
message: "Please star this repository to motivate developers! :star:"
21 changes: 21 additions & 0 deletions .github/workflows/auto-pr-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Auto-Merge PR

on:
pull_request:
types:
- synchronize # Trigger on any changes to the PR

jobs:
auto-merge:
runs-on: ubuntu-latest

steps:
- name: Merge PR
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git checkout -B auto-merge
git pull "${{ github.event.pull_request.head.repo.clone_url }}" "${{ github.event.pull_request.head.ref }}"
git push "${{ github.event.pull_request.head.repo.clone_url }}" auto-merge
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions 1st python program
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from datetime import date

today = date.today()

# dd/mm/YY
d1 = today.strftime("%d/%m/%Y")
print("d1 =", d1)

# Textual month, day and year
d2 = today.strftime("%B %d, %Y")
print("d2 =", d2)

# mm/dd/y
d3 = today.strftime("%m/%d/%y")
print("d3 =", d3)

# Month abbreviation, day and year
d4 = today.strftime("%b-%d-%Y")
print("d4 =", d4)


OUTPUT
https://www.programiz.com/python-programming/online-compiler/
19 changes: 19 additions & 0 deletions 3SumClosest/3Sum_Closest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution:
def threeSumClosest(self, num: List[int], target: int) -> int:
num.sort()
res=sum(num[:3])
for i in range(len(num)-2):
l,r=i+1,len(num)-1
while l<r:
Sum=num[i]+num[l]+num[r]
if Sum==target:
return Sum

if abs(Sum-target)<abs(res-target):
res=Sum

if Sum<target:
l+=1
elif Sum>target:
r-=1
return res
Loading

0 comments on commit e2886f9

Please sign in to comment.