Skip to content

Commit

Permalink
Update 🟡
Browse files Browse the repository at this point in the history
  • Loading branch information
ChandrashekharRobbi committed Aug 9, 2023
1 parent 340228f commit a425387
Show file tree
Hide file tree
Showing 9 changed files with 344 additions and 667 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.ipynb_checkpoints
__pycache__
runscript.bat
33 changes: 33 additions & 0 deletions Basic DSA Questions/Basic DSA Questions.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "a49fbd2f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
135 changes: 135 additions & 0 deletions Basic DSA Questions/watcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import re
import os
import time
import random
import subprocess
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler

# for a safer side git pull before any other operation
os.popen("git pull")

GREEN = "\033[1;32m"
RED = "\033[1;31m"
RESET = "\033[0m"
print(f"{GREEN}Hey Chandrashekhar All the best Do bunch of problems today 👍🏻💖{RESET}")


class Watcher:
# set the Path of the directory to monitor
DIRECTORY_TO_WATCH = "C:\GFG_DataScience\LeetCode\Blind 75"


def __init__(self):
self.observer = Observer()

def run(self):
event_handler = Handler()
self.observer.schedule(event_handler, self.DIRECTORY_TO_WATCH, recursive=False)
self.observer.start()
try:
while True:
time.sleep(5)
except:
self.observer.stop()
print("Error")

self.observer.join()


class Handler(FileSystemEventHandler):
counter = 0

@staticmethod
def on_any_event(event):
if event.is_directory:
return None

elif event.event_type == 'created':
# Take any action here when a file is first created.
print("Received created event - %s." % event.src_path)


elif event.event_type == 'modified':
GREEN = "\033[1;32m"
RED = "\033[1;31m"
RESET = "\033[0m"
# Taken any action here when a file is modified.
print("Received modified event - %s." % event.src_path)
# to extract specific file name from the event path
if '~' in event.src_path:
value = event.src_path.split("~")[-1]
else:
value = event.src_path.split("\\")[-1]
# to check which value gets printed
print(value)
# if the file is not Untitled then only perform operations
if value != 'Untitled.ipynb':
# get all the possible values such that it can related to changes
s = ["changes", "update", "modification","Made modifications", "Updated code", "Implemented alterations", "Tweaked the code", "Adjusted the program", "Modified the source code", "Refactored the code", "Edited", "Made adjustments"]
# pre_msg for commit messagfe
pre_msg = ["Added Some Code to","Modified","Changes in ", "Added new functionality to", "Introduced code changes to","Integrated new code into","Updated code in","Made changes to","Tweaked code in","Edited code in","Adjusted code in","Refactored code in","Revised code in","Reworked code in","Altered code in","Improved code in"]
# emojis
emojis = ['👀','💖','🥳','🙌','🚩','😎','🥰','🫣','👻','💪','✌','✍','👑','🚀','❤️‍','🔥']
# it returns the output of what all changes we have done to the file
diff_output = subprocess.check_output(['git', 'diff', f'{value}']).decode()
# this is the pattern to find def function present in it or not
pattern = r"def\s+(\w+)\("
print("Inside the While loop 🌀")
# print("Diff Output", diff_output)
# Use re.search() to find the first match of the pattern in the input string
match = re.findall(pattern, diff_output)
if match: print("Match Found 👍🏻")
else: print("Match Not Found 👎🏻")
# set initial value to None
commit_message = None
# if a match is founf then change the commit_message with the function name
if match:
commit_message = f"{random.choice(pre_msg)} `{match[-1]}` function {random.choice(emojis)}"
Handler.counter = 0
n = 0
# else select random from s and change the value of commit_message
else:
# commit_message = random.choice(s)
# check if the counter has reached 20
n = 20
if Handler.counter == n:
# reset the counter
Handler.counter = 0
# choose a random commit message from s
commit_message = random.choice(s) + random.choice(emojis)
else:
# increment the counter
Handler.counter += 1
# print the commit message to see in terminal
k = f"{RED}You haven't made changes in the functions so your commit will be added after {n - Handler.counter} changes in your file:({RESET}" if (20 - Handler.counter) > 0 else f"{GREEN}Your commit will be added now:){RESET}"

