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
| # Enable us to call scrapy from manage.py | |
| from __future__ import absolute_import | |
| from django.core.management.base import BaseCommand | |
| class Command(BaseCommand): | |
| def run_from_argv(self, argv): | |
| self._argv = argv | |
| self.execute() |
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
| This playbook has been removed as it is now very outdated. |
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
| class LoginRequiredMixin(object): | |
| """ | |
| View mixin which requires that the user is authenticated. | |
| """ | |
| @method_decorator(login_required) | |
| def dispatch(self, request, *args, **kwargs): | |
| return super(LoginRequiredMixin, self).dispatch( | |
| self, request, *args, **kwargs) |
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
| # https://groups.google.com/forum/?fromgroups#!topic/django-brasil/d6gV1V9qrgU | |
| from django.forms import ModelForm | |
| from minha_app.models import MeuModel | |
| class MeuForm(ModelForm): | |
| class Meta: | |
| model = MeuModel |
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
Show hidden characters
| /* | |
| SublimeLinter default settings | |
| */ | |
| { | |
| /* | |
| Sets the mode in which SublimeLinter runs: | |
| true - Linting occurs in the background as you type (the default). | |
| false - Linting only occurs when you initiate it. | |
| "load-save" - Linting occurs only when a file is loaded and saved. |
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
| These are snippets of py.test in action, used in a talk given at | |
| PyCon AU 2012 in Hobart, Tasmania. They are all relevant for | |
| py.test 2.2 except where specified. Where taken from open source | |
| projects I have listed a URL, some examples are from the py.test | |
| documentation, some are from my workplace. | |
| Apart from things called test_*, these functions should probably | |
| be in your conftest.py, although they can generally start life in | |
| your test 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
| """ | |
| Two things are wrong with Django's default `SECRET_KEY` system: | |
| 1. It is not random but pseudo-random | |
| 2. It saves and displays the SECRET_KEY in `settings.py` | |
| This snippet | |
| 1. uses `SystemRandom()` instead to generate a random key | |
| 2. saves a local `secret.txt` |
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
| """A basic database set-up for Travis CI. | |
| The set-up uses the 'TRAVIS' (== True) environment variable on Travis | |
| to detect the session, and changes the default database accordingly. | |
| Be mindful of where you place this code, as you may accidentally | |
| assign the default database to another configuration later in your code. | |
| """ | |
| import os |
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
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
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
| import tornado.ioloop | |
| import tornado.web | |
| from datetime import datetime | |
| import urlparse | |
| from bson.json_util import dumps | |
| import pymongo | |
| from pymongo import Connection | |
| class Home(tornado.web.RequestHandler): |