Skip to content

Instantly share code, notes, and snippets.

View benjaoming's full-sized avatar

Benjamin Balder Bach benjaoming

View GitHub Profile
@benjaoming
benjaoming / shotwell_regenerate_thumbnails.sh
Last active April 10, 2017 01:56
Regenerate Shotwell Thumbnails
#!/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

Keybase proof

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:

@benjaoming
benjaoming / brute_force_mixin.py
Last active August 29, 2015 14:00
Block brute force attempts with a Mixin intended for FormView
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
@benjaoming
benjaoming / pyedit_autopep8.py
Last active February 2, 2017 08:55
PyDev with autopep8 formatting upon CTRL+SHIFT+F
"""
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).
@benjaoming
benjaoming / custom_user_auth_south_refactor.py
Last active August 1, 2020 17:04
Refactor South migration directory to respect custom User models. Backwards compatible with <django 1.5
# -*- 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.