print(f"Counter: {Handler.counter}")
if commit_message != None:
print(f"commit message is {GREEN}'{commit_message}'{RESET}")
# now git add the file
os.popen(f'git add "{value}"')
# time.sleep so that there will be no load at once at cmd
time.sleep(1)
os.popen(f'git commit -m "{commit_message}"')
# finally git push 🥳
time.sleep(1)
os.popen("git push")
# os.popen("^C")
time.sleep(1)
# this timer such that it will again see in after 10 seconds
print(f"{GREEN}Git Pushed Successfully{RESET} 🥳")
else:
print(k)

time.sleep(10)
# if not untitled then send message
else:
print(f"{value} is common so it wouldn't be added Rename it to add")
# print("test")



if __name__ == '__main__':
w = Watcher()
w.run()
28 changes: 11 additions & 17 deletions Deque.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
"cell_type": "code",
"execution_count": 2,
"id": "9d60a2c8",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
Expand All @@ -70,24 +72,12 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"id": "65ca748e",
"metadata": {
"tags": []
},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'deque' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[1], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m deq \u001b[38;5;241m=\u001b[39m \u001b[43mdeque\u001b[49m()\n\u001b[0;32m 2\u001b[0m \u001b[38;5;66;03m#Function to erase the element from specified position X in deque.\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21meraseAt\u001b[39m(deq,x):\n",
"\u001b[1;31mNameError\u001b[0m: name 'deque' is not defined"
]
}
],
"outputs": [],
"source": [
"deq = deque()\n",
"#Function to erase the element from specified position X in deque.\n",
Expand Down Expand Up @@ -120,7 +110,9 @@
"cell_type": "code",
"execution_count": 4,
"id": "b8c58fe3",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"class List_deque:\n",
Expand Down Expand Up @@ -156,7 +148,9 @@
"cell_type": "code",
"execution_count": 5,
"id": "ab4a4480",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"d = List_deque()"
Expand Down
6 changes: 4 additions & 2 deletions Graphs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"id": "f421e371",
"metadata": {
"tags": []
Expand All @@ -27,7 +27,9 @@
"metadata": {},
"source": [
"# Graphs\n",
"\n"
"\n",
"\n",
"#### if the below links are not clickable then : [Click Me](https://nbviewer.org/github/ChandrashekharRobbi/GFG-DSA/blob/main/Graphs.ipynb?flush_cache=True)"
]
},
{
Expand Down
20 changes: 14 additions & 6 deletions Hashing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@
},
{
"cell_type": "code",
"execution_count": 54,
"execution_count": 43,
"id": "71fa38b9",
"metadata": {},
"outputs": [],
Expand All @@ -1281,7 +1281,7 @@
},
{
"cell_type": "code",
"execution_count": 56,
"execution_count": 44,
"id": "e539f705",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -1310,7 +1310,7 @@
},
{
"cell_type": "code",
"execution_count": 58,
"execution_count": 45,
"id": "48603a6a",
"metadata": {},
"outputs": [],
Expand All @@ -1336,7 +1336,7 @@
},
{
"cell_type": "code",
"execution_count": 60,
"execution_count": 46,
"id": "4eb60bea",
"metadata": {},
"outputs": [],
Expand All @@ -1361,7 +1361,7 @@
},
{
"cell_type": "code",
"execution_count": 62,
"execution_count": 47,
"id": "0d0578d0",
"metadata": {},
"outputs": [],
Expand All @@ -1377,7 +1377,7 @@
},
{
"cell_type": "code",
"execution_count": 64,
"execution_count": 48,
"id": "6322545c",
"metadata": {},
"outputs": [],
Expand All @@ -1404,6 +1404,14 @@
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "990953f6",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading

0 comments on commit a425387

Please sign in to comment.