Skip to content

Instantly share code, notes, and snippets.

View alexdzul's full-sized avatar

Alex Dzul alexdzul

View GitHub Profile
@alexdzul
alexdzul / url_gravatar.py
Last active September 25, 2015 02:41
Obteniendo url de imagen gravatar desde Python
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
@alexdzul
alexdzul / gist:70725c26b2ffdb00fd18
Last active August 29, 2015 14:25 — forked from tamoyal/gist:2ea1fcdf99c819b4e07d
Upgrade Postgres 9.3 to 9.4 on Ubuntu
# 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
@alexdzul
alexdzul / pipeline_twitter.py
Created July 24, 2015 00:58
Pipeline para Twitter
""""
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
@alexdzul
alexdzul / PaginatingDjango
Last active June 17, 2018 22:23
Paginación inteligente con Django Template Engine
<!--
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.