thefekete.net

$> :(){ :|:& };:

Remove trailing whitespace from lines in Vim

Put this in your command mode and smoke it:

:s/ \+$//g

Match RAR archives

The Following can be used to find the first RAR file in a multi-volume archive. It will find *.part01.rar or *.rar depending on the naming convention in use.

.*[^p][^a][^r][^t]..\.rar$|.*part01\.rar$

If you need to find all the RAR files and SFV files (probably to delete them after extraction), the following will get them all.

.*\.r[0-9]{2}$|.*\.rar$|.*\.sfv$

Bash: Count Lines of Code in a Python Project

#!/bin/bash
find . -name '*.py' | xargs cat | sed '/^\s*#/d;/^\s*$/d' | wc -l

xargs converts find’s output to arguments, the sed RE drops comments and blank lines, and wc counts them lines. Thanks to these posts on stack overflow for some reference material.

Slug urlconf regex pattern for Django urlpatterns

If you want to match a slug in your urls.py, use (?P[-\w]+) as a named match pattern:

So, if you wanted to match http://example.com/some-slug-name/, you would use

urlpatterns = patterns('',
    # ...
    url(r'^(?P<slug>[-\w]+)/$', some_view),
    # ...
)

I got this info from a Django Users Thread on google groups.