Skip to content

Instantly share code, notes, and snippets.

@IvansNab
IvansNab / password_manager.py
Last active August 22, 2021 11:03
Password Manager, Generator, tkinter python 3
from tkinter import *
from tkinter import messagebox
from string import ascii_letters, digits
from random import choices, shuffle
import pyperclip
import json
symbols = '!#$%&()*+'
@IvansNab
IvansNab / pomodoro.py
Last active August 21, 2021 14:00
Pomodoro Technique, tkinter python 3
from tkinter import *
from tkinter import messagebox
import winsound
# ---------------------------- CONSTANTS ------------------------------- #
# www.colorhunt.io
PINK, RED, GREEN, YELLOW = "#e2979c", "#e7305b", "#9bdeac", "#f7f5dd"
FONT_NAME = "Courier"
# ---------------------------- VARIABLES ------------------------------- #
reps, work_time, timer = 0, 0, 0
work_min, short_break_min, long_break_min = 25, 5, 20
@IvansNab
IvansNab / prettifiedStopwatch.py
Last active March 24, 2021 13:06
Prettified Stopwatch automate boring stuff
#! python3
'''
Prettified Stopwatch
Expand the stopwatch project from this chapter so that it uses the rjust()
and ljust() string methods to “prettify” the output. (These methods were
covered in Chapter 6.) Instead of output such as this:
Lap #1: 3.56 (3.56)
Lap #2: 8.63 (5.07)
Lap #3: 17.68 (9.05)
Lap #4: 19.11 (1.43)
@IvansNab
IvansNab / excel-to-csvConverter.py
Created March 20, 2021 18:09
Excel to CSV Converter automate boring stuff
'''
Usage: excel-to-csvConverter.py folderPath or via input()
Excel-to-CSV Converter
Excel can save a spreadsheet to a CSV file with a few mouse clicks, but if
you had to convert hundreds of Excel files to CSVs, it would take hours of
clicking. Using the openpyxl module from Chapter 12, write a program that
reads all the Excel files in the current working directory and outputs them
as CSV files.
A single Excel file might contain multiple sheets; you’ll have to
create one CSV file per sheet. The filenames of the CSV files should be
@IvansNab
IvansNab / brute-forcePdfPasswordBreaker.py
Last active March 19, 2021 16:31
Brute-Force PDF Password Breaker automate boring stuff
'''
Brute-Force PDF Password Breaker
Say you have an encrypted PDF that you have forgotten the password to,
but you remember it was a single English word. Trying to guess your forgot-
ten password is quite a boring task. Instead you can write a program that
will decrypt the PDF by trying every possible English word until it finds one
that works. This is called a brute-force password attack. Download the text file
dictionary.txt from https://nostarch.com/automatestuff2/. This dictionary file
contains over 44,000 English words with one word per line.
Using the file-reading skills you learned in Chapter 9, create a list of
@IvansNab
IvansNab / customInvitationsAsWordDocuments.py
Created March 18, 2021 15:00
custom invitations as word documents automate boring stuff
'''
Custom Invitations as Word Documents
Say you have a text file of guest names. This guests.txt file has one name per
line, as follows:
Prof. Plum
Miss Scarlet
Col. Mustard
Al Sweigart
RoboCop
Write a program that would generate a Word document with custom
@IvansNab
IvansNab / pdfParanoia.py
Last active March 18, 2021 10:41
pdf paranoia automate boring stuff
'''
PDF Paranoia
Using the os.walk() function from Chapter 10, write a script that will go
through every PDF in a folder (and its subfolders) and encrypt the PDFs
using a password provided on the command line. Save each encrypted PDF
with an _encrypted.pdf suffix added to the original filename. Before deleting
the original file, have the program attempt to read and decrypt the file to
ensure that it was encrypted correctly.
Then, write a program that finds all encrypted PDFs in a folder (and its
subfolders) and creates a decrypted copy of the PDF using a provided pass-
@IvansNab
IvansNab / findingMistakesInASpreadsheet.py
Last active March 16, 2021 20:17
automate the boring stuff
'''
After a long day at the bean-counting office, I’ve finished a spreadsheet
with all the bean totals and uploaded them to Google Sheets. The spread-
sheet is publicly viewable (but not editable). You can get this spreadsheet
with the following code:
>>> import ezsheets
>>> ss = ezsheets.Spreadsheet('1jDZEdvSIh4TmZxccyy0ZXrH-ELlrwq8_YYiZrEOB4jg')
You can look at this spreadsheet in your browser by going to https://docs
.google.com/spreadsheets/d/1jDZEdvSIh4TmZxccyy0ZXrH-ELlrwq8_YYiZrEOB4jg
/edit?usp=sharing/. The columns of the first sheet in this spreadsheet are
@IvansNab
IvansNab / spreadsheetToTextFiles.py
Last active March 16, 2021 13:54
spreadsheet to text files automate the boring stuff
'''
Spreadsheet to Text Files
Write a program that performs the tasks of the previous program in reverse
order: the program should open a spreadsheet and write the cells of column
A into one text file, the cells of column B into another text file, and so on.
'''
import os
import re
import openpyxl
from openpyxl.utils import get_column_letter as GCL
@IvansNab
IvansNab / textFilesToSpreadsheet.py
Last active March 14, 2021 19:39
text files to spreadsheet automate the boring stuff
'''
Text Files to Spreadsheet
Write a program to read in the contents of several text files (you can make
the text files yourself) and insert those contents into a spreadsheet, with
one line of text per row. The lines of the first text file will be in the cells of
column A, the lines of the second text file will be in the cells of column B,
and so on.
Use the readlines() File object method to return a list of strings, one
string per line in the file. For the first file, output the first line to column 1,
row 1. The second line should be written to column 1, row 2, and so on. The