Skip to content

Instantly share code, notes, and snippets.

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
@motiteux
motiteux / dabblet.css
Created March 9, 2014 16:50
How to force HTML background to bottom when page is smaller than window (SO)
/**
* 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;
"""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
@motiteux
motiteux / about.md
Created December 22, 2011 22:59 — forked from fogus/about.md
Programming Achievements: How to Level Up as a Developer
# 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,
@motiteux
motiteux / index.html
Last active March 12, 2018 12:30
World Map
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
width: 960px;
height: 500px;
position: relative;
}