Skip to content

Commit 8e6ad3f

Browse files
Merge pull request #321 from kishanrajput23/revert-320-add-todo-list
Revert "Add todo list application"
2 parents 46c0be8 + e2886f9 commit 8e6ad3f

File tree

902 files changed

+662406
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

902 files changed

+662406
-38
lines changed

"Python PDF Sorter"

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import os
2+
import re
3+
import PyPDF2
4+
import tkinter as tk
5+
from tkinter import filedialog, scrolledtext
6+
7+
class PDFSorterGUI:
8+
def __init__(self, root):
9+
self.root = root
10+
self.root.title("PDF Sorter")
11+
self.root.geometry("600x400")
12+
13+
# Initialize variables
14+
self.keyword_to_directory_map = {}
15+
self.min_size_bytes = 0
16+
self.start_page = 1
17+
self.end_page = 1
18+
19+
# Create UI elements
20+
self.create_ui()
21+
22+
def create_ui(self):
23+
# Labels and Textboxes
24+
folder_label = tk.Label(self.root, text="Select Folder:")
25+
folder_label.pack()
26+
self.folder_entry = tk.Entry(self.root)
27+
self.folder_entry.pack()
28+
29+
keywords_label = tk.Label(self.root, text="Keywords (comma-separated):")
30+
keywords_label.pack()
31+
self.keywords_entry = tk.Entry(self.root)
32+
self.keywords_entry.pack()
33+
34+
size_label = tk.Label(self.root, text="Minimum Size (bytes):")
35+
size_label.pack()
36+
self.size_entry = tk.Entry(self.root)
37+
self.size_entry.pack()
38+
39+
page_range_label = tk.Label(self.root, text="Page Range (e.g., 1-5):")
40+
page_range_label.pack()
41+
self.page_range_entry = tk.Entry(self.root)
42+
self.page_range_entry.pack()
43+
44+
# Sort button
45+
sort_button = tk.Button(self.root, text="Sort PDFs", command=self.sort_pdfs)
46+
sort_button.pack()
47+
48+
# Log area
49+
self.log_text = scrolledtext.ScrolledText(self.root, wrap=tk.WORD, width=50, height=10)
50+
self.log_text.pack()
51+
52+
def sort_pdfs(self):
53+
folder_path = self.folder_entry.get()
54+
keywords = self.keywords_entry.get()
55+
size_str = self.size_entry.get()
56+
page_range_str = self.page_range_entry.get()
57+
58+
# Parse keywords
59+
keyword_list = [kw.strip() for kw in keywords.split(',')]
60+
self.keyword_to_directory_map.clear()
61+
for keyword in keyword_list:
62+
self.keyword_to_directory_map[keyword] = "/path/to/sorted/directory" # Replace with actual directory paths
63+
64+
# Parse minimum size
65+
try:
66+
self.min_size_bytes = int(size_str)
67+
except ValueError:
68+
self.log_text.insert(tk.END, "Invalid minimum size value.\n")
69+
return
70+
71+
# Parse page range
72+
page_range = page_range_str.split('-')
73+
if len(page_range) != 2:
74+
self.log_text.insert(tk.END, "Invalid page range format.\n")
75+
return
76+
try:
77+
self.start_page = int(page_range[0])
78+
self.end_page = int(page_range[1])
79+
except ValueError:
80+
self.log_text.insert(tk.END, "Invalid page range values.\n")
81+
return
82+
83+
# Sort the PDFs
84+
self.sort_pdfs_by_criteria(folder_path)
85+
86+
def sort_pdfs_by_criteria(self, folder_path):
87+
for root, _, files in os.walk(folder_path):
88+
for file in files:
89+
if file.endswith(".pdf"):
90+
pdf_file_path = os.path.join(root, file)
91+
92+
try:
93+
with open(pdf_file_path, "rb") as pdf_file:
94+
pdf_reader = PyPDF2.PdfFileReader(pdf_file)
95+
file_size = os.path.getsize(pdf_file_path)
96+
num_pages = pdf_reader.getNumPages()
97+
98+
if file_size < self.min_size_bytes:
99+
continue
100+
101+
if not (self.start_page <= num_pages <= self.end_page):
102+
continue
103+
104+
text = ""
105+
for page_num in range(num_pages):
106+
page = pdf_reader.getPage(page_num)
107+
text += page.extractText()
108+
109+
for keyword, destination_directory in self.keyword_to_directory_map.items():
110+
if re.search(keyword, text, re.IGNORECASE):
111+
destination_file = os.path.join(destination_directory, file)
112+
os.rename(pdf_file_path, destination_file)
113+
self.log_text.insert(tk.END, f"Moved {file} to {destination_directory}\n")
114+
break
115+
116+
except Exception as e:
117+
self.log_text.insert(tk.END, f"Error processing PDF: {file}\n")
118+
print(e)
119+
120+
if __name__ == "__main__":
121+
root = tk.Tk()
122+
app = PDFSorterGUI(root)
123+
root.mainloop()

