Using gpg # compress and encrypt gpg -c filename >> Enter password # filename.gpg is encrypted file # decrypt gpg -d filename.gpg http://superuser.com/questions/162624/how-to-password-protect-gzip-files-on-the-command-line
Python: password generator
Password generator for myself(works in python3). # -*- coding:utf-8 -*- from string import ascii_lowercase, ascii_uppercase, digits import random def iter_password(length=8, num_of_numbers=2, num_of_uppers=2): numbers = list(digits) uppers = list(ascii_uppercase) lowers = list(ascii_lowercase) num_of_lowers = length – num_of_numbers – num_of_uppers while True:…
Python: General decorator
General decorator, that can be used to class method and function (keyword args are also permitted) by checking whether args[0] is ‘self’ or not and kwargs. # -*- coding:utf-8 -*- import inspect def multiply(func): def _multiply(*args, **kwargs): if inspect.getargspec(func).args[0] ==…
Django: csrf_exempt of class based view
To suppress csrf verification of class based view, @csrf_exempt decorator in veiws.py doesn’t work in Django 1.4 . http://stackoverflow.com/questions/10252238/csrf-exempt-stopped-working-in-django-1-4#comment13230749_10252521 Instead, decorating the as_view function in urls.py works fine! from django.views.decorators.csrf import csrf_exempt urlpatterns = patterns(”, url(r’^$’, csrf_exempt(views.IndexView.as_view()), name=’index’),