Skip to content

Instantly share code, notes, and snippets.

@AO8
AO8 / month_analyzer3.py
Last active September 26, 2018 17:11
Another approach to an ongoing Python project: reading CSV exported from Calendly to analyze what months students book an advising appointment. Key modules used in this approach include OrderedDict, datetime, and matplotlib.
import csv
from datetime import datetime
from collections import OrderedDict
import matplotlib.pyplot as plt
# set up empty containers
total = 0
months = dict()
# open and read CSV
@AO8
AO8 / cohort_analyzer.py
Last active October 9, 2018 19:58
Using Python to analyze the makeup of a given BAS-SD cohort.
import csv
from statistics import mean
# set up empty dict containers
associate_type = dict() # row 6
associate_from = dict() # row 7
maths = dict() # row 14
advisors = dict() # row 15
# set up empty list containers
@AO8
AO8 / record_video.py
Created September 17, 2018 00:21
Simple Python recipe for recording video with timestamp using PiCamera + Raspberry Pi.
from picamera import PiCamera, Color
from time import sleep
from datetime import datetime as dt
with PiCamera() as camera:
camera.rotation = 180 # omit or use 90, 180, 270 depending on setup
camera.annotate_background = Color("black")
start = dt.now()
camera.start_preview()
@AO8
AO8 / simple_send_photo.py
Last active September 17, 2018 00:08
Simple Python script to attach & email images, handy for sending photos taken with a PiCamera / Raspberry Pi.
# enable less secure apps in gmail before sending
import os
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
# gather inputs
from_addr = input("FROM ADDRESS: ")
pwd = input("PASSWORD: ")
@AO8
AO8 / bas_sd_scraper.py
Last active October 26, 2020 20:14
Python webscraper + email report creator. Uses BeautifulSoup and pyautogui to scrape Green River's online class finder for BAS software development and programming prereq enrollments, then sends email report to stakeholders.
# Python Standard Library
import smtplib
import ssl
import webbrowser
from datetime import datetime as dt
from email.mime.text import MIMEText
from time import sleep
from urllib.request import urlopen
# Third-party
@AO8
AO8 / continuous_stoic_meditation.py
Last active August 2, 2018 19:56
Continuously email a random Stoic meditation from Marcus Aurelius: a simple exercise in file reading, timedeltas, and sending gmail with Python.
# Builds on the random daily Stoic meditation gist at:
# https://gist.github.com/AO8/a33b0e70a1885679279f0533d4f5d8dc
# Enable less secure apps in gmail before running
import random
import smtplib
from email.mime.text import MIMEText
from datetime import datetime, timedelta
from time import sleep
@AO8
AO8 / email_stoic_meditation.py
Last active July 31, 2018 21:21
Randomly select and email a daily Stoic meditation from Marcus Aurelius: a simple exercise in file reading and sending gmail with Python.
# Builds on the random daily Stoic meditation gist at:
# https://gist.github.com/AO8/a33b0e70a1885679279f0533d4f5d8dc
# Enable less secure apps in gmail before attempting to send
import random
import smtplib
from email.mime.text import MIMEText
from datetime import datetime
random.seed(datetime.now())
@AO8
AO8 / month_analyzer2.py
Last active September 25, 2018 20:42
Read CSV exported from Calendly to analyze what months students book an advising appointment. More concise version using dict as central data structure.
import csv
import matplotlib.pyplot as plt
months = {
"january" : 0,
"february" : 0,
"march" : 0,
"april" : 0,
"may" : 0,
"june" : 0,
@AO8
AO8 / lead_analyzer2.py
Last active December 3, 2019 19:54
Read CSV exported from Calendly to create a bar chart with matplotlib depicting how students heard about program when booking an appointment. This version is more concise using the Counter class as central data structure.
import csv
from collections import Counter
import matplotlib.pyplot as plt
# set up empty containers
leads = Counter()
email_addresses = set()
total_rows = 0 # storing total rows in csv if useful outside of plot
# ignores 'Other' entries; 'Other' since removed from appt booking question
@AO8
AO8 / daily_stoic_meditation.py
Last active January 3, 2025 16:17
Randomly select a daily Stoic meditation from Marcus Aurelius: a simple exercise in file reading with Python.
# Inspired from a recent re-reading of Meditations by Marcus Aurelius, translation by Gregory Hays.
import random
import textwrap
with open("meditations.txt", "r") as f:
contents = f.readlines()
def ask_stoic():
prompt = input("Would you like a stoic meditation? y or n ")