Skip to content

Instantly share code, notes, and snippets.

View ptone's full-sized avatar

Preston Holmes ptone

View GitHub Profile
@ptone
ptone / gist:4102528
Created November 18, 2012 01:30
flake8 git hook for virtualenv
#!/usr/bin/env python
import glob
import os
import sys
# git usurbs your bin path for hooks and will always run system python
site_packages = glob.glob('%s/lib/*/site-packages' % os.environ['VIRTUAL_ENV'])[0]
sys.path.insert(0, site_packages)
@ptone
ptone / gist:4069307
Last active October 12, 2015 18:28
django-up
#!/bin/bash
git fetch upstream && git co stable/1.5.x && git merge --ff-only upstream/stable/1.5.x && git co stable/1.4.x && git merge --ff-only upstream/stable/1.4.x && git co master && git merge --ff-only upstream/master
element:ola (master)$ autoreconf -i
configure.ac:11: installing 'config/install-sh'
configure.ac:11: installing 'config/missing'
common/Makefile.am:1: error: Libtool library used but 'LIBTOOL' is undefined
common/Makefile.am:1: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
common/Makefile.am:1: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
common/Makefile.am:1: If 'LT_INIT' is in 'configure.ac', make sure
common/Makefile.am:1: its definition is in aclocal's search path.
common/base/Makefile.am:3: error: Libtool library used but 'LIBTOOL' is undefined
common/base/Makefile.am:3: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
element:src$ git clone https://code.google.com/p/open-lighting/ ola
Cloning into 'ola'...
remote: Counting objects: 26969, done.
remote: Finding sources: 100% (26969/26969), done.
remote: Total 26969 (delta 19524)
Receiving objects: 100% (26969/26969), 8.96 MiB | 1.17 MiB/s, done.
Resolving deltas: 100% (19524/19524), done.
element:src$ cd ola/
element:ola (master)$ autoreconf -i
configure.ac:21: error: possibly undefined macro: AC_LIBTOOL_WIN32_DLL
In an ideal world - checksums would be an perfectly viable way to compare
files. However, practically - they can't be well supported by the collectstatic
API.
While md5 may be somewhat common - it is neither universal nor standard. For
cloud based storage backends to support a comparison metric other than
modification times for use by collectstatic, they would need to provide that
value as a remote/api call, it would do no good if the only way to support this
involved retrieving the remote object to get a hash on it (even if you had
drastically asymetrical bandwidth - this is just poor design).
>>> from django.contrib.auth.models import User
>>> u = User.objects.all()[0]
>>> u
<User: preston>
>>> u.natural_key
<bound method User.natural_key of <User: preston>>
>>> u.natural_key()
(u'preston',)
>>> nat_key = u.natural_key()
>>> User.objects.get_by_natural_key(nat_key)
@ptone
ptone / current.md
Created October 6, 2012 04:25
A WIP refactor of auth docs - this is just a draft rough reorg - much rewriting would also be involved
  • /topics/auth.txt
    • Overview
    • Installation
    • Users
      • API reference
        • Fields
        • Methods
        • Manager functions
      • Basic usage
  • Creating users
Implement template-based widget renderinghttps://code.djangoproject.com/ticket/15667
Proposal: template-based widget rendering
http://groups.google.com/group/django-developers/browse_thread/thread/7cc4279367c0a3f0
@ptone
ptone / gist:3741235
Created September 18, 2012 04:16
CONTRIBUTING draft

Contributing to Django

As an open source project, Django welcomes contributions of many forms.

Examples of contributions include:

  • Code patches
  • Documentation improvements