Skip to content

Commit 8f6fa06

Browse files
committed
experimentals
1 parent cd6ccd9 commit 8f6fa06

File tree

24 files changed

+7045
-0
lines changed

24 files changed

+7045
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,6 @@ ENV/
109109
*.idea*
110110

111111
*.tex
112+
duplicate.db
113+
duplicate.sqlite
114+
Trash

autoclicker/autoclicker/__init__.py

Whitespace-only changes.
9.07 KB
Loading

autoclicker/autoclicker/main.py

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import sys
2+
import time
3+
4+
import pyautogui
5+
from pyautogui import Point
6+
7+
times_per_second = 20
8+
delay_between_clicks = 1 / times_per_second
9+
10+
x_offset = 30
11+
12+
13+
def __initial_delay(delay: int):
14+
time.sleep(delay)
15+
print("finished delay")
16+
17+
18+
def clicks(click_times: int = 10, delay_before_start: int = 3):
19+
global delay_between_clicks
20+
if delay_before_start != 0:
21+
__initial_delay(delay_before_start)
22+
23+
start_position: pyautogui.Point = pyautogui.position()
24+
for i in range(0, click_times):
25+
pyautogui.click()
26+
time.sleep(delay_between_clicks)
27+
current_position: pyautogui.Point = pyautogui.position()
28+
# print("current position = " + str(current_position))
29+
# print("start position: " + str(start_position))
30+
if current_position != start_position:
31+
print("not equal position")
32+
break
33+
34+
35+
def click_image_mode(delay_before_start: int = 3):
36+
__initial_delay(delay_before_start)
37+
global x_offset
38+
image_abs_path = '/Users/amitseal/git/' \
39+
'automating-boring-tasks-using-python/' \
40+
'autoclicker/autoclicker/images/eye.png'
41+
42+
try:
43+
print("entering while")
44+
for i in range(0, 5):
45+
print("in while")
46+
47+
print("trying to find image")
48+
start_x = 79
49+
end_x = 1346
50+
start_y = 152
51+
end_y = 871
52+
width = end_x - start_x
53+
height = end_y - start_y
54+
image_location: Point = pyautogui.locateOnScreen(
55+
image_abs_path,
56+
region=(start_x, width, start_y, height),
57+
confidence=0.6)
58+
pyautogui.screenshot('img{}.png'.format(str(i)),
59+
region=(
60+
start_x, start_y, width * 2, height * 2))
61+
62+
print("found image!")
63+
print(image_location)
64+
break
65+
continue
66+
start_position = Point(image_location.x - x_offset,
67+
image_location.y)
68+
pyautogui.moveTo(start_position, image_location.y)
69+
current_position: pyautogui.Point = pyautogui.position()
70+
time.sleep(delay_between_clicks)
71+
pyautogui.click()
72+
if current_position != start_position:
73+
print("not equal position")
74+
break
75+
break
76+
except pyautogui.ImageNotFoundException:
77+
print("image not found, break")
78+
79+
80+
def find_current_position():
81+
__initial_delay(2)
82+
while True:
83+
current = pyautogui.position()
84+
print(current)
85+
time.sleep(1)
86+
87+
88+
if __name__ == '__main__':
89+
if len(sys.argv) > 1:
90+
print(sys.argv)
91+
# exit()
92+
clicks(1000, int(sys.argv[1]))
93+
else:
94+
clicks(1000, 2)
95+
# click_image_mode()
96+
# find_current_position()

clipboard_modifier/__init__.py

Whitespace-only changes.

clipboard_modifier/init.py

Whitespace-only changes.

clipboard_modifier/main.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pyperclip
2+
3+
def main():
4+
clip = pyperclip.paste()
5+
lines = clip.splitlines()
6+
new_lines = ""
7+
for line in lines:
8+
line = line.replace("[00 --> 00]","")
9+
if "->" in line:
10+
if "[" in line and "]" in line:
11+
line = line[25:]
12+
else:
13+
continue
14+
new_lines += line.replace("\n", " ").replace(" ", " ").replace("’", "'") + " "
15+
print(new_lines)
16+
pyperclip.copy(new_lines.replace(" ", " "))
17+
18+
if __name__ == "__main__":
19+
main()

clipboard_modifier/runme.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
/Users/amit/git/automating-boring-tasks-using-python/clipboard_modifier/venv/bin/python /Users/amit/git/automating-boring-tasks-using-python/clipboard_modifier/main.py

gplay_apk_download_multidex/LOG.csv

+5,844
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/amitseal/git/automating-boring-tasks-using-python/image_sort_landscape_portrait/src/venv/bin/python /Users/amitseal/git/automating-boring-tasks-using-python/image_sort_landscape_portrait/src/main.py

