I hereby claim:
- I am benjaoming on github.
- I am benjaoming (https://keybase.io/benjaoming) on keybase.
- I have a public key ASCa077dJpvd_GlrDxPvWAQUkdoRhqhU_mHh9eg1zSQxWgo
To claim this, I am signing this object:
# -*- coding: utf-8 -*- | |
"""Refactor South migrations to use settings.AUTH_USER_MODEL. | |
Inserts a backwards-compatible code-snippet in all | |
your schema migration files and uses a possibly customized user | |
model as introduced in Django 1.5. | |
Please note that this has nothing to do with changing | |
settings.AUTH_USER_MODEL to a new model. If you do this, stuff | |
will very likely break in reusable apps that have their own | |
migration trees. |
""" | |
This code is public domain. | |
The original author is Bear Huang (http://bear330.wordpress.com/). | |
Uploaded to GIST and adapted for autopep8 by github/benjaoming | |
""" | |
# Guide for installing a code formatter (like this one) in PyDev: | |
# http://bear330.wordpress.com/2007/10/30/using-pythontidy-in-pydev-as-code-formatter/ | |
# Ensure that your autopep8.py is executable (chmod +x). |
import logging | |
from django.core.cache import cache | |
from django.utils import timezone | |
from datetime import timedelta | |
logger = logging.getLogger('name-your-logger') | |
class BruteForceMixin(): | |
""" | |
Use this in a FormView and call count_failure() in form_invalid |
I hereby claim:
To claim this, I am signing this object:
#!/bin/bash | |
# Based on http://gagor.pl/2014/01/regenerate-thumbnails-in-shotwell-for-last-month/ | |
THUMB_ROOT=~/.cache/shotwell/thumbs | |
# Remove " > date('now','start of month','-1 month')" if you want to re-generate everything | |
sqlite3 ~/.local/share/shotwell/data/photo.db \ | |
"select id||' '||filename from PhotoTable where date(timestamp,'unixepoch','localtime') > date('now','start of month','-1 month') order by timestamp desc" | | |
while read id filename; do |
class ExceptionUserInfoMiddleware(object): | |
""" | |
Adds user details to request context on receiving an exception, so that they show up in the error emails. | |
Add to settings.MIDDLEWARE_CLASSES and keep it outermost(i.e. on top if possible). This allows | |
it to catch exceptions in other middlewares as well. | |
Origin: https://gist.github.com/646372 | |
""" | |
""" | |
Automatically suspend computer when the user has fallen asleep. But using your | |
own custom timing. | |
Add to your crontab with `crontab -e` | |
# m h dom mon dow command | |
0 2 * * * python3 /path/to/awake_or_suspend.py | |
This command either needs that your user can invoke `sudo` without a password or that it's launched with sude permissions. |
""" | |
This command exports blog posts, categories and tags from django-blog-zinnia | |
to wagtail_blog. | |
Usage: | |
0. Carefully consider if you want custom models for wagtail_blog before | |
starting the import. You may for instance want to retain an FK relation in | |
the database between old Zinnia Entry objects and new BlogPage objects. | |
1. Copy this script to yourapp/management/commands/zinnia_to_wagtail.py |
#!/usr/bin/env python | |
try: | |
import kolibri | |
except ImportError: | |
print( | |
"Could not find Kolibri in the system path, if you are using a PEX " | |
"file, please run `./file.pex manage shell` and then copy-paste all " | |
"contents of this script into the command line of Kolibri." | |
) |
""" | |
Ever got tired of having loads of migrations that have no effect on | |
the actual database? | |
This little mockup presents how we can move properties of fields into | |
a scope where they can easily be ignored by the migration system | |
Would it work? | |
""" | |
from django.db import models |