Skip to content

Instantly share code, notes, and snippets.

View matuu's full-sized avatar

Matuu matuu

View GitHub Profile
#!/bin/bash
sudo apt-get -y install language-pack-es-base
sudo apt-get -y install postgresql-9.1 libpq-dev postgresql-9.1-postgis gdal-bin
sudo apt-get -y install git python-pip python-dev
sudo apt-get -y install libxml2-dev libxslt1-dev
sudo -u postgres psql -c "CREATE ROLE dev LOGIN PASSWORD 'dev' SUPERUSER VALID UNTIL 'infinity';"
sudo -u postgres createdb template_postgis
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
@matuu
matuu / ttag_query.py
Created December 22, 2013 09:38
django templatetags: query filters model
@register.assignment_tag
def query(qs, **kwargs):
""" template tag which allows queryset filtering.
Usage:
{% load query from operations %}
{% query operations description="some things" as records %}
{% for r in records %}
...
{% endfor %}
"""
@matuu
matuu / reset_last_commit.txt
Created November 27, 2013 17:28
Reset last commit
$ git commit ... (1)
$ git reset --soft "HEAD^" (2)
$ edit (3)
$ git add .... (4)
$ git commit -c ORIG_HEAD (5)
1) This is what you want to undo
2) This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before "reset". (The quotes are required if you use zsh)
3) Make corrections to working tree files.
4) Stage changes for commit.
@matuu
matuu / luhn.py
Created November 27, 2013 11:14
Luhn checksum
def luhn_checksum(card_number):
def digits_of(n):
return [int(d) for d in str(n)]
digits = digits_of(card_number)
odd_digits = digits[-1::-2]
even_digits = digits[-2::-2]
checksum = 0
checksum += sum(odd_digits)
for d in even_digits:
checksum += sum(digits_of(d*2))