This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| active_required = user_passes_test(lambda u: u.is_active, | |
| login_url='login.views.not_active', | |
| redirect_field_name='redirect_to' | |
| ) | |
| def active_and_login_required(view_func): | |
| decorated_view_func = login_required( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| dictionary = {} | |
| Model.objects.create(**dictionary) | |
| Model.objects.filter(pk=pk).update(**dictionary) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| from django.template.loader import get_template | |
| from django.template.loader_tags import BlockNode | |
| from django.template import Context | |
| from django.core import mail | |
| class EmailMessage(mail.EmailMultiAlternatives): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pip install requests | |
| import requests | |
| from django.core.files import File | |
| from django.core.files.temp import NamedTemporaryFile | |
| def save_image_from_url(model, url): | |
| r = requests.get(url) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| from django.http import HttpResponseNotAllowed | |
| from django.template import RequestContext | |
| from django.template import loader | |
| class HttpResponseNotAllowedMiddleware(object): | |
| def process_response(self, request, response): | |
| if isinstance(response, HttpResponseNotAllowed): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # first install mysql | |
| brew install mysql | |
| # second export path mysql | |
| PATH="$PATH:/usr/local/Cellar/mysql/5.6.15/bin/" | |
| # finally install mysql-python | |
| sudo pip install mysql-python --upgrade |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Makes you owner of /usr/local | |
| $ sudo chown -R `whoami` /usr/local | |
| ### Force uninstalls failed python | |
| $ brew uninstall -f python | |
| ### Clear the brew cache | |
| $ rm -rf `brew --cache` | |
| ### Cleanup - cleans up old homebrew files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo sh -c 'wget -qO- http://people.redhat.com/bkabrda/scl_python27.repo >> /etc/yum.repos.d/scl.repo' | |
| sudo yum install python27 | |
| scl -l | |
| python27 | |
| scl enable python27 bash | |
| python -V |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo groupadd developers | |
| adduser username | |
| usermod -a -G developers username | |
| mkdir repository.git | |
| cd !$ | |
| git --bare init | |
| touch readme.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import random | |
| from string import digits | |
| from string import letters | |
| def _pw(length=10): | |
| s = '' | |
| for i in range(length): |