Schnippets

Python

#
#http://codeblog.dhananjaynene.com/2011/06/10-python-one-liners-to-impress-your-friends/
#
print map(lambda x: x * 2, range(1,11))

# Sieve of Eratosthenes
n = 50 # We want to find prime numbers between 2 and 50
print sorted(set(range(2,n+1)).difference(set((p * f) for p in range(2,int(n**0.5) + 2) for f in range(2,(n/p)+1))))

Bash

# convert to mp4
mkdir -p mp4
mkdir -p completed
for file in $@; do
    extension="${file##*.}"
    filename="${file%.*}"
    avconv -i ${file} -c:v libx264 -c:a copy mp4/${filename}.mp4
    mv ${file} completed/
done

# fix dangling symlinks
cd ~/bin; find . -xtype l | sed 's/\.\///' | xargs -i find /path/to/files/in/revisioncontrol -name {} | xargs -i ln -fs {} .

# sort files by last modified date
find . -type f -printf '%T@' -ls | sort | tail -n

LibreOffice Macro

Sub highlight
    Dim oActiveCell
    oActiveCell = ThisComponent.CurrentSelection
    oActiveCell.CellBackColor = 16777113
End Sub