Monday, September 24, 2007


File I/O in Ruby

Ruby FAQ which seems to constantly move around and is currently not available (Google cache is though) has a very useful section 10.6 Should I feel uneasy if I don't close a file :
There are at least four good ways of ensuring that you do close a file:
  1. Use close (remembering to catch exceptions).
    f = open "file"
      f.each {|l| print l}
  2. Use the block form of open"file") do |f|
      f.readlines.each { |l| print l }
  3. Use foreach
    IO.foreach("file") {|l| print l}
  4. Use readlines.
    IO.readlines("file").each {|l| print l}


Friday, September 14, 2007


Copy DVD

Well, the next best thing after using gmplayer is copying (protected) DVDs. Number of good utilities exist under Windows, e.g. free DVD Decrypter and non-free but very good Magic DVD Ripper. Here we will cover what is available under Linux.

First, very good review, and only slightly outdated, is available in Gentoo Wiki. In fact, from all the tools mentioned there I only tried the simplest one: dvdbackup.

Here is what to do:

  1. Install libdvdcss ;
  2. Install libdvdread . Run configure command like that: ./configure --with-libdvdcss-libs=/usr/local/lib
  3. Get dvdbackup;
  4. Goto "src" subdirectory;
  5. (optional) Consider applying this patch;
  6. Compile dvdbackup like that: gcc -I/usr/local/include dvdbackup.c -o dvdbackup /usr/local/lib/libdvdread.a /usr/local/lib/libdvdcss.a -ldl (Note: linking does not work for some reason, but feel free to use
  7. Copy dvdbackup to /usr/local/bin or whatever
  8. Use like that:
    (to copy DVD)
    dvdbackup -v 4 -M -i /media/cdrecorder -o ~/mytopdir -n my_name
    (to get info)
    dvdbackup -i /media/cdrecorder -I
P.S. To use gmplayer to watch a movie dumped to hard drive use command like that:

gmplayer dvd://1 -dvd-device ~/mytopdir/my_name

Labels: , ,

This page is powered by Blogger. Isn't yours?