<jupyter_start><jupyter_text>Do It Today, AKA Magic 8 Ball Reminder with Log Dead simple: Just make sure you do this once a dayNot “morning, night, recurring” - if you need that put it on a phone alarm<jupyter_code>import random
from datetime import datetime, date

import ipywidgets as widgets


def load_items(path=None):
    items = []
    fullpath = path or "DoItToday.txt"
    with open(fullpath) as source:
        items = source.read().split('\n')
        items = [i.strip() for i in items if i.strip()]
    return items    
    
def pick_item(items):
    if items:
        return random.choice(items)
    else:
        return ''

def finished_item(items, item):
    if not items or not item:
        return items
    now = datetime.utcnow()
    with open(f'DidIt{now.date().isoformat()}.txt' ,'a') as done_file:
        done_file.write(f"{now.isoformat()}\t{item}\n")
    items.remove(item) # destructive, likely should edit a modified and return that one!
    return items
# initialize today
now = datetime.utcnow()
today = now.date()
stuff = load_items()
print(f"It's a brand new day: {today.isoformat()}")
print(f"You have {len(stuff)} items to do sometime today!")
# Run Today
btn_next = widgets.Button(description='Next')
txt_item = widgets.Text()
btn_did_it = widgets.Button(description='Did It')

def click_next(b):
    item = pick_item(stuff)
    if not item:
        print("TODAY IS A DONE DAY!")
        txt_item.value = ''
    else:    
        txt_item.value = item

def click_did_it(b):
    if txt_item.value:
        finished_item(stuff, txt_item.value)
        txt_item.value = ''
    
btn_next.on_click(click_next)
btn_did_it.on_click(click_did_it)

display(btn_next,txt_item,btn_did_it)<jupyter_output><empty_output><jupyter_text>File contents example:        Brush TeethCheck EmailCheck SlackCheck DiscordCheck FacebookListen to a Pocket ArticleAffirm wifeCheck in with GodClean portion of houseText sonTake a vitamin  Consume some Scripture<jupyter_code># example/test
stuff = load_items()
while stuff:
    item = pick_item(stuff)
    print(item)
    stuff = finished_item(stuff, item)
    
with open(f'DidIt{now.date().isoformat()}.txt' ,'r') as done_file:
    print(done_file.read())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10972346119536129, 'fraction_numerical': 0.00044603033006244426, 'mean_word_length': 3.7825159914712154, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '662724', 'license': 'MIT', 'n_tokens_mistral': 759, 'n_tokens_neox': 737, 'n_words': 206, 'path': 'DoItToday.ipynb', 'repo_name': 'deangoodmanson/jupyter', 'size': '2242'}