Skip to content

This repository is a collection of tools for developers to easily access relevant solutions for development in order to accelerate their workflow.

License

Notifications You must be signed in to change notification settings

Lima-e-Silva/toolboxy

Repository files navigation

toolboxy

Status Maintainability PythonVersion Version Downloads

This repository is a collection of tools for developers. The goal is to offer a variety of resources that are constantly used, in order to accelerate the workflow. It is a way to quickly and easily access relevant solutions for development.

The functionality is diverse, some examples of code use are listed below. Feel free to suggest new functionality or directly contribute to the development of this repository.

cover

Language

The repository, as well as the docstrings of the functions, were developed with support for English and Brazilian Portuguese in order to facilitate access to functionality.

Table of Contents

Installation

To install, simply open the terminal and enter the following command:

pip install toolboxy

Usage

Web Scrapping

Convert header to Python dictionary
import toolboxy

headers = """sec-ch-ua-platform: "Windows"
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: same-origin
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"""

headers_dict = toolboxy.chrome2dict(headers_str=headers)
Save source code in text file
import toolboxy

url = 'https://raw.githubusercontent.com/Lima-e-Silva/toolboxy/main/README.md'

toolboxy.html2txt(url=url, output_path='Github-toolboxy.txt')
Check if a given IP address and port can be used as a proxy
import toolboxy

# IP addresses and respective ports can be found here: "https://free-proxy-list.net"
ip = '80.252.5.34'
port = '7001'

if toolboxy.verify_proxy(ip=ip, port=port):
   print('IP and port are functional!')

Error Identification

Run a function with error logging
import toolboxy

# Function that is experiencing errors
def foo(a,b):
   return a/b

toolboxy.debug_function(foo, a=1, b=0, output='logfile')

File Manipulation

Create configuration file (cfg)
import toolboxy

config_dict = {
   'section': {
       'A': '1',
       'B': '2'
   }
}

toolboxy.create_cfg(file='config.cfg', cfg_dict=config_dict)
Read a configuration file (cfg)
import toolboxy

config_dict = toolboxy.read_cfg(file='config.cfg')
Create file backup
import toolboxy

toolboxy.backup(file='important_file.txt',
               output_path='backups/security_copies')
Verify file integrity or get hashes
import toolboxy

if toolboxy.check_hash('file.txt', 'backup.txt'):
   print('Integrity Verified')

file_hash = toolboxy.check_hash('file.txt')

Git Tools

Create a virtual environment
import toolboxy

toolboxy.create_env()
Create a license file
import toolboxy

toolboxy.license(license_type='MIT', name='Luiz Paulo Lima e Silva')
Generate a .gitignore file based on a standard template
import toolboxy

toolboxy.git_ignore(folders=['personal-folder'], extensions=['xlsx', 'pdf'])
Create requirements.txt
import toolboxy

toolboxy.requirements()

Windows Tools

Create Windows notification
import toolboxy

toolboxy.notify(
   id='toolboxy',
   title='Demonstration',
   message='This notification is merely a demonstration',
   buttons={'Open link': 'https://github.com/Lima-e-Silva/toolboxy/'},
   sound=True,
   audio_loop=False)
Schedule computer shutdown
import toolboxy

toolboxy.shutdown(time=3600, message="Time to sleep Zzz...")

Optimization

Generate function performance profile
import toolboxy

def foo(x, y=3):
   for n in range(x):
       print(n**y)

toolboxy.prof('output', foo, 100, y=2)
Calculate the elapsed time while running a function
import toolboxy

def foo(n):
   values = list()
   for i in range(n):
       for _ in range(i):
           values.append(i)
   print(values)

print(toolboxy.elapsed_clocktime(foo, 100))
Display the elapsed CPU time while running a function
import toolboxy

def foo(n):
   values = list()
   for i in range(n):
       for _ in range(i):
           values.append(i)
   print(values)

toolboxy.elapsed_cputime(foo, 100)

Miscellaneous

Displays strings in console with delay (like typing)
import toolboxy

toolboxy.delay_print('Hello World!')
Generates a docstring (according to the repository pattern) for a function
import toolboxy


def my_function():
   print("this is my function")


print(toolboxy.gpt_docstring(my_function,api_key="YOUR_API_KEY"))

# Output:
# """
# English:
# ----------
# Prints a string to the console.
#
# Returns
# -------
# None
#
# Português (brasileiro):
# ----------
# Imprime uma string no console.
#
# Retorna
# -------
# None
# """

# You can also store your api_key in a .env file then call the function without specifying the api_key.
# Example:
# toolboxy.gpt_docstring(my_function)
Generates a unique identification string
import toolboxy

id = toolboxy.unique_id(length=6,
                       letters=True,
                       numbers=True,
                       lower_case=False,
                       blocks=4)

# Example output: 0AMKPJ-LITCGF-N5A1LM-TCSHZF
Generate QR Code for a link
import toolboxy

toolboxy.QRcode(url='https://github.com/Lima-e-Silva/toolboxy/',
               size=150,
               output='My QR Code')

Free APIs

Create push notification (mobile)
import toolboxy

TOPIC = 'notifications'  # More information here: https://ntfy.sh

toolboxy.smartphone_notify(topic=TOPIC,
                          message='This is a demonstration notification',
                          title='Test Notification')
Shorten URL
import toolboxy

url = 'https://www.google.com.br'

if short:= toolboxy.short_url(url):
   print(short)

# Example Output: https://gotiny.cc/xr4cs6

Credits

Due to the nature of the repository, many of the implemented functions are full of dependencies. Therefore, it is essential to explicitly acknowledge the contribution of the community as a way of thanking them for the tools provided. Below is a list of the libraries and resources used and their respective licenses:

Library License
BeautifulSoup MIT
loguru MIT
openai MIT
ntfy Apache 2.0 - GPL 2.0
pipreqs Apache 2.0
pyperclip BSD-3-Clause
python-dotenv BSD-3-Clause
requests Apache 2.0
setuptools MIT
snakeviz License
winotify MIT

About

This repository is a collection of tools for developers to easily access relevant solutions for development in order to accelerate their workflow.

Topics

Resources

License

Stars

Watchers

Forks

Languages