Skip to content

Instantly share code, notes, and snippets.

View gilsondev's full-sized avatar
💼
Work

Gilson Filho gilsondev

💼
Work
View GitHub Profile
@gilsondev
gilsondev / subversion_cheatsheet.md
Created November 23, 2012 18:08
Subversion cheatsheet

Subversion Cheatsheet

Criar um repositório SVN local

OBS: Assumindo que project1 já existe em /home/user/project1 e tem conteúdo, vamos criar um repositório e importar o conteúdo de project1.

  1. Cria o diretório que irá conter o repositório:
    $ mkdir /home/user/svnrep
@gilsondev
gilsondev / dummy_image.py
Last active November 9, 2015 16:13
Cria imagem para ser usados em testes unitários
# -*- coding: utf-8 -*-
from StringIO import StringIO
from PIL import Image
def dummy_image(name='image_test', format='png'):
"""Gera um imagem para 'mockar' nos testes. Você pode passar
os seguintes parametros::
@gilsondev
gilsondev / bashrc
Created September 1, 2012 21:32
Cria variável de ambiente que aponta para o caminho da pasta do projeto ao ativar o ambiente com virtualenvwrapper.
# Plus: Creating alias for manage.py of django projects (with manage.py in root)
alias manage='$PROJECT_PATH/manage.py'
@gilsondev
gilsondev / models.py
Created August 23, 2012 14:06
Alterando atributos de certos fields da classe Pai
class User(models.Model):
"""
Users within the Django authentication system are represented by this
model.
Username and password are required. Other fields are optional.
"""
username = models.CharField(_('username'), max_length=30, unique=True,
help_text=_('Required. 30 characters or fewer. Letters, numbers and '
'@/./+/-/_ characters'))
@gilsondev
gilsondev / forms.py
Created August 17, 2012 19:08 — forked from mcosta/forms.py
Sistema de Auditoria (RAAI - Relatorio Anual de Auditoria Interna)
# -*- coding: utf8 -*-
import time, datetime
from datetime import date
from django import forms
from django.contrib.auth.models import User
from django.conf import settings
from bootstrap_toolkit.widgets import BootstrapDateInput
@gilsondev
gilsondev / forms.py
Created August 8, 2012 16:43
Mostrando como usar o Django Forms
# -*- coding: utf8 -*-
from django import forms
from .models import Foo, Bar, FooBar
class FooModelForm(forms.ModelForm):
# Essa classe vai usar a instrospecção para gerar o formulário
# baseado nos atributos da classe Foo
class Meta:
@gilsondev
gilsondev / xmonad-unity-session.desktop
Created August 7, 2012 13:49
Minha configuração do Xmonad com Unity no Ubuntu 12.04
# /usr/share/xsession/
[Desktop Entry]
Name=XMonad Unity
Comment=Tiling window manager
TryExec=/usr/bin/gnome-session
Exec=gnome-session --session=xmonad
Type=XSession
# -*- coding: utf8 -*-
from django.test import TestCase
from django.core.urlresolvers import reverse as r
from django.db import IntegrityError
from .models import Subscription
from .forms import SubscriptionForm
@gilsondev
gilsondev / tests.py
Created July 31, 2012 18:21
Classe de Teste da view de subscriptions
from django.core.urlresolvers import reverse as r
# ...
class SubscribeViewTest(TestCase):
def setUp(self):
self.resp = self.client.get(r('subscriptions:subscribe'))
def test_get(self):
'Ao visitar /inscricao/ a página de inscrição é exibida'
@gilsondev
gilsondev / middleware.py
Created July 21, 2012 16:12
Middleware que impede o cache da página pelo navegador (bom para desenvolvimento)
class NoCacheMiddleware(object):
def process_response(self, request, response):
request.META['HTTP_CACHE_CONTROL'] = "no-cache"
return response