Skip to content

Instantly share code, notes, and snippets.

View go4Mor4's full-sized avatar
💡
Focusing

Gabriel Mora go4Mor4

💡
Focusing
  • Getnet Brasil
  • Sao Paulo, Brazil
View GitHub Profile
def generate_pdf(PATH, nome_pdf):
images, list_images = [name for name in os.listdir(PATH) if name.endswith('.png')], []
for i in images:
image = Image.open(PATH+i)
list_images.append(image)
list_images[0].save(rf'{PATH}{nome_pdf}', save_all=True, append_images=list_images[1:])
def pdf_to_images(PATH_PDF, DIR_OUTPUT):
images, count = convert_from_path(PATH_PDF, poppler_path= r'C:\Program Files (x86)\poppler-0.68.0\bin'), 1
for image in images:
image.save(rf'{DIR_OUTPUT}teste ({count}).png', 'PNG')
count += 1
def resize_images(PATH, size):
images = [name for name in os.listdir(PATH) if os.path.isfile(os.path.join(PATH, name))]
for i in images:
image = Image.open(PATH+i)
image.thumbnail((size, size))
image.save(PATH+i)
pytest --showlocals # show local variables in tracebacks
pytest -l # show local variables (shortcut)
pytest --tb=auto # (default) 'long' tracebacks for the first and last
# entry, but 'short' style for the other entries
pytest --tb=long # exhaustive, informative traceback formatting
pytest --tb=short # shorter traceback format
pytest --tb=line # only one line per failure
pytest --tb=native # Python standard library formatting
pytest --tb=no # no traceback at all
# This is how you use requests:
import requests
userdata = {"firstname": "Homer", "lastname": "Simpson", "password": "beer123"}
resp = requests.post('http://www.springfield.com/user', data=userdata)
resp.json()
# Ex 1:
from math import ceil
__table = [['5-9', 125], ['9.1-16', 250], ['16.1-24', 375], ['24.1-30', 500]]
def get_idade_peso():
try:
idade = int(input('Digite a sua idade: '))
peso = float(input('Digite o seu peso (em kg): '))
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.implicitly_wait(15)
driver.get('https://web.whatsapp.com')
driver.find_element_by_css_selector("span[title='" + input("Enter name to spam: ") + "']").click()
inputString = input("Enter message to send: ")
qnt_messages = int(input("Enter number of messages: "))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.