Archive
Play the first 30 seconds of a song with mplayer
mplayer -endpos 00:00:30 song.mp3
I have an alarm script that loads a bunch of MP3s and starts playing them in random order in the morning. However, some songs are very long, some of them are boring, etc. So I prefer playing just the first X seconds of each song.
This tip is from here.
Enable insults in sudo
When you use sudo and you mistype your password, you can receive some insults :) Here is how to activate it:
sudo vi /etc/sudoers- find the line that starts with “
Defaults” and append “insults” to the end of the line. Mine looks like this: “Defaults env_reset,insults” (without quotes, of course).
If you want to test it, just mistype your sudo password. Have fun :)
This entry is based on this post.
Get the public Dropbox links of several files
Problem
When you install Dropbox, you get a Public directory. It has the advantage that if you put a file in it, you can get a public http:// link on it, thus sharing files with your friends is very easy. To get the public link, just navigate to the file in Nautilus, right click on the file, then Dropbox -> Copy Public Link.
However, if you want to share several files, getting their public links via Nautilus can be a PITA. How to get the public links for all the files in the current directory?
Solution
I made a simple Python script for this task. It can show the public link of (1) one file, or (2) all files in the current directory.
Usage:
$ get_public_link share.zip http://dl.dropbox.com/u/XXXXXX/share.zip
$ get_public_link -a http://dl.dropbox.com/u/XXXXXX/share/movie.r01 http://dl.dropbox.com/u/XXXXXX/share/movie.r02 http://dl.dropbox.com/u/XXXXXX/share/movie.rar
If you want to copy the links to the clipboard, combine it with my tocb script:
$ get_public_link share.zip | tocb
Download
The script (together with tocb.py) is available here, in the dropbox/ folder.

Remove comments from a LaTeX file
Problem
I had to remove all the comments from a LaTeX file.
Solution
LaTeX comments start with ‘
%‘. It was enough to remove comments that start at the beginning of a line.(Yeah, I know, it’s two processes, but I prefer like this…)
Generalization
If your comments start with ‘
#‘, use “cat file | grep -v ^#“.