Here's my filter code
from django import template
register = template.Library()
@register.filter()
def smooth_timedelta(timedeltaobj):
"""Convert a datetime.timedelta object into Days, Hours, Minutes, Seconds."""
secs = timedeltaobj.total_seconds()
timetot = ""
if secs > 86400: # 60sec * 60min * 24hrs
days = secs // 86400
timetot += "{} days".format(int(days))
secs = secs - days*86400
if secs > 3600:
hrs = secs // 3600
timetot += " {} hours".format(int(hrs))
secs = secs - hrs*3600
if secs > 60:
mins = secs // 60
timetot += " {} minutes".format(int(mins))
secs = secs - mins*60
if secs > 0:
timetot += " {} seconds".format(int(secs))
return timetot
Then in my template I did
{% load smooth_timedelta %}
{% timedeltaobject|smooth_timedelta %}
Un container pour émuler en local l'api metadata et ainsi endosser un role
https://github.com/awslabs/amazon-ecs-local-container-endpoints
def atoi(text):
return int(text) if text.isdigit() else text
def natural_keys(text):
return [ atoi(c) for c in re.split(r'(\d+)', text) ]
my_list.sort(key=natural_keys)
Un outils pour visualiser son schema
via Flavio
Au top pour faire des petits helper en cmd line
J'utilisais https://hub.github.com/ jusqu'a present mais je vais surement changer, github cli a l'air plus intuitif et interactif
ce petit projet a l'air top mais j'ai tellement pris l'habitude d'utiliser shaarli pour stocker tout plein de choses
Ça c'est bien cool! Presque envie de prendre l'offre pro de Feedly
from distutils.util import strtobool
bool(strtobool('true'))
FOO = bool(strtobool(os.environ['FOO']))
Gérer des resources aws avec un controller kube fourni par aws
retcode = subprocess.call(['echo', 'foo'], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)