Skip to content

Instantly share code, notes, and snippets.

@matiasherranz
matiasherranz / date_periods_handler.py
Created May 12, 2012 17:32
Date handling util functions
"""
Some date handling util functions I coded for Python/Django.
"""
import calendar
from datetime import datetime
from decimal import Decimal
from django.utils.datastructures import SortedDict
@matiasherranz
matiasherranz / .git_completion.sh
Created September 24, 2013 10:44
Git completion script. To be placed in the home directory.
#!bash
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@matiasherranz
matiasherranz / .django_bash_completion
Created September 24, 2013 10:45
Django commands completion script. To be placed in the home folder.
# #########################################################################
# This bash script adds tab-completion feature to django-admin.py and
# manage.py.
#
# Testing it out without installing
# =================================
#
# To test out the completion without "installing" this, just run this file
# directly, like so:
#
@matiasherranz
matiasherranz / .profile
Created September 24, 2013 10:47
GIT prompt setup file (and some more Bash tune-ups) Place this file under the home directory. Name it ".bashrc" in Linux or ".profile" in Mac OS.
# Python projects:
alias limpiarpycs='find . -iname "*.pyc" -delete'
# Para que SVN no muera por los acentos:
export LC_CTYPE=UTF-8
# General stuff:
alias ls="ls -G"
export EDITOR=nano
@matiasherranz
matiasherranz / gist:6693100
Last active December 23, 2015 20:59
Colours for GIT
[user]
name = Your Full Name
email = youremail@somemail.com
[alias]
conflicts = diff --name-only --diff-filter=U
st = status -s
ci = commit
br = branch
co = checkout
@matiasherranz
matiasherranz / gist:6693320
Created September 25, 2013 00:32
Python madness
[matias@MacBookPro]:~$ python
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def f():
... print 'f()'
...
>>> def g():
... print 'g()'
...
# Let's create a list with duplicated elements:
ls = [1,1,1,2,2,1,5,4,3,2,1]
# And let's now remove them in just one line:
l2 = list(set(ls))
# See the result:
@matiasherranz
matiasherranz / gist:6832420
Created October 4, 2013 20:44
Ubuntu Beep
beep() {
$@ &amp;&amp; paplay /usr/share/sounds/gnome/default/alerts/glass.ogg || paplay /usr/share/sounds/alsa/Noise.wav
}
@matiasherranz
matiasherranz / gist:6832433
Created October 4, 2013 20:45
Mac OS Beep
beep() {
$@ &amp;&amp; afplay /System/Library/Sounds/Glass.aiff || afplay /System/Library/Sounds/Blow.aiff
}