Skip to content

Instantly share code, notes, and snippets.

View helpse's full-sized avatar

Sergio Melendez helpse

View GitHub Profile
@helpse
helpse / TreeArray.php
Last active November 17, 2015 14:13
Get a tree from an array and indicators
<?php
/**
* Author: Sergio Melendez
* www.inspiredsolutions.pe
*
* Usage:
* $data = TreeArray::factory($array, $indicators)->get();
*
* Input: [['a': 1, 'b': 2],['a': 1, 'b': 3]]
* Input: ['a']
import datetime
def prettydate(d):
diff = datetime.datetime.utcnow() - d
s = diff.seconds
if diff.days > 7 or diff.days < 0:
return d.strftime('%d %b %y')
elif diff.days == 1:
return '1 day ago'
elif diff.days > 1:
return '{} days ago'.format(diff.days)