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: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">
@ikks
ikks / forms.py
Created February 11, 2012 00:03
Sample Search Form to avoid accents using translit
from haystack.forms import SearchForm
.
.
class RtSearchForm(SearchForm):
def search(self):
if hasattr(self,'cleaned_data') and self.cleaned_data['q']:
self.cleaned_data['q']=self.cleaned_data['q'].encode('translit/one/ascii', 'replace')
sqs = super(RtSearchForm, self).search()
@ikks
ikks / urls.py
Created February 10, 2012 23:58
from haystack.views import SearchView
.
.
.
urlpatterns += patterns('haystack.views',
url(r'^$', SearchView, name='haystack_search'),
)
@ikks
ikks / urls.py
Created February 10, 2012 23:56
Pattern for haystack with a custom form and login_required
from haystack.views import SearchView
from django.contrib.auth.decorators import login_required
from apps.informationgathering.forms import RtSearchForm
.
.
.
urlpatterns += patterns('haystack.views',
url(r'^$', login_required(SearchView(