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 splinter.browser import Browser | |
| browser = Browser('chrome') | |
| browser.visit('http://google.com') | |
| browser.fill('q', 'splinter - python acceptance testing for web applications') | |
| browser.find_by_name('btnG').first.click() | |
| if browser.is_text_present('splinter.cobrateam.info'): | |
| print "Yes, the official website was found!" | |
| else: |
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
| """ | |
| Resposta que surgiu nesta discussão: https://groups.google.com/forum/#!topic/django-brasil/3ADhmbltSUU | |
| Então guardei aqui p/ testar em breve. | |
| """ | |
| Model.objects.using(Model.user_db(user)).all() ou | |
| instance.save(using=Model.user_db(user)) | |
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.views.generic import View | |
| from django.template.response import TemplateResponse | |
| from news.models import Noticia | |
| from videos.models import Video | |
| from datetime import datetime | |
| class HomeView(View): | |
| template_name = 'home/home.html' |
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
| SetEnvIf Origin "^http(s)?://(.+\.)?(http://ANY_DOMAIN_HERE\.com)$" origin_is=$0 | |
| Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is |
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
| # Apply keyword searches. | |
| def construct_search(field_name): | |
| if field_name.startswith('^'): | |
| return "%s__istartswith" % field_name[1:] | |
| elif field_name.startswith('='): | |
| return "%s__iexact" % field_name[1:] | |
| elif field_name.startswith('@'): | |
| return "%s__search" % field_name[1:] | |
| else: | |
| return "%s__icontains" % field_name |
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/TZBXSowifn8 | |
| from django.utils.encoding import smart_str, smart_unicode | |
| a = u'\xa1' | |
| print smart_str(a) |
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://coderwall.com/p/p0nvjw?i=5&p=1&q= --> | |
| <ol class="breadcrumb"> | |
| <li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> | |
| <a href="http://www.example.com/" itemprop="url"> | |
| <span itemprop="title">Example.com</span> | |
| </a> | |
| </li> | |
| <li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> | |
| <a href="http://www.example.com/news" itemprop="url"> | |
| <span itemprop="title">News</span> |
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
| update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, "find this string", "replace found string with this string"); |
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
| ~$ cd /opt/VirtualBox | |
| ~$ ls -al | |
| ~$ sudo chmod +x uninstall.sh | |
| ~$ sudo sh uninstall.sh | |
| # then with 'cd' command move to the directory where is the .deb file, and execute it, example: | |
| ~$ cd ~/Downloads | |
| ~$ sudo dpkg -i virtualbox-4.1_4.1.20-80170~Ubuntu~precise_amd64.deb |