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 hashlib | |
def get_url_gravatar(email): | |
""" | |
Obtenemos la url del gravatar del email que se nos proporcione. | |
""" | |
m = hashlib.md5() | |
m.update(email.encode('utf-8')) | |
url = "http://www.gravatar.com/avatar/{0}.jpg?s=300".format(m.hexdigest()) | |
return url |
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
# Be sure to save your config files. Optional but I do: | |
sudo cp /etc/postgresql/9.3/main/postgresql.conf ~ | |
sudo cp /etc/postgresql/9.3/main/pg_hba.conf ~ | |
# Package repo (for apt-get) | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list' | |
# Also probably optional but I like to update sources and upgrade | |
sudo apt-get 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
"""" | |
Pipeline para guardar información desde un login con Twitter. | |
Obtiene la imagen grande de su cuenta de Twitter. | |
"""" | |
__author__ = 'alex' | |
from urllib.request import urlopen | |
from django.core.files.base import ContentFile | |
from social.backends.twitter import TwitterOAuth | |
from .models import UserProfile |
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
<!-- | |
autor: Alex Dzul @alexjs88 | |
Supongamos que tenemos miles de objetos a paginar. Django por sí solo no cuenta con una función que nos | |
permita definir cuántas páginas queremos mostrar y en tu template te podría aparecer miles de páginas: | |
< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 N1.. N2.. etc ... > | |
Si en nuestro sitio solo queremos mostrar un fragmento de páginas, entonces con este SNIP podemos definir | |
el intervalo de páginas hacia la izquierda y hacia la derecha que necesitamos. | |