Skip to content

Instantly share code, notes, and snippets.

@thevickypedia
thevickypedia / help_jarvis.py
Created November 13, 2020 23:18
Face recognition script that can run in the background
import os
from threading import Thread
import cv2
import face_recognition
class Face(Thread):
def __init__(self):
super(Face, self).__init__()
from phonenumbers import geocoder, carrier, parse, timezone, is_valid_number, is_possible_number
phone = parse('target number goes here')
if is_valid_number(phone) and is_possible_number(phone):
state = geocoder.description_for_number(phone, 'en')
t_zone = timezone.time_zones_for_number(phone)[0]
car = carrier.name_for_number(phone, 'en')
print(f'The phone number with {phone} using the Carrier {car} is located in {state} and is currently in the timezone {t_zone}.')
@thevickypedia
thevickypedia / keep_it_busy.ps1
Last active July 23, 2021 03:17
Keep it busy for Windows OS
cls
$currentTime = Get-Date -format "MMM, dd yyyy hh:mm:ss tt"
echo "StartTime: $currentTime`n`n"
echo "I will keep the system busy! Go do your thing!`n`t- Vignesh Rao`n`n"
echo "Questions?`n"
echo "https://vigneshrao.com/contact"
@thevickypedia
thevickypedia / phraser.py
Created August 17, 2021 04:25
Generate alpha numeric phrase for a defined length
from random import choices
from string import ascii_letters, digits
def alpha_numeric(length: int = 20) -> str:
"""Generates alpha numeric phrase.
Args:
length: Length of the phrase that should be generated.
@thevickypedia
thevickypedia / sphinx-pydantic.md
Last active December 4, 2021 17:35
Configure sphinx docs when using Pydantic

Sphinx Auto-docs and Pydantic Configuration

Sphinx autogen docs and pydantic don't get along.

Problem:

  • Using the BaseModel from pydantic takes the class members as arguments.
    • These arguments are displayed (along with the values) in the docs whether the user wants it or not.
@thevickypedia
thevickypedia / text.py
Last active February 9, 2022 00:26
Format text in python's print statements
class Format:
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
ITALIC = '\x1B[3m'
class Colors:
VIOLET = '\033[95m'
BLUE = '\033[94m'
CYAN = '\033[96m'
@thevickypedia
thevickypedia / display.py
Created April 23, 2022 13:23
Custom display
import inspect
import os
from datetime import datetime
from typing import Any
class Format:
"""Initiates Format object to define variables that print the message in a certain format.
>>> Format
@thevickypedia
thevickypedia / timeout_handler.py
Created May 26, 2022 14:28
Timeout handler using threading and wrapper
import functools
import time
from threading import Thread
from typing import Union, Callable, NoReturn
def timeout(duration: Union[float, int]) -> Callable:
"""Timeout handler for Windows OS.
Args:
@thevickypedia
thevickypedia / timeout_handler.py
Last active May 26, 2022 14:28
Handle timeout using multiprocessing
import multiprocessing
import time
from typing import Callable, Union
class TimeoutHandler:
"""Initiates TimeoutHandler object to run a function and terminate it after a given time limit.
>>> TimeoutHandler
@thevickypedia
thevickypedia / timeout_handler.py
Last active May 26, 2022 14:29
Handle timeout using context manager and singal (Linux and Darwin)
import signal
import time
from contextlib import contextmanager
from types import FrameType
from typing import Union, NoReturn
@contextmanager
def timeout(duration: Union[int, float]) -> NoReturn:
"""Creates a timeout handler.