Word of the Week is designed to enrich vocabulary through weekly engagement. A Python script selects an esoteric word from a CSV file. This word, along with its definition and a contextual example sentence, is then emailed to a list of recipients. GitHub Actions automates the delivery process, ensuring the email arrives reliably at a predetermined time each week.
📩 Subscribe to recieve a word of the week.
👨🏻💻 For the story behind the project, read the blog post.
📚 See a selection of the books that have contributed to Word of the Week.
Activate the virtual environment:
source wow_venv/bin/activate
-
Copy new words from 'new_vocab.txt' to 'new_words_list.csv'. Note: Keep the column headers in the csv file.
-
Run
new_words_list.py
to populate the csv with word types, definitions, and example sentences. -
Check the csv file for any errors.
-
Manually copy & paste from 'new_words_list.csv' to 'words_for_email.csv'.
-
To sort 'words_for_email.csv' in Excel: Select all -> Sort & Filter -> Custom Sort -> Sort by 'word' -> A to Z. Note: Be sure to check My data has headers. This ensures that Excel recognizes the first row as headers and excludes it from the sort.
To send an email to just one person, run wow_dev.py
. This requires the python-dotenv
package to access the environment variables in the .env
file. This is not required for the GitHub Actions workflow as that uses GitHub Secrets.
Note: If you have a .env file in your project directory and the Python extension installed, VS Code automatically loads these variables into terminals it opens. This is not the case in terminals outside of VS Code. (Is this true? 🤔 I can run the scripts in Ubuntu 🐧.) 🧐
-
Make sure the workflow YAML file includes the 'workflow_dispatch' trigger.
-
Under the 'Actions' tab, select the Workflow in the left sidebar.
-
Click the 'Run workflow' button on the right side of the workflow page.
-
Start the Workflow: Click 'Run workflow' again in the dropdown menu that appears.
duplicates.py
will check for duplicates.
Check for duplicates in 'words_for_email.csv' by running duplicates.py
.
Create the alphabetized 'Word_List' XL Worksheet by running alphabetize.py
. This creates a new file every time it is run. Note the encoding; some entries have been removed if they have accents (e.g, éclat).
Get the latest word count by running duplicates.py
.
- Word count for 19/09/24: 560
- Word count for 10/07/24: 559
- Word count for 06/05/24: 556
- Word count for 23/04/24: 537
- Word count for 22/04/24: 532
On changing my Gmail password, the Python script was no longer able to send emails. The error message was:
Failed to send email: (535, b'5.7.8 Username and Password not accepted. …')
Google does not allow you to log in via smtplib because it has flagged this as "Less secure app access". To resolve this, you need to generate an app password.
-
Log into your Google account and go to the following link: https://myaccount.google.com/apppasswords
-
Create a new app password. Type a name for the password and click 'Create'. This will generate a 16-character password.
-
The app password for this project is wow.
-
In the
.env
file, use the new app password as GMAIL_PASSWORD. -
For prod, add the app password to GitHub Secrets without the quotes.
If ufw is active, you need to allow connections on the ports used by VS Code. By default, VS Code uses port 22 for SSH and some random ports for its server. Here are the steps to allow those ports:
- Allow SSH:
sudo ufw allow 22/tcp
- Allow High-Numbered Port Range (to cover dynamically assigned ports):
sudo ufw allow 30000:65535/tcp
Remote - WSL typically uses dynamically assigned ports. However, you can check the VS Code Remote Server Logs to identify and allow only the required ports:
- Open the Command Palette (Ctrl+Shift+P).
- Type and select
Remote-WSL: Show Log
. - Look for the line that says "Remote server listening on" followed by a port number. This is the port used by the VS Code server.
- You can also find this under
View -> Output -> Ports
.
# Allow Specific Ports:
sudo ufw allow 60713/tcp # The VS Code Server is bound to port 60713
sudo ufw allow 49893/tcp # The local proxy server is running on port 49893
# Allow Localhost Connections (optional but useful for internal traffic):
sudo ufw allow from 127.0.0.1
# Reload UFW:
sudo ufw reload
# Verify UFW Rules:
sudo ufw status numbered
# Re-enable ufw if it was disabled
sudo ufw enable
ctrl + enter
to get Copilot suggestions.
🌐 followCrom: followcrom.online 🌐
📫 followCrom: get in touch 📫
👷 Feel free to open a pull request or branch from this project. 👷
This project is open source and available under the MIT License.