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
@joaodubas
joaodubas / django.md
Created March 3, 2012 02:45
Steps to init django
  1. Instalar Xcode via AppleStore

  2. Instalar Command Line Tools for Xcode (procurar em Apple Developers)

  3. Instalar pip

    • sudo easy_install pip
  4. Instalar virtualenv e virtualenvwrapper

    • sudo pip install virtualenv virtualenvwrapper
  5. Alterar o arquivo .bash_profile, adicionando o código a seguir

     # Make pip respect virtualenv
    

export PIP_RESPECT_VIRTUALENV=true

@joaodubas
joaodubas / LICENSE.txt
Created February 16, 2012 13:59
Render the content of a page using PhantomJS
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 / 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
}
@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 / 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 / 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 / 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 / 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')
from django import forms
from models import Pais
class MyForm(forms.Form):
pais = forms.ModelChoiceField(queryset = Pais.objects.all())
def __init__(self, *args, **kwargs):
======================================================
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