Skip to content

Instantly share code, notes, and snippets.

@jedberg
Last active August 10, 2020 23:50
Show Gist options
  • Save jedberg/143c12c79c7cba916a53f4f26ba1c11d to your computer and use it in GitHub Desktop.
Save jedberg/143c12c79c7cba916a53f4f26ba1c11d to your computer and use it in GitHub Desktop.
Some utilities that are handy
# Convert fahrenheit to celcius
def f2c(temp):
c = ((temp-32)/9)*5
return round(c, 2)
# Check if a file is older than some number of seconds.
import time, os, stat
def file_too_old(pathname, seconds=600):
try:
os.stat(pathname)
except FileNotFoundError:
return True
if (time.time() - os.stat(pathname)[stat.ST_MTIME]) > seconds:
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment