Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Remove .svn files recursively

find . -type d -name '.svn' -exec rm -rf {} \;

recursevly remove .svn files from an existing repo

If you need to take a project out of scm, you can run this bash script from the top folder - and it will remove all .svn folders recursevly (sp)

Works well for
- changing an svn checkout into and svn export
- switching from svn to git

find . -type d -name '.svn' -exec rm -rf {} \;

Compressing a directory with rar on Linux

I've been struggling to get this to work for so long that when I finally got it going I had to throw it up here so I wouldn't lose it.
rar a -m5 -R output.rar /etc/

This will create a max compression (not taking into account dictionary sizes and the like) archive of the entire etc directory.

Python Towers of Hanoi

Use the following as a template, replace the print line with any work for moving the discs using your data structure. The code below just prints the necessary moves.

def hanoi(n, a='A', b='B', c='C'):
    """
    move n discs from a to c using b as middle
    """
    if n == 0:
        return
    hanoi(n-1, a, c, b)
    print a, '->', c
    hanoi(n-1, b, a, c)

hanoi(3)