Skip to content

Instantly share code, notes, and snippets.

View israel-dryer's full-sized avatar

Israel Dryer israel-dryer

View GitHub Profile
@israel-dryer
israel-dryer / tearoff.py
Created April 8, 2021 01:42
tkinter startup tearoff menu
import tkinter
def tearoff_callback(menu, tearoff):
"""Move the tearoff menu after tearoff"""
root.update()
x = root.winfo_x() - 75
y = root.winfo_y()
root.tk.call('wm', 'geometry', tearoff, f'+{x}+{y}')
root = tkinter.Tk()
@israel-dryer
israel-dryer / fading_window.py
Created March 29, 2021 19:55
A tkinter window that fades in and out at specified intervals
"""
Window that fades in an out at a specified time interval and increment
Author: Israel Dryer
Modified: March 29, 2021
"""
from tkinter import ttk
import tkinter
@israel-dryer
israel-dryer / full_module_class_instantiation.py
Created February 25, 2021 05:05
Instantiate all the classes in a target module without explicitly naming them
import sys
from datetime import datetime
class GoogleNewsScraper():
def __init__(self):
self.date_modified = datetime.today()
def scrape(self):
@israel-dryer
israel-dryer / yt_question_find_and_break.py
Created December 28, 2020 17:50
example of find a word in a subject line then performing action; then stopping.
search_term = "product"
for message in inbox.Items:
if search_term in message.Subject:
do_something()
break # this will break out of the loop once the item is found
@israel-dryer
israel-dryer / gist:350fe21e49bc9445f5b6827a668f247e
Created November 20, 2020 14:17
Example - Saving data to CSV
import csv
import requests
from bs4 import BeautifulSoup
stock = ['AMZN','AXP','AAPL','AXTA','BAC']
# create csv writer
f = open("data_file.csv", "w", newline="", encoding="utf-8")
writer = csv.writer(f)
# add header to csv file
@israel-dryer
israel-dryer / wiki_homepage.txt
Created September 30, 2020 22:22
Wiki homepage example
Welcome to a series of tutorials on how to get the most out of Microsoft Outlook using python!
<table>
<tr>
<td>
<ul><b>
<li><a href="https://github.com/israel-dryer/Outlook-Python-Tutorial/wiki">Home</a></li>
<li><a href="https://github.com/israel-dryer/Outlook-Python-Tutorial/wiki/Getting-started">Getting started</a></li>
<li><a href="https://github.com/israel-dryer/Outlook-Python-Tutorial/wiki/Plain-text-email">Plain text email</a></li>
<li><a href="https://github.com/israel-dryer/Outlook-Python-Tutorial/wiki/HTML-formatted-email">HMTL formatted email</a></li>
@israel-dryer
israel-dryer / add_dl_members.py
Created September 22, 2020 01:35
Add members to an Outlook distribution
"""
Add members to an existing user distribution list in Python
https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.recipients
https://docs.microsoft.com/en-us/office/vba/api/outlook.distlistitem.addmembers
https://docs.microsoft.com/en-us/office/vba/api/outlook.oldefaultfolders
"""
import win32com.client as client
# start an instance of outlook
@israel-dryer
israel-dryer / message_finder.py
Created September 19, 2020 02:08
Identify undeliverable messages in Outlook
import re
import win32com.client as client
# pattern for identifying email addresses
pattern = re.compile(r'mailto:(\w+\.\[email protected])')
outlook = client.Dispatch('Outlook.Application')
namespace = outlook.GetNameSpace('MAPI')
inbox = namespace.Folders['Inbox']
@israel-dryer
israel-dryer / py_list_to_html_list.py
Created September 16, 2020 14:50
Insert python list into html formatted email template
"""
Create a html formatted list from a python list
"""
# email template with curly braces to insert list
email_template = '''
<p>Hello, here are the items that you ordered:<br>
{}
</p>
'''
@israel-dryer
israel-dryer / gist:bc92cd8bd960492f2cbce617db68cf5e
Created September 7, 2020 15:10
Find Excel table range with win32com

Find Excel Range in Workbook

import win32com.client as client
import pathlib

Initialize the application