I hereby claim:
- I am jdunck on github.
- I am jdunck (https://keybase.io/jdunck) on keybase.
- I have a public key whose fingerprint is 8801 066B D85C 57BA 0D02 8BF9 A4EA DF1F 0080 A663
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| import posixpath | |
| from django.contrib.staticfiles import finders | |
| from django.contrib.staticfiles.storage import staticfiles_storage | |
| def static_fallback_open(static_path, mode='r'): | |
| writing = 'w' in mode or 'a' in mode | |
| if writing or staticfiles_storage.exists(static_path): | |
| return staticfiles_storage.open(static_path, mode) |
| Scenario: | |
| You have a long-running branch to upgrade your existing codebase to django 1.7. | |
| You've previously used south, and your existing deployment includes schema changes since the | |
| base of the django-1.7 upgrade branch. | |
| You need to re-create django (core) migrations periodically since you can't merge | |
| south migrations into core migrations. | |
| (Assumes commands are run from root of project and that apps are top-level directories Adjust pathing if that is not the case.) |
| def get_stdlib_names(): | |
| import distutils.sysconfig as sysconfig | |
| import os | |
| import sys | |
| std_lib = sysconfig.get_python_lib(standard_lib=True) | |
| pathed_dirs = sorted(sys.path[:], key=lambda s: len(s), reverse=True) | |
| prefixes = filter(lambda path: path.startswith(std_lib), pathed_dirs) | |
| for top, dirs, files in os.walk(std_lib): |
| for COMPONENT in actionmailer actionpack actionview activemodel activerecord activesupport; do | |
| for VERSION in master 4-2-stable 4-1-stable 4-0-stable 3-2-stable 3-1-stable 3-0-stable; do | |
| if [[ "$VERSION" == "3-0-stable" ]]; then | |
| FN='CHANGELOG' | |
| else | |
| FN='CHANGELOG.md' | |
| fi | |
| curl "https://raw.githubusercontent.com/rails/rails/${VERSION}/${COMPONENT}/${FN}" > ${COMPONENT}-${VERSION}-CHANGELOG | |
| done |
| def flattened_hash(h, namespace = '', memo = {}) | |
| h.reduce(memo) { |memo, (key, value)| | |
| if value.instance_of?(Hash) | |
| memo.merge!(flattened_hash(value, "#{namespace}#{key}_", memo)) | |
| else | |
| memo["#{namespace}#{key}"] = value | |
| end | |
| memo | |
| } | |
| end |
| from collections import OrderedDict | |
| class Choices(object): | |
| """ | |
| Just like raw tuple-choices you're used to passing to django's | |
| choices kwarg, but better. | |
| :param value_label_pairs: tuple-of-pairs, like raw choices= parameters. | |
| :param attrs: optional attribute names to use instead of label.upper() |
It's been hard for me to remember what the required relative order of python preambles (that is, encoding markers, future imports, and module docstrings) should be.
This is an empirical approach, showing that the proper order is:
# -*- coding: utf8 -*-
"""døcst®îñg"""
from __future__ import unicode_literals
| #!/bin/bash | |
| if [[ $# != 1 ]]; then | |
| echo usage: backup /path/to/backup/dest | |
| echo "( src is assumed / )" | |
| exit | |
| fi | |
| root_dir=$1 | |
| dest=${root_dir}/${HOSTNAME} | |
| if [[ -e /proc ]] ; then |