Skip to content

Instantly share code, notes, and snippets.

@simonw
simonw / example_output.json
Created August 3, 2017 23:43
Python function for retrieving all git commits (from "git log" in the current directory) as a useful data structure
[
{
"date": "Mon Jan 23 13:03:00 2017 -0800",
"message": "Recommended by Django https://docs.djangoproject.com/en/1.10/ref/databases/#setting-sql-mode",
"title": "SET sql_mode='STRICT_TRANS_TABLES';",
"hash": "a395f401c9a6d3e8602b80ecc729d736da871f46",
"author": "Simon Willison <simonw@example.com>"
},
{
"date": "Mon Jan 23 11:37:38 2017 -0800",
@shangxiao
shangxiao / authenticated_or_404.py
Created May 14, 2016 13:20
Django view decorator for returning 404 if not authenticated
from functools import update_wrapper
from django.http import Http404
class authenticated_or_404(object):
def __init__(self, func):
self.func = func
update_wrapper(self, func)