Skip to content

Instantly share code, notes, and snippets.

@matiasherranz
matiasherranz / get_extension.py
Created September 26, 2014 15:52
Get filename extension function, using a regex.
import re
def get_extension(filename):
regex = re.compile(r'^.*?[.](?P<ext>tar\.gz|tar\.bz2|\w+)$')
return regex.match(filename).group('ext')
@matiasherranz
matiasherranz / get_extension2
Created September 26, 2014 15:54
Get filename extension function, using a regex. Keep the point.
import re
def get_extension(filename):
regex = re.compile(r'^.*?.(?P<ext>.tar\.gz|.tar\.bz2|.\w+)$')
return regex.match(filename).group('ext')
@matiasherranz
matiasherranz / gist:9a4f2a2cb2d03aced6a4
Created September 26, 2014 15:59
Get filename extension function, using a regex. Keep the point.
import re
def get_extension(filename):
regex = re.compile(r'^.*?.(?P<ext>.tar\.gz|.tar\.bz2|.\w+)$')
return regex.match(filename).group('ext')
@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
santex@santex-VirtualBox:~/DevIT/nagios_samanage$ cat nagios.cfg
# 'notify-host-by-sam' command definition
define command{
command_name notify-host-by-sam
command_line <perl path> <script path>/sam_createcase --hostname=$HOSTNAME$ --type="$NOTIFICATIONTYPE$" --state=$HOSTSTATE$ --address=$HOSTADDRESS$ --output="$HOSTOUTPUT$" --date="$LONGDATETIME$"
}
# 'notify-service-by-sam' command definition
define command{
command_name notify-service-by-sam
function Car() {
}
Car.protoype = {
}
@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