Skip to content

Commit ea5500f

Browse files
authored
Merge pull request #1 from ankitdobhal/master
Updating my fork with changes
2 parents 744547f + 550b652 commit ea5500f

File tree

20 files changed

+557
-13
lines changed

20 files changed

+557
-13
lines changed

Basic-Scripts/balanced_paranthesis.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
openBracketList = ["[", "{", "("]
2+
closeBracketList = ["]", "}", ")"]
3+
4+
5+
def check_parentheses(data: str) -> str:
6+
"""
7+
check_parentheses() : Will take a string as an arguement and each time when an open parentheses is encountered
8+
will push it in the stack, and when closed parenthesis is encountered,
9+
will match it with the top of stack and pop it.
10+
11+
Parameters:
12+
data (str): takes a string.
13+
14+
Returns:
15+
str: Returns a string value whether string passed is balanced or Unbalanced.
16+
"""
17+
stack = []
18+
for index in data:
19+
if index in openBracketList:
20+
stack.append(index)
21+
elif index in closeBracketList:
22+
position = closeBracketList.index(index)
23+
if (len(stack) > 0) and (
24+
openBracketList[position] == stack[len(stack) - 1]
25+
):
26+
stack.pop()
27+
else:
28+
return "Unbalanced"
29+
if len(stack) == 0:
30+
return "Balanced"
31+
else:
32+
return "Unbalanced"
33+
34+
35+
if __name__ == "__main__":
36+
37+
data = input("Enter the string to check:\t")
38+
result = check_parentheses(data)
39+
print(result)
40+

Basic-Scripts/tic-tac-toe.py

Whitespace-only changes.

Contribution.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,29 @@
22
If this is your first time to open source contribution in python So that I have created this repo for all the you to start contributing.
33

44
# How to contribute!
5-
## Steps:
6-
* fork the [repository](https://github.com/ankitdobhal/Python-Scripts)
7-
* Clone the fork [repo](https://github.com/ankitdobhal/Python-Scripts)
8-
(git clone https://github.com/ankitdobhal/Python-Scripts)
9-
* Create new branch
10-
(git checkout -b <Your-Branch-Name>)
11-
* Add files in scripts folder
12-
(git add <your-contribution>)
13-
* Add a commit message !
14-
(git commit -a -m "<Added your message>")
15-
* Push changes
16-
(git push origin)
17-
* Create pull requests
5+
6+
## Steps:
7+
- First commment on the issue in which you want to work upon.
8+
- Issue-1 : https://github.com/ankitdobhal/Awesome-Python-Scripts/issues/91
9+
- Issue-2 : https://github.com/ankitdobhal/Awesome-Python-Scripts/issues/92
10+
- Issue-3 : https://github.com/ankitdobhal/Awesome-Python-Scripts/issues/93
11+
- Issue-4 : https://github.com/ankitdobhal/Awesome-Python-Scripts/issues/94
12+
13+
- Fork the [repository](https://github.com/ankitdobhal/Awesome-Python-Scripts)
14+
15+
- Clone the fork [repo](https://github.com/ankitdobhal/Awesome-Python-Scripts)
16+
- git clone https://github.com/<Your_Username>/Awesome-Python-Scripts
17+
- Create new branch
18+
- git checkout -b <Your-Branch-Name>
19+
20+
- Add Scripts related to your respective issues.
21+
- git add <your-contribution>
22+
23+
- Add a commit message !
24+
- git commit -a -m "<Added your message>"
25+
26+
- Push changes
27+
- git push -u origin <name_of_your_branch>
28+
29+
- Create pull requests
30+
- [Try to Mention the related issue for your PR]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Invisible Cloak
2+
This is a python script about the cloak of invisibility which was used by harry to become invisible.
3+
4+
## How it works
5+
* It captures and store the background.
6+
* Detect the defined color using color detection.
7+
* Segment out the red colored cloth by generating a mask.
8+
* Generate the final augmented output to create a magical effect.
9+
10+
## Installation
11+
* Use the package manager [pip](https://pip.pypa.io/en/stable/) to install Opencv.
12+
13+
```bash
14+
pip install opencv-python
15+
```
16+
* Install Numpy
17+
18+
```bash
19+
pip install numpy
20+
```
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import numpy as np
2+
import cv2
3+
import time
4+
5+
print("""
6+
BE PREPARE YOU WILL BE INVISIBLE SOON............
7+
""")
8+
9+
if __name__ == '__main__':
10+
cap = cv2.VideoCapture(0)
11+
12+
#For capturing output video
13+
fourcc = cv2.VideoWriter_fourcc(*'XVID')
14+
out = cv2.VideoWriter('harry.avi' , fourcc, 20.0, (640,480))
15+
time.sleep(2)
16+
background = 0
17+
18+
#capturing background
19+
for i in range(30):
20+
ret, background = cap.read()
21+
22+
#capturing image
23+
while(cap.isOpened()):
24+
ret, img = cap.read()
25+
26+
if not ret:
27+
break
28+
#HSV stands for Hue Satrurated Value
29+
hsv=cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
30+
31+
#YOU CAN CHANGE THE COLOR VALUE BELOW ACCORDING TO YOUR CLOTH COLOR
32+
lower_red = np.array([0,120,70])
33+
upper_red = np.array([10,255,255])
34+
mask1 = cv2.inRange(hsv , lower_red , upper_red)
35+
36+
lower_red = np.array([170,120,70])
37+
upper_red = np.array([180,255,255])
38+
mask2 = cv2.inRange(hsv , lower_red , upper_red)
39+
40+
mask1 = mask1 + mask2
41+
42+
#Open and clean the mask image
43+
mask1=cv2.morphologyEx(mask1, cv2.MORPH_OPEN ,np.ones((3,3) , np.uint8) , iterations=2)
44+
45+
mask2=cv2.morphologyEx(mask1, cv2.MORPH_DILATE ,np.ones((3,3) , np.uint8) , iterations=1)
46+
47+
mask2 = cv2.bitwise_not(mask1)
48+
49+
#Generating the final output
50+
res1 = cv2.bitwise_and(background, background, mask=mask1)
51+
res2 = cv2.bitwise_and(img, img, mask=mask2)
52+
53+
final_output = cv2.addWeighted(res1 , 1, res2 , 1, 0)
54+
55+
cv2.imshow('Invisibility Game' , final_output)
56+
k=cv2.waitKey(10)
57+
if k==27:
58+
print("Escape hit, closing...")
59+
break
60+
61+
cap.release()
62+
out.release()
63+
cv2.destroyAllWindows()

Image-Processing/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Image-Processing
2+
Image processing has been used to create weird and beautiful modifications to pictures many of us have seen online. Older black and white photos can be brought to life using colorization techniques. On the other hand, color photos can be made to look like old black and white photos. In addition to distorting images for entertainment, image processing can be used for more serious applications, for example, to enhance medical imaging to screen patients for cancer or other diseases.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# In this script we will automate Google using Selenium
2+
3+
# Imports :
4+
from selenium import webdriver
5+
from selenium.webdriver.common.keys import Keys
6+
import time
7+
from time import sleep
8+
from webdriver_manager.chrome import ChromeDriverManager
9+
10+
driver = webdriver.Chrome(ChromeDriverManager().install())
11+
12+
# enter the link of the google
13+
driver.get("https://www.google.com")
14+
15+
# AUTOMATING CLICKING OF THE LINK TEXT
16+
17+
# enter the name of the text
18+
element = driver.find_element_by_link_text("About")
19+
20+
# delaying by 2 sec
21+
time.sleep(2)
22+
# clicking of the element is done by the below click method
23+
element.click()
24+
time.sleep(5)
25+
26+
# AUTOMATING CLICKING OF BACKWARD AND FOORWARD BUTTON
27+
28+
# going backward
29+
driver.back()
30+
31+
time.sleep(5)
32+
33+
# going forward
34+
driver.forward()
35+
36+
# AUTOMATING THE REFRESH OF THE WEBPAGE
37+
time.sleep(10)
38+
driver.refresh()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# In this script we will automate Google Search using Selenium
2+
3+
# Imports :
4+
from selenium import webdriver
5+
from selenium.webdriver.common.keys import Keys
6+
import time
7+
from time import sleep
8+
from webdriver_manager.chrome import ChromeDriverManager
9+
10+
11+
driver = webdriver.Chrome(ChromeDriverManager().install())
12+
13+
# providing the link
14+
driver.get("https://www.google.com")
15+
16+
# then we will look for the search bar name(here name is referred to the html code)
17+
element = driver.find_element_by_name("q")
18+
19+
# this is to provide some delay so that we can easily see the process
20+
time.sleep(2)
21+
element.clear()
22+
23+
# here whatever we have to search we can write between the parenthesis
24+
element.send_keys("Python")
25+
26+
# for the enter button
27+
element.send_keys(Keys.RETURN)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# System-Automation-Scripts
2+
## Automating Google using Selenium
3+
4+
#### Install Requirements :
5+
1. Install Selenium by writing the following pip command, at command prompt -
6+
> pip install selenium
7+
8+
2. Install ChromeDriver
9+
10+
#### Automating_Google_Search.py
11+
- This file contains the script to automate the Google Search , you just have to enter whatever you want to search & run the file.
12+
13+
#### Automating_Google.py
14+
- This file contains the script to automate various tasks on Google like clicking the text link, cliking the forward and the backward button and refreshing of the page .
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import os
2+
from pathlib import Path as pt
3+
4+
DIRECTORIES = {
5+
"HTML": [".html5", ".html", ".htm", ".xhtml"],
6+
"IMAGES": [".jpeg", ".jpg", ".tiff", ".gif", ".bmp", ".png", ".bpg", "svg",
7+
".heif", ".psd"],
8+
"VIDEOS": [".avi", ".flv", ".wmv", ".mov", ".mp4", ".webm", ".vob", ".mng",
9+
".qt", ".mpg", ".mpeg", ".3gp"],
10+
"DOCUMENTS": [".oxps", ".epub", ".pages", ".docx", ".doc", ".fdf", ".ods",
11+
".odt", ".pwi", ".xsn", ".xps", ".dotx", ".docm", ".dox",
12+
".rvg", ".rtf", ".rtfd", ".wpd", ".xls", ".xlsx", ".ppt",
13+
"pptx"],
14+
"ARCHIVES": [".a", ".ar", ".cpio", ".iso", ".tar", ".gz", ".rz", ".7z",
15+
".dmg", ".rar", ".xar", ".zip"],
16+
"AUDIO": [".aac", ".aa", ".aac", ".dvf", ".m4a", ".m4b", ".m4p", ".mp3",
17+
".msv", "ogg", "oga", ".raw", ".vox", ".wav", ".wma"],
18+
"PLAINTEXT": [".txt", ".in", ".out"],
19+
"PDF": [".pdf"],
20+
"PYTHON": [".py"],
21+
"C": [".c"],
22+
"CPP": [".cpp"],
23+
"JAVA": [".java"],
24+
"XML": [".xml"],
25+
"EXE": [".exe"],
26+
"SHELL": [".sh"]
27+
28+
}
29+
30+
FILE_FORMATS = {file_format: directory
31+
for directory, file_formats in DIRECTORIES.items()
32+
for file_format in file_formats}
33+
34+
def org_junk():
35+
for entry in os.scandir():
36+
if entry.is_dir():
37+
continue
38+
file_path = pt(entry)
39+
file_format = file_path.suffix.lower()
40+
if file_format in FILE_FORMATS:
41+
directory_path = pt(FILE_FORMATS[file_format])
42+
directory_path.mkdir(exist_ok=True)
43+
file_path.rename(directory_path.joinpath(file_path))
44+
45+
for dir in os.scandir():
46+
try:
47+
os.rmdir(dir)
48+
except:
49+
pass
50+
51+
if __name__ == "__main__":
52+
org_junk()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Unnecesaary Files
2+
3+
app/__pycahce__/
4+
.idea
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Medium-Articles-Details-Scrapping
2+
This script will scrap details about medium articles published in a date range in the given publication. The dates are choosen randomly. If there is no article on that date, then that date is skipped. The results returned is a dataframe which can be saved in any format, currently saves as CSV. Here is the preview of the terminal:
3+
![](terminal-preview.PNG)
4+
5+
# Requirements
6+
- numpy
7+
- pandas
8+
- bs4
9+
- requests
10+
11+
# How to run?
12+
- Run the command: python run.py
13+
14+
# About the Scrap class
15+
A Scrapper to get details about medium articles published in a date range in a Publication by selecting random dates.
16+
17+
Attributes
18+
----------
19+
urls_dict : dict
20+
key-value pairs of the publication name with link. Example:
21+
urls_dict={"The Startup":"https://medium.com/swlh"}
22+
23+
start_date : str
24+
starting date of the search. Default: 2020-01-01
25+
26+
end_date : str
27+
ending date of the search. Default: 2020-08-01
28+
29+
year : int
30+
year in which search has to be done. Default: 2020
31+
32+
number: int
33+
number of random dates you want to pick. Default: 10
34+
35+
Methods
36+
-------
37+
scrap():
38+
Scrapping process will be initiated by this method.
39+
40+
dataframe():
41+
Returns the dataframe object.
42+

0 commit comments

Comments
 (0)