Skip to content

Instantly share code, notes, and snippets.

View ikks's full-sized avatar

Igor Támara ikks

View GitHub Profile
@ikks
ikks / gist:3497819
Created August 28, 2012 13:04
load django-automplete-light for admin
import autocomplete_light
autocomplete_light.autodiscover()
@ikks
ikks / gist:3497811
Created August 28, 2012 13:02
urls for django-autocomplete-light
url(r'autocomplete/', include('autocomplete_light.urls')),
@ikks
ikks / gist:3497717
Created August 28, 2012 12:44
Install django-autocomplete-light
pip install django-autocomplete-light
@ikks
ikks / gist:3371167
Created August 16, 2012 15:41
Colored Image in hover
img {
-webkit-transition: -webkit-filter 1s;
-webkit-filter: grayscale(1); /* Chrome */
filter: url(filters.svg#grayscale); /* Firefox 3.5+ */
filter: gray; /* IE6-9 */
}
img:hover {
-webkit-filter: grayscale(0); /* Chrome */
filter: none; /* Applies to FF + IE */
}
@ikks
ikks / gist:3344804
Created August 13, 2012 23:27
Algunas operaciones sobre hstore
-- Obtener las llaves como arreglo
SELECT nombre, akeys(atributos) FROM producto;
-- Saber si un producto tiene cierta característica
SELECT nombre, atributos -> talla FROM producto WHERE atributos ? 'talla';
-- Obtener el conjunto de características y sus valores para un producto
SELECT each(atributos) FROM producto WHERE name='pizza';
@ikks
ikks / gist:3344613
Created August 13, 2012 22:42
Añadir un dato a una tabla con hstore
INSERT INTO producto (nombre, atributos) VALUES (
'Bicicleta',
'color => "verde",
ruedas => 2,
tipo => "monareta"'
);
@ikks
ikks / gist:3344575
Created August 13, 2012 22:38
Tabla con hstore
CREATE TABLE producto (
id serial PRIMARY KEY,
nombre varchar,
atributos hstore
);
@ikks
ikks / gist:3344545
Created August 13, 2012 22:33
Creating extension hstore for Postgresql 9.X
CREATE EXTENSION hstore;
@ikks
ikks / goo.gl.py
Created May 31, 2012 19:43
Using goo.gl from python 2.X Where X is 6 or more
#Given to the public domain
#No warranties
import urllib2
import simplejson
def shorturl(urltoshorten):
"""Compress the URL using goo.gl take a look at https://developers.google.com/url-shortener/v1/getting_started
>>> shorturl('http://igor.tamarapatino.org')
'http://goo.gl/FxHOn'
@ikks
ikks / search.html
Created February 11, 2012 00:09
Sample for a search template using gist
{% extends "layout/base.html" %}
<div class="entry">
{% block body %}
<div class="register_init">
<div class="add_new">
<a href="/recolecta/nuevo">Nueva Solicitud de Inscripción en el Registro</a>
</div>
<form method="get" action=".">
{{ form.as_p }}
<input type="submit" value="Buscar">