Skip to content

Instantly share code, notes, and snippets.

View Tuhin-thinks's full-sized avatar
🏅
Learning

Tuhin Mitra Tuhin-thinks

🏅
Learning
View GitHub Profile
import time
from typing import Dict
import pyautogui as pag
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
def fill_form_tab_seq(form_data: Dict):
@Tuhin-thinks
Tuhin-thinks / expand_linked_urls.py
Created September 28, 2023 14:27
To expand any linkedin encded url to actual URL and save them as CSV file.
import csv
from typing import Dict, List
import re
import requests
from requests.exceptions import RequestException
def expand_url(url):
try:
@Tuhin-thinks
Tuhin-thinks / save_files_from_server.py
Created June 10, 2023 06:45
Utility Python script to save files from server selectively.
import os
from pathlib import Path
from urllib.parse import urlparse
from bs4 import BeautifulSoup
import requests
SAVE_DIR = Path(os.path.dirname(os.path.abspath(__file__))) / 'save'
TO_SAVE_DIR = ['Movies', 'TV Shows', 'Music', 'Books', 'Games', 'Software', 'Pictures']
@Tuhin-thinks
Tuhin-thinks / winnin_lottery_number.py
Last active June 4, 2023 08:48
Problem statement: Next week's winning lottery numbers are 8 different numbers all in the range 11 to 99 inclusiveThree, and only three of them are prime numbers and the sum of these three is 265Of the other 5, just two of them are even, and when these 2 are multiplied together they make 1332The mean of the remaining 3 is 23What are the eight wi…
"""
Problem statement: Next week's winning lottery numbers are 8 different numbers all in the range 11 to 99 inclusive
Three, and only three of them are prime numbers and the sum of these three is 265
Of the other 5, just two of them are even, and when these 2 are multiplied together they make 1332
The mean of the remaining 3 is 23
What are the eight winning lottery numbers?
"""
# (x + y + z) == 265 and all((is_prime(num) for num in (x, y, z)))
# all((is_even(num) for num in (p, q))) and p * q == 1332
from typing import Literal, List, Any, Union
from browser import document, prompt, html, window
def print_formatted(_header: List[str], _items: List[List[Union[str, Any]]],
padding=10, alignment="^"):
"""
Function to print header along with list of list in tabular format.
:param alignment: ^ -center alignment;
< -left alignment;
@Tuhin-thinks
Tuhin-thinks / unscramble.py
Created May 25, 2023 16:17
"XSmPyeyHlTFjlvoIM.ZCuTlvrLkyVYjdJBqtdM SozWLxOrayj" The unscrambling process is as follows. 1. Set an index x to 0 2. Get the character at position x 3. If the character is a full stop, print your result string (omitting the first character) and stop 4. if not a full stop, add that character to your result string 5. Get the low order 4 bits of …
string = "XSmPyeyHlTFjlvoIM.ZCuTlvrLkyVYjdJBqtdM SozWLxOrayj"
# unscrambling start
x = 0
result = ""
while True:
ch = string[x]
if ch == '.':
print(result[1:]) # print the result string omitting the first character
break
@Tuhin-thinks
Tuhin-thinks / matrix_with_angle_utils.py
Last active November 24, 2022 18:33
A utility for matrix operation
import pprint
from math import radians, sin, cos
import numpy as np
class Angle:
"""
class for interconversion of angle in degrees and radians
"""
@Tuhin-thinks
Tuhin-thinks / Time__Profiler.py
Created January 2, 2022 14:51
Profile code execution time
import time
import typing
def profiler(fn: typing.Callable):
"""to be used as a function decorator for monitoring execution time of a function"""
def inner():
start_time = time.perf_counter_ns()
fn()
elapsed = time.perf_counter_ns() - start_time
@Tuhin-thinks
Tuhin-thinks / bubble_notification.py
Created December 29, 2021 19:10
PyQt5 bubble notification, original code from https://stackoverflow.com/a/59327658/8201723 (adapted for latest PyQt5 version)
import sys
from PyQt5.QtCore import (QRectF, Qt, QPropertyAnimation, pyqtProperty,
QPoint, QParallelAnimationGroup, QEasingCurve)
from PyQt5.QtGui import QPainter, QPainterPath, QColor, QPen
from PyQt5.QtWidgets import (QLabel, QWidget, QVBoxLayout, QApplication,
QLineEdit, QPushButton)
class BubbleLabel(QWidget):
@Tuhin-thinks
Tuhin-thinks / WindowNotification.py
Created December 29, 2021 18:54
Code to show windows notification/desktop notification in PyQt5
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
class QToaster(QtWidgets.QFrame):
closed = QtCore.pyqtSignal()
def __init__(self, *args, **kwargs):
super(QToaster, self).__init__(*args, **kwargs)
QtWidgets.QHBoxLayout(self)