Skip to content

Instantly share code, notes, and snippets.

View douglasmiranda's full-sized avatar
👽

Douglas Miranda douglasmiranda

👽
  • Earth, Brazil
View GitHub Profile
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'
@douglasmiranda
douglasmiranda / gist:2885050
Created June 6, 2012 21:49
Django: Escolher db dinamicamente
"""
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))
@douglasmiranda
douglasmiranda / splinter_tutorial.py
Created June 6, 2012 06:27
Tutorial Splinter. Fixing the current tutorial, which is failing
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:
@douglasmiranda
douglasmiranda / gist:2791545
Created May 26, 2012 00:58
find gunicorn process
ps ax|grep gunicorn
@douglasmiranda
douglasmiranda / gist:2721572
Created May 17, 2012 21:01
Force the Launch of Unity 3D as First Desktop Enviroment on Ubuntu 12
#From the terminal open the file environment
$: sudo gedit /etc/environment
#Insert the line at the botton of the file
UNITY_FORCE_START=1
@douglasmiranda
douglasmiranda / gist:2565256
Created May 1, 2012 05:11
WebFaction: Total (MB) of memory usage app
ps -u username -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum/1024}'
@douglasmiranda
douglasmiranda / gist:2555156
Created April 30, 2012 03:07
Solução para instalar lxml no ubuntu com sucesso =] ( erro em pip install lxml )
#Se o erro for algo parecido com isto:
#building 'lxml.etree' extension
#gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w
#In file included from src/lxml/lxml.etree.c:239:0:
#src/lxml/etree_defs.h:9:31: erro fatal: libxml/xmlversion.h: Arquivo ou diretório não encontrado
#compilação terminada.
#error: command 'gcc' failed with exit status 1
#basta instalar libxml2-dev e libxslt-dev
@douglasmiranda
douglasmiranda / gist:2552192
Created April 29, 2012 17:44
Gloobus Preview for Ubuntu 12.04
#INSTALL
sudo add-apt-repository ppa:gloobus-dev/gloobus-preview
sudo apt-get update
sudo apt-get install gloobus-preview gloobus-sushi
#For the oppenoffice documents to work, you should install unoconv too
sudo apt-get install unoconv
@douglasmiranda
douglasmiranda / gist:2527687
Created April 29, 2012 03:07
fixing dropbox - Ubuntu 12
#When dropbox is not working on ubuntu 12
#you tried to execute on terminal:
#dropbox start
#and the error is something like this:
#Starting Dropbox.../home/YOUR_USER/.dropbox-dist/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required #by /usr/lib/x86_64-linux-gnu/libproxy.so.1)
#Failed to load module: /usr/lib/x86_64-linux-gnu/gio/modules/libgiolibproxy.so
#Done!
#FIX
cd /home/YOUR_USER/.dropbox-dist/
@douglasmiranda
douglasmiranda / .gitconfig
Created April 27, 2012 03:33
git configs
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold