This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| <!DOCTYPE html> | |
| <meta charset="utf-8"> | |
| <style> | |
| body { | |
| font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | |
| width: 960px; | |
| height: 500px; | |
| position: relative; | |
| } |
| """Add user created_by and modified_by foreign key refs to any model automatically. | |
| Almost entirely taken from https://github.com/Atomidata/django-audit-log/blob/master/audit_log/middleware.py""" | |
| from django.db.models import signals | |
| from django.utils.functional import curry | |
| class WhodidMiddleware(object): | |
| def process_request(self, request): | |
| if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'): | |
| if hasattr(request, 'user') and request.user.is_authenticated(): | |
| user = request.user |
| /** | |
| * How to force HTML background to bottom when page is smaller than window (SO) | |
| * http://stackoverflow.com/questions/12444774/how-to-force-html-background-to-bottom-when-page-is-smaller-than-window | |
| */ | |
| html, body { | |
| height: 100%; | |
| /* The html and body elements cannot have any padding or margin. */ | |
| background: url(http://upload.wikimedia.org/wikipedia/commons/2/22/Turkish_Van_Cat.jpg) no-repeat center center fixed; | |
| -webkit-background-size: cover; | |
| -moz-background-size: cover; |
| def namedlist(typename, field_names): | |
| """Returns a new subclass of list with named fields. | |
| >>> Point = namedlist('Point', ('x', 'y')) | |
| >>> Point.__doc__ # docstring for the new class | |
| 'Point(x, y)' | |
| >>> p = Point(11, y=22) # instantiate with positional args or keywords | |
| >>> p[0] + p[1] # indexable like a plain list | |
| 33 | |
| >>> x, y = p # unpack like a regular list |
| # Copyright 2012 Twitter | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer