Skip to content

Instantly share code, notes, and snippets.

View philgyford's full-sized avatar

Phil Gyford philgyford

View GitHub Profile
@adactio
adactio / updateDateTimes.js
Last active September 11, 2023 05:10
Periodically update the text of `datetime` elements with the relative time elapsed.
(function (win, doc) {
'use strict';
if (!doc.querySelectorAll || !win.Intl || !win.Intl.RelativeTimeFormat) {
// doesn't cut the mustard.
return;
}
var rtf = new Intl.RelativeTimeFormat('en', {
localeMatcher: 'best fit',
numeric: 'always',
style: 'long'
@dpnova
dpnova / gist:1223933
Created September 17, 2011 13:26
invalidate cache_page entries in django
def expire_view_cache(view_name, args=[], namespace=None, key_prefix=None, method="GET"):
"""
This function allows you to invalidate any view-level cache.
view_name: view function you wish to invalidate or it's named url pattern
args: any arguments passed to the view function
namepace: optioal, if an application namespace is needed
key prefix: for the @cache_page decorator for the function (if any)
from: http://stackoverflow.com/questions/2268417/expire-a-view-cache-in-django
added: method to request to get the key generating properly