Skip to content

Instantly share code, notes, and snippets.

@mazelife
Created May 29, 2015 17:17
Show Gist options
  • Save mazelife/76c185d0d61239bf6d9a to your computer and use it in GitHub Desktop.
Save mazelife/76c185d0d61239bf6d9a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Crontab setting to bother you during wokring hours on weekdays
# 0 9,10,11,12,13,14,15,16 * * 1,2,3,4,5 /usr/local/bin/exercise_helper.py
from random import choice, randrange
from datetime import date
from math import ceil
import tkMessageBox
EXERCISES = (
("mountain climbers", 10, 20, 1),
("burpees", 10, 20, 1),
("situps", 15, 30, 1),
("pushups", 7, 12, 0.5),
)
START_DATE = date(2015, 5, 29)
def get_increment(x, extra):
return int(ceil(0.02 * pow(x, 2) * extra))
name, mn, mx, extra_multiplier = choice(EXERCISES)
days_out = max((date.today() - START_DATE).days, 1)
inc = get_increment(days_out, extra_multiplier)
count = randrange(mn + inc, mx + inc)
title = "It's day {}!".format(days_out)
message = "Here's your exercise to do: {}. Do {} of them.".format(name, count)
tkMessageBox.showinfo(title, message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment