Skip to content

Instantly share code, notes, and snippets.

@dimaqq
Created October 22, 2021 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimaqq/8c79721ae72142230d8ca750304143ae to your computer and use it in GitHub Desktop.
Save dimaqq/8c79721ae72142230d8ca750304143ae to your computer and use it in GitHub Desktop.
import time
import math
import sys
start = time.time()
total = int(sys.argv[1]) * 60
deadline = start + total
def remains():
now = time.time()
if now > deadline:
return 0
else:
return deadline - now
def format(secs):
secs = int(secs)
if not secs:
return "##:##"
minutes = secs // 60
seconds = secs % 60
return "% 2d:%02d" % (minutes, seconds)
def fun(secs):
now = time.time()
ceil = min(secs**2 / 100, (start - now)**2 / 100, 60)
extra = max(0, math.sin(secs / 14.2))**4 * ceil
return secs + extra
while True:
time.sleep(.05)
print(f"\n {format(fun(remains()))}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment