Skip to content

Instantly share code, notes, and snippets.

View eternicode's full-sized avatar

Andrew Rowls eternicode

View GitHub Profile
All modules templates I've seen were not suited for code sharing
between client/server in case the module has dependencies.
This template will only work on server-side if module's dependencies
are in node_modules (installed with npm) on server side and are
available without any path in require.
In case the dependencies are part of the application, their paths
will be different in nodejs and in browser,
so some adaptation will be required to use correct dependencies paths.
@eternicode
eternicode / gist:7478166
Last active December 28, 2015 09:19
humanized interval formatter that works with both past and future times
# Adapted from https://github.com/jtushman/human_dates
from datetime import datetime
from django.template.defaultfilters import pluralize
def prettyinterval(time=None):
"""
Take a datetime object and return a pretty string like 'in an hour',
'tomorrow', 'in 3 months', 'just now', etc
"""
@eternicode
eternicode / gist:5924803
Created July 4, 2013 03:54
Adding a custom view to the admin -- from a project written in Django 1.1.2, meaning don't use this! Please ignore the codesmells :3 Relevant docs: https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_urls
# project/app/admin/__init__.py
from admin import *