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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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: "))
# 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): '))
# 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()
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
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)
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 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:])
from PIL import Image
import os
import argparsedef rescale_images(directory, size):
for img in os.listdir(directory):
im = Image.open(directory+img)
im_resized = im.resize(size, Image.ANTIALIAS)
im_resized.save(directory+img)if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Rescale images")
parser.add_argument('-d', '--directory', type=str, required=True, help='Directory containing the images')
parser.add_argument('-s', '--size', type=int, nargs=2, required=True, metavar=('width', 'height'), help='Image size')
from tkinter import *
class Calculator():
def __init__(self, master=None, **kwargs):
master.title('CALCULATOR')
master.geometry('339x400')
display = StringVar()
view = Entry(self,highlightthickness= 0, relief=SUNKEN, textvariable=display, border=0, font=('Calibri', 24))
view.bind('<Return>', lambda e, s=self, w=display: s.calc(w))
view.place(x=0, y=6, width=254, height=36)
view.focus_set()