.DS_Store

26 KB
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# OTP VERIFICATION
2+
3+
## What is OTP verification
4+
5+
#### 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.
6+
7+
---
8+
9+
10+
11+
![OTP verification](otp-verification-form.jpg)
22.2 KB
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
import math
3+
import random
4+
import smtplib
5+
6+
digits="0123456789"
7+
OTP=""
8+
for i in range(6):
9+
OTP+=digits[math.floor(random.random()*10)]
10+
otp = OTP + " is your OTP"
11+
msg= otp
12+
s = smtplib.SMTP('smtp.gmail.com', 587)
13+
s.starttls()
14+
s.login("Your Gmail Account", "You app password")
15+
emailid = input("Enter your email: ")
16+
s.sendmail('&&&&&&&&&&&',emailid,msg)
17+
a = input("Enter Your OTP >>: ")
18+
if a == OTP:
19+
print("Verified")
20+
else:
21+
print("Please Check your OTP again")

.github/workflows/StarCheck.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Star validation
4+
5+
# Controls when the workflow will run
6+
on:
7+
pull_request_target:
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
- edited
13+
schedule:
14+
- cron: "5 * * * *"
15+
16+
# Allows you to run this workflow manually from the Actions tab
17+
workflow_dispatch:
18+
19+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
20+
jobs:
21+
# This workflow checks if a user has starred a repository and takes actions
22+
starcheck:
23+
runs-on: ubuntu-latest
24+
25+
# Steps represent a sequence of tasks that will be executed as part of the job
26+
steps:
27+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
28+
- uses: actions/checkout@v2
29+
with:
30+
GITHUB_TOKEN: ${{ secrets.TOKEN }}
31+
message: "Please star this repository to motivate developers! :star:"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Auto-Merge PR
2+
3+
on:
4+
pull_request:
5+
types:
6+
- synchronize # Trigger on any changes to the PR
7+
8+
jobs:
9+
auto-merge:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Merge PR
14+
run: |
15+
git config user.name "${{ github.actor }}"
16+
git config user.email "${{ github.actor }}@users.noreply.github.com"
17+
git checkout -B auto-merge
18+
git pull "${{ github.event.pull_request.head.repo.clone_url }}" "${{ github.event.pull_request.head.ref }}"
19+
git push "${{ github.event.pull_request.head.repo.clone_url }}" auto-merge
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1st python program

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from datetime import date
2+
3+
today = date.today()
4+
5+
# dd/mm/YY
6+
d1 = today.strftime("%d/%m/%Y")
7+
print("d1 =", d1)
8+
9+
# Textual month, day and year
10+
d2 = today.strftime("%B %d, %Y")
11+
print("d2 =", d2)
12+
13+
# mm/dd/y
14+
d3 = today.strftime("%m/%d/%y")
15+
print("d3 =", d3)
16+
17+
# Month abbreviation, day and year
18+
d4 = today.strftime("%b-%d-%Y")
19+
print("d4 =", d4)
20+
21+
22+
OUTPUT
23+
https://www.programiz.com/python-programming/online-compiler/

3SumClosest/3Sum_Closest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution:
2+
def threeSumClosest(self, num: List[int], target: int) -> int:
3+
num.sort()
4+
res=sum(num[:3])
5+
for i in range(len(num)-2):
6+
l,r=i+1,len(num)-1
7+
while l<r:
8+
Sum=num[i]+num[l]+num[r]
9+
if Sum==target:
10+
return Sum
11+
12+
if abs(Sum-target)<abs(res-target):
13+
res=Sum
14+
15+
if Sum<target:
16+
l+=1
17+
elif Sum>target:
18+
r-=1
19+
return res

0 commit comments

Comments
 (0)