Skip to content

Commit 2a80986

Browse files
authored
Merge pull request #239 from arefathi/main
Included some python scripts
2 parents 65f1222 + a188105 commit 2a80986

File tree

6 files changed

+237
-0
lines changed

6 files changed

+237
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#a script that converts images to pdf
2+
3+
from reportlab.platypus import Image, SimpleDocTemplate
4+
5+
6+
def images_to_pdf(
7+
list_of_images: list, pdf_file_name: str, width=None, height=None, hAlign="CENTER"
8+
) -> bool:
9+
"""
10+
Function convert the image into Pdf
11+
"""
12+
pdf = SimpleDocTemplate(pdf_file_name)
13+
images = []
14+
for i in list_of_images:
15+
try:
16+
re = Image(i, width=width, height=height, hAlign=hAlign)
17+
except:
18+
pass
19+
images.append(re)
20+
pdf.build(images)
21+
22+
return True
23+
24+
25+
if __name__ == "__main__":
26+
# You Can use any source of image
27+
# Here I use posts of Instagram with hashtag 'tamil'
28+
from instagramy import InstagramHashTag
29+
30+
tag = InstagramHashTag("tamil")
31+
print(images_to_pdf(tag.posts_display_urls, "tamil.pdf", width=250, height=250))
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
This script can automatically perform the google search process and open the website in default web browser.
3+
"""
4+
5+
from googlesearch import search
6+
from webbrowser import open
7+
8+
9+
def google_search(query, no_of_results):
10+
11+
result = search(query, num=no_of_results, pause=2, stop=no_of_results)
12+
13+
return result
14+
15+
16+
if __name__ == "__main__":
17+
18+
query = input("Enter the Query: ")
19+
no_of_results = int(input("Enter number of tabs open in browser: "))
20+
for i in google_search(query, no_of_results):
21+
open(i)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import csv
2+
import json
3+
4+
5+
def csv_to_json(input_csv: str, output_json: str) -> bool:
6+
"""
7+
Funtion to Convert csv to json file
8+
Funtion might need some changes according to your file organization and type
9+
"""
10+
11+
with open(input_csv, "r") as file_obj:
12+
reader = list(csv.DictReader(file_obj))
13+
json_obj = json.dumps(reader)
14+
15+
with open(output_json, "w") as file_obj:
16+
file_obj.writelines(json_obj)
17+
18+
return True
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# the calculator
2+
from tkinter import Tk, Button, Label, Grid, Entry, END
3+
4+
root = Tk()
5+
root.title("CALCULATOR")
6+
e = Entry(
7+
root,
8+
width=35,
9+
borderwidth=10,
10+
)
11+
e.grid(row=0, column=0, columnspan=4, padx=8, pady=8)
12+
13+
14+
def joker(number):
15+
now = e.get()
16+
e.delete(0, END)
17+
e.insert(0, str(now) + str(number))
18+
19+
20+
def addd():
21+
n1 = e.get()
22+
global num1
23+
global cal
24+
cal = "add"
25+
num1 = float(n1)
26+
e.delete(0, END)
27+
28+
29+
def sub():
30+
n1 = e.get()
31+
global num1
32+
global cal
33+
cal = "sub"
34+
num1 = float(n1)
35+
e.delete(0, END)
36+
37+
38+
def mul():
39+
n1 = e.get()
40+
global num1
41+
global cal
42+
cal = "mul"
43+
num1 = float(n1)
44+
e.delete(0, END)
45+
46+
47+
def div():
48+
n1 = e.get()
49+
global num1
50+
global cal
51+
cal = "div"
52+
num1 = float(n1)
53+
e.delete(0, END)
54+
55+
56+
def equ():
57+
if cal == "add":
58+
n2 = e.get()
59+
e.delete(0, END)
60+
e.insert(0, num1 + float(n2))
61+
elif cal == "sub":
62+
n2 = e.get()
63+
e.delete(0, END)
64+
e.insert(0, num1 - float(n2))
65+
elif cal == "mul":
66+
n2 = e.get()
67+
e.delete(0, END)
68+
e.insert(0, num1 * float(n2))
69+
elif cal == "div":
70+
n2 = e.get()
71+
e.delete(0, END)
72+
e.insert(0, num1 / float(n2))
73+
else:
74+
pass
75+
76+
77+
def clr():
78+
e.delete(0, END)
79+
80+
81+
# bottons
82+
btn1 = Button(root, text="1", padx=20, pady=5, command=lambda: joker("1"))
83+
btn2 = Button(root, text="2", padx=20, pady=5, command=lambda: joker("2"))
84+
btn3 = Button(root, text="3", padx=20, pady=5, command=lambda: joker("3"))
85+
btn4 = Button(root, text="4", padx=20, pady=5, command=lambda: joker("4"))
86+
btn5 = Button(root, text="5", padx=20, pady=5, command=lambda: joker("5"))
87+
btn6 = Button(root, text="6", padx=20, pady=5, command=lambda: joker("6"))
88+
btn7 = Button(root, text="7", padx=20, pady=5, command=lambda: joker("7"))
89+
btn8 = Button(root, text="8", padx=20, pady=5, command=lambda: joker("8"))
90+
btn9 = Button(root, text="9", padx=20, pady=5, command=lambda: joker("9"))
91+
btn0 = Button(root, text="0", padx=20, pady=5, command=lambda: joker("0"))
92+
btnadd = Button(root, text="+", padx=20, pady=5, command=addd)
93+
btnsub = Button(root, text="-", padx=20, pady=5, command=sub)
94+
btnmul = Button(root, text="*", padx=20, pady=5, command=mul)
95+
btndiv = Button(root, text="/", padx=20, pady=5, command=div)
96+
btnequ = Button(root, text="=", padx=20, pady=5, command=equ)
97+
btndot = Button(root, text=".", padx=20, pady=5, command=lambda: joker("."))
98+
btnclr = Button(root, text="clear", padx=20, pady=5, command=clr)
99+
100+
101+
btn1.grid(row=3, column=0)
102+
btn2.grid(row=3, column=1)
103+
btn3.grid(row=3, column=2)
104+
btn4.grid(row=2, column=0)
105+
btn5.grid(row=2, column=1)
106+
btn6.grid(row=2, column=2)
107+
btn7.grid(row=1, column=0)
108+
btn8.grid(row=1, column=1)
109+
btn9.grid(row=1, column=2)
110+
btn0.grid(row=4, column=1)
111+
btnadd.grid(row=1, column=3)
112+
btnsub.grid(row=2, column=3)
113+
btnmul.grid(row=3, column=3)
114+
btndiv.grid(row=4, column=3)
115+
btnequ.grid(row=4, column=0)
116+
btndot.grid(row=4, column=2)
117+
btnclr.grid(row=5, column=1)
118+
119+
root.mainloop()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from requests import post
2+
3+
# requires API from tinyurl.com
4+
5+
def TinyShortner(big_url: str) -> str:
6+
"""
7+
Function short the big urls to tiny by Tiny Api
8+
"""
9+
return post("https://tinyurl.com/api-create.php", data={"url": big_url}).text
10+
11+
12+
if __name__ == "__main__":
13+
url = input("Enter the Big Url to short: ")
14+
print(TinyShortner(url))
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
This scripts fetches all saved wifi passwords in your Windows PC
3+
"""
4+
5+
import subprocess
6+
7+
8+
def get_all_profiles():
9+
try:
10+
data = subprocess.check_output(
11+
["netsh", "wlan", "show", "profiles", "key=clear"]
12+
).decode("utf-8", errors="backslashreplace")
13+
return data
14+
except FileNotFoundError:
15+
return "Only For Windows"
16+
17+
18+
def get_profiles_info(profile):
19+
try:
20+
data = subprocess.check_output(
21+
["netsh", "wlan", "show", "profiles", profile, "key=clear"]
22+
).decode("utf-8", errors="backslashreplace")
23+
24+
return data
25+
except subprocess.CalledProcessError:
26+
return "Profile Not Found"
27+
except FileNotFoundError:
28+
return "Only For Windows"
29+
30+
31+
if __name__ == "__main__":
32+
print(get_all_profiles())
33+
profile = input("Enter the profile Name: ")
34+
print(get_profiles_info(profile))

0 commit comments

Comments
 (0)