iterative_web_search/main.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env python3
2+
import time
3+
import random
4+
import re
5+
6+
# https://github.com/search?p=4&q=Cipher.getInstance&type=Code
7+
8+
class IterSearch():
9+
def __init__(self) -> None:
10+
11+
self.matched_urls: list[str] = []
12+
self.url_search: str = "https://github.com/search?p=P@#&q=Cipher.getInstance&type=Code"
13+
self.token_iter: str = "P@#"
14+
self.iter_start: int = 4
15+
self.iter_end: int = 10
16+
self.token_keyword: str = None
17+
self.expressions
18+
self.pause_seconds: int = None
19+
self.random_delay: list[int] = (5, 10)
20+
21+
# "Cipher\.getInstance\(\"[A-Z]+\"\)"
22+
def add_expression(self, expression):
23+
self.expressions.add(expression)
24+
25+
def _append_matched_url(self, URL: str):
26+
self.matched_urls.append(URL)
27+
28+
def _adding_pause(self):
29+
delay = random.randint(self.random_delay[0], self.random_delay[1])
30+
time.sleep(delay)
31+
32+
def iter_url(self):
33+
# including the iter_end itself
34+
for i in range(self.iter_start, self.iter_end+1):
35+
self._adding_pause()
36+
formatted_URL: str = self.url_search.replace(
37+
self.token_iter,
38+
str(i)
39+
).replace(
40+
self.token_keyword,
41+
self.keyword)
42+
content = self._get_content_from_url(formatted_URL)
43+
if self._find_word_in_content(content, self.keyword):
44+
self._append_matched_url(formatted_URL)
45+
46+
def _get_content_from_url(self, URL: str) -> str:
47+
return None
48+
49+
def _find_expression_in_content(self, content: str):
50+
for expression in self.expressions:
51+
return re.findall(pattern, content)
52+
53+
54+
if __name__ == "__main__":
55+
pass

markdown-detail-summary/main.py

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
import argparse
2+
import re
3+
from typing import List
4+
from enum import Enum
5+
import random
6+
7+
8+
classes_used = 0
9+
10+
class LineType(Enum):
11+
TEXT = 1
12+
HEADER = 2
13+
ITEM = 3
14+
15+
all_class_names = [
16+
"dangerm",
17+
"errorm",
18+
"hintm",
19+
"tipm",
20+
"notem",
21+
"seealsom",
22+
"todom"]
23+
24+
25+
Classes = {}
26+
27+
28+
def reset_classes():
29+
global Classes
30+
global classes_used
31+
classes_used = 0
32+
for i in range(0,len(all_class_names)):
33+
Classes[i] = (all_class_names[i], False)
34+
35+
def class_supplier():
36+
global Classes
37+
global classes_used
38+
random_int = 0
39+
if classes_used == len(all_class_names)-1:
40+
reset_classes()
41+
while True:
42+
random_int = random.randint(0, len(Classes.keys())-1)
43+
if Classes[random_int][1]:
44+
continue
45+
else:
46+
Classes[random_int] = (Classes[random_int][0], True)
47+
classes_used += 1
48+
return Classes[random_int][0]
49+
50+
def read_file(file_path:str):
51+
lines = []
52+
with open(file_path) as file:
53+
lines = file.readlines()
54+
return lines
55+
56+
def find_indent_spaces(line:str):
57+
return len(line) - len(line.lstrip())
58+
59+
def line_type(line:str) ->LineType:
60+
if line.strip().startswith("#"):
61+
return LineType.HEADER
62+
if line.strip().startswith("-"):
63+
return LineType.ITEM
64+
else:
65+
return LineType.TEXT
66+
67+
def process_item(current_line: str, lines: str, current_index: int):
68+
length = len(lines)
69+
if length < 2:
70+
return current_line
71+
splitted = current_line.lstrip().split(" ", maxsplit=1)
72+
content = splitted[0].replace("-","") + " "+splitted[1]
73+
content = content.strip()
74+
next_index = current_index + 1
75+
next_line_indent_level = 0
76+
current_line_indent_level = 0
77+
if next_index < length:
78+
next_line:str = lines[next_index]
79+
current_line_indent_level = find_indent_spaces(current_line)
80+
next_line_indent_level = find_indent_spaces(next_line)
81+
if next_line_indent_level > current_line_indent_level:
82+
return "<details class = '{}'>\n<summary>".format(class_supplier())+content+"</summary>"
83+
84+
else:
85+
return content
86+
87+
def is_continuous(line: str, previous_line:str) -> bool:
88+
if len(previous_line.strip()) == 0:
89+
return False
90+
else:
91+
return True
92+
93+
94+
def process_header(line_header: str, is_this_first_header_seen: bool = False):
95+
content = line_header.replace("#", "").strip()
96+
if is_this_first_header_seen:
97+
return "\n<details class = '{}'>\n<summary>".format(class_supplier())+content+"</summary>"
98+
else:
99+
return "</details>"+\
100+
"\n<details class = '{}'>\n<summary>".format(class_supplier())+content+"</summary>"
101+
102+
103+
def process_lines(lines: List[str]):
104+
new_lines = []
105+
current_indent = 0
106+
previous_indent = 0
107+
heading_first: bool = False
108+
current_line_type: LineType = LineType.TEXT
109+
previous_line_type: LineType = LineType.TEXT
110+
current_line:str = ""
111+
is_this_first_header_seen: bool = True
112+
is_processing_item = False
113+
is_processing_header = False
114+
length = len(lines)
115+
for i in range(0, len(lines)):
116+
current_line = lines[i]
117+
if len(current_line.strip()) < 1:
118+
if is_processing_item:
119+
is_processing_item = False
120+
new_lines.append("</details>")
121+
new_lines.append(current_line)
122+
continue
123+
if line_type(current_line) == LineType.HEADER:
124+
is_processing_header = True
125+
new_lines.append(process_header(current_line, is_this_first_header_seen))
126+
is_this_first_header_seen = False
127+
elif line_type(current_line) == LineType.ITEM:
128+
new_lines.append(process_item(current_line, lines, i))
129+
is_processing_item = True
130+
else:
131+
new_lines.append(current_line.strip())
132+
new_lines.append("</details>")
133+
return new_lines
134+
135+
def write_file(lines: List[str], filename):
136+
with open(filename, "w") as file:
137+
for line in lines:
138+
file.write(line+"\n")
139+
140+
reset_classes()
141+
142+
write_file(
143+
process_lines(
144+
read_file("source.md")), "output.html")

0 commit comments

Comments
 (0)