Skip to content

Instantly share code, notes, and snippets.

View joaodubas's full-sized avatar
🤓
always learning

Joao P Dubas joaodubas

🤓
always learning
View GitHub Profile
from datetime import datetime
while tempo >= 0:
if minuto > 59:
hora += 1
minuto = 0
if hora > 23:
dia += 1
hora = 0
if dia > dia_limite:
mes += 1
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._
======================================================
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10
======================================================
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu
8.10. The article is targeted at a production environment, but keep in mind
this is a more generalized environment. You may have different requirements,
but this article should at least provide the stepping stones.
The article will use distribution packages where nesscary. As of 8.10 the
from django import forms
from models import Pais
class MyForm(forms.Form):
pais = forms.ModelChoiceField(queryset = Pais.objects.all())
def __init__(self, *args, **kwargs):
@joaodubas
joaodubas / settings.py
Created August 17, 2011 23:56
eventex settings
import os
ROOT = os.path.dirname(os.path.abspath(__file__))
join_root = lambda *x: os.path.join(ROOT, *x)
MEDIA_ROOT = join_root('media', 'uploads')
MEDIA_URL = '/upload/'
STATIC_ROOT = join_root('media', 'assets')
@joaodubas
joaodubas / route.py
Created November 8, 2011 18:44 — forked from henriquebastos/route.py
Route is a better urls function, consider all Http verbs, and return 405 (NotAllowed) with the list of proper methods
# -*- encoding: utf-8 -*-
# Usage:
# urlpatterns += patterns('',
# route(r'^$', GET='getview', POST='postview', PUT='putview', DELETE='deleteview', name='viewname'),
# )
#
from django.http import HttpResponseNotAllowed
from django.core.urlresolvers import RegexURLPattern, get_callable
def discover_view(view, prefix=''):
@joaodubas
joaodubas / LICENSE.txt
Created November 23, 2011 18:25
A simple form to export data from a django model to a csv file
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 João Paulo Dubas <http://aval.io>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@joaodubas
joaodubas / decorator.py
Created November 27, 2011 12:11
Profiler decorator for Django
import hotshot
import os
import time
from django.conf import settings
try:
PROFILE_LOG_BASE = settings.PROFILE_LOG_BASE
except:
PROFILE_LOG_BASE = settings.ROOT
@joaodubas
joaodubas / git_graph
Created December 11, 2011 18:17
Git graph alias
git config --global alias.graph "log --graph --date-order -C -M --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=short"
@joaodubas
joaodubas / GoSublime.sublime-settings
Created December 25, 2011 15:08
GoSublime settings
{
"gocode_cmd": "/usr/local/bin/gocode",
"gofmt_cmd": "/usr/local/bin/gofmt",
"gslint_cmd": "/usr/local/bin/gotype",
"gstint_timeout": 500,
"gocode_accepts_character_offsets": false
}