This file contains 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 pickle | |
import os | |
class ModelBase(type): | |
models = [] | |
def __new__(cls, name, bases, attrs): | |
attrs.update({ |
This file contains 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
def feliz(number, results=None): | |
if results is None: | |
results = [] | |
next_number = sum(int(a) ** 2 for a in str(number)) | |
if next_number in results: | |
return False | |
if next_number != 1: |
This file contains 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 functools import wraps | |
from getpass import getpass | |
import sys | |
from db import Users | |
Logged = False |
This file contains 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 functools import partial, wraps | |
def debug_old(prefix=''): | |
def debug(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
print(prefix + func.__name__) |
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant::Config.run do |config| | |
config.vm.box = "precise32" | |
config.vm.box_url = "http://files.vagrantup.com/precise32.box" | |
config.vm.network :hostonly, "33.33.33.33" |
This file contains 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 Field(object): | |
def __init__(self, default=None): | |
self.val = default | |
def __get__(self, obj, objtype): | |
if obj is None: | |
return self.__class__ | |
else: | |
return self.val |
This file contains 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 ListView | |
from django.views.generic.edit import FormMixin | |
from django.db.models import Q | |
class SearchView(FormMixin, ListView): | |
template_name_suffix = '_search' | |
filter_operator = 'contains' | |
allow_or_operator = False | |
def get_filter_operator(self): |
This file contains 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.core.exceptions import ImproperlyConfigured | |
from django.contrib import messages | |
class SuccessMessageMixin(object): | |
success_message = None | |
def get_success_message(self): | |
if self.success_message: |
This file contains 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.conf.urls import patterns, include, url | |
from django.views.decorators.cache import never_cache | |
from django.contrib import admin | |
# voce pode por isso em outra arquivo e importar aqui | |
class CustomAdminSite(admin.AdminSite): | |
@never_cache | |
def index(self, request, extra_context=None): | |
ret = super(CustomAdminSite, self).index(request, extra_context) | |
# SEU CODIGO AQUI |
This file contains 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
{% extends 'base.html'%} | |
{% block content %} | |
{% if messages %} | |
<ul class="messages"> | |
{% for message in messages %} | |
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> | |
{% endfor %} | |
</ul> | |
{% endif %} |