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 random | |
| import unittest | |
| import HTMLTestRunner | |
| class TestSequenceFunctions(unittest.TestCase): | |
| def setUp(self): | |
| self.seq = range(10) |
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
| {{ variable|stringformat:"02d" }} |
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
| The solution is: | |
| Update your virtualenv and re-create your virtualenvs, by passing the path of an existing virtualenv dir. | |
| http://www.guyrutenberg.com/2012/05/30/fixing-virtualenv-after-upgrading-your-distributionpython/ |
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
| # O select você faz normal usando o 'using' para indicar a database específica | |
| # algo como: Usuario.objects.using('database_test') | |
| from django import forms | |
| # ... | |
| class UsuarioForm(forms.ModelForm): | |
| def __init__(self, *args, **kwargs): | |
| super(ContentForm, self).__init__(*args, **kwargs) | |
| self.fields["user"].queryset = Usuario.objects.using('database_test') |
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
| git commit --amend | |
| more info: http://git-scm.com/book/en/Git-Basics-Undoing-Things |
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
| # coding=UTF-8 | |
| from __future__ import division | |
| import re | |
| # This is a naive text summarization algorithm | |
| # Created by Shlomi Babluki | |
| # April, 2013 | |
| class SummaryTool(object): |
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
| from django import forms | |
| from .models import ExampleModel | |
| class LocalizeMixin(object): | |
| def __init__(self, *args, **kwargs): | |
| super(LocalizeMixin, self).__init__(*args, **kwargs) | |
| fields = self.Meta.localized_fields | |
| if fields: | |
| for field in fields: |
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
| $ python manage.py shell | |
| >>> from south.models import MigrationHistory | |
| >>> m = MigrationHistory.objects.get(migration='<migration_name>') | |
| >>> m.delete() |
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 apt-get build-dep python-sympy python-scipy python-matplotlib python-pandas python-nose |
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
| http://www.ubuntubrsc.com/13-principais-comandos-do-ubuntu.html | |
| Atualizar a lista de pacotes: sudo apt-get update | |
| Efetua a atualização: sudo apt-get upgrade | |
| Instalar pacotes: sudo apt-get install nome do pacote | |
| Procurar pacotes: apt-cache search palavras chave | |
| Procurar por dependências inválidas: sudo apt-get check | |
| Corrigir problemas de dependências, concluir instalação de pacotes pendentes e outros erros: sudo apt-get -f install | |
| Se o comando sudo apt-get -f install não resolver use: sudo dpkg -i –force-all para forçar a instalação ou sudo dpkg -r nome do pacote para desistir da instalação |