Friday, October 15, 2010

Rip audio from flv file

ffmpeg -i /path/to/file.flv -acodec mp3 -ac 2 -ab 128 -vn -y /path/to/file.mp3

Thursday, September 30, 2010

Mount an iso file in linux

mount -o loop /path/to/file.iso /mnt/iso

-o loop: specifies mounting the iso as a loopback device

/path/to/file.iso is the source file

/mnt/iso is the mount point on the filesystem

Make iso in linux

mkisofs -r -o /path/to/file.iso /path/to/directory/

all the files in the /path/to/directory/ will be made into a cd iso image at /path/to/file.iso

-r: preserves long filenames upto 31 characters
-o: output iso image

Thursday, June 10, 2010

fixing cgi newline character problem in vim

I recently had problems with a python "hello world" cgi script. Turns out, I originally wrote the file in a windows system and when I copied the cgi directory to a linux system, I encountered newline issues.

use cat -v /path/to/file.py to print the file to stdout exposing the newline characters.

in vim use

:set fileformat=unix

or

:set fileformat=dos

to write the correct newline characters when saving a cgi file.


Another way to remove the window$ style new line character is to execute the following bash script:
>find /code/cgi-bin/ -type f -iname '*.py' -exec dos2unix {} \;

/code/cgi-bin/ is the path to search
-type f is search for file
-iname is search by name, case insensitive (python files in this example)
-exec is execute the dos2unix program with the results from find being represented by the {}

Hope these tips help.