Skip to content

Instantly share code, notes, and snippets.

View Madrox's full-sized avatar

David Horn Madrox

View GitHub Profile
"""
# cloud_task_delete_old_appengine_versions.py
This is a python file designed to operate as a Cloud Function.
On trigger, it will delete all but the number of non-active
versions equal to `RETAIN_LAST_N_VERSIONS` below (default 5).
Note: failure to delete will not raise an exception. If you're
running into bugs, see the commented line below to help debug
if the delete call is throwing errors
@fabiosussetto
fabiosussetto / gist:c534d84cbbf7ab60b025
Last active December 2, 2023 01:11
Enable Django toolbar for JSON responses
class NonHtmlDebugToolbarMiddleware(object):
"""
The Django Debug Toolbar usually only works for views that return HTML.
This middleware wraps any JSON response in HTML if the request
has a 'debug' query parameter (e.g. http://localhost/foo?debug)
"""
@staticmethod
def process_response(request, response):
if request.GET.get('debug'):