Friday, November 28, 2008

Using Putty for Surfing the Web

I found this guide to be rather useful:

All I have to add is the following command line, that I've added to the startup menu:

"C:\PUTTY\PUTTY.EXE" -N -D 8080 -load profile

Surf away!

Friday, November 21, 2008

Sharing a CUPS-PDF Printer Over IPP

Generating PDF documents is easy enough on Window$: install PDFCreator and print from any application to the newly created PDF printer.

The same is possible on Linux using a CUPS-PDF printer. It's even easier if the source document is an document, because you can directly export it to PDF. Not to mention a lot of other applications that let you create PDF documents directly, or convert from most formats to PDF.

I recently needed to generate PDF documents on my VirtualBox hosted Window$ XP virtual PC. But instead of installing PDFCreator, it seemed to make more sense to "simply" print to the existing CUPS-PDF printer - it's just a matter of installing a new IPP printer at the Window$ side...

Start at the Linux box:
  1. point your browser to the local CUPS administration web interface: http://localhost:631
  2. click the Printers tab, scroll down until you find the PDF printer - write down its URL
And now for the main event, at a real or virtual Window$ XP box:
  1. open the Printers and Faxes folder
  2. from the menu select File->Add Printer
  3. click Next until the wizard asks you to choose between a local or network printer, select the network printer and click Next
  4. specify the printer with the URL recorded earlier, but replace localhost with the Linux box IP address, e.g.
    and click Next
  5. select a printer driver - in our case any Color PostScript printer should be OK
  6. a few more mouse clicks and we're done
At this point the newly created PDF printer can be used to generate PDF documents by printing to it from any application.

The documents will be created, by default, in the PDF directory at your Linux user account. If you're printing from a Window$ user account with a username that does not match any user account on the Linux box, then the generated PDF files will land in /var/spool/cups-pdf/ANONYMOUS/ (the paths can be configured by editing /etc/cups/cups-pdf.conf).

The problem with the procedure above is that the printer driver selected for the new printer does not match the capabilities and limitations of the CUPS-PDF printer. The Right ThingTM to do is to install a PostScript printer driver with the correct CUPS-PDF PPD file:
  1. copy the file CUPS-PDF.ppd from the Linux box (find it at /usr/share/ppd/cups-pdf/CUPS-PDF.ppd) to a temporary folder on the Window$ box
  2. download the Adobe PostScript Universal Printer Driver for Windows Installer
  3. launch the installer - a printer installation wizard will come up
  4. tell it that the printer to install is a Local Printer, connected to LPT1: or any other local port
  5. when prompted to select a printer model, click Browse and search for the PPD file
  6. you should now be able to select "Generic CUPS-PDF Printer" and continue
The new local printer is a fake one, that's used only to get the driver installed. The next step is to replace the IPP printer's driver with this new driver:
  1. open the Printers and Faxes folder
  2. right-click the IPP PDF printer icon, select "Properties" from the pop-up menu
  3. select the Advanced tab
  4. select "AdobePS Generic CUPS-PDFPRinter" from the Driver drop-down selection box
  5. click OK
  6. delete the fake local CUPS-PDF printer

I hope you realize by now that it's much simpler to install PDFCreator and be done with it, instead of all this futzing around with PPD files and all those printer installations and driver replacements.

Bottom line: sharing a CUPS-PDF printer is perfectly feasible, yet, at the same time, quite pointless.

Friday, November 14, 2008

All Line Are Busy!

I've exported an document (with .odt extension) to Microsoft Word format (.doc). I had a simple plan: to edit the exported document in MS Word on my VirtualBox hosted Window$ XP virtual PC. Nothing fancy, really.

There was one snag that had to fixed: fonts. The original document uses Bitstream Vera Sans TrueType fonts, which aren't installed on the Window$ PC. I could've switched to Tahoma, which look similar enough, but, being a perfectionist (read: obsessive-compulsive), I decided to install the fonts.

Should be easy, right? In principle, that's true:
  1. download the fonts and extract them to a temporary folder
  2. double click the Fonts control panel applet
  3. from the menu, select File->Install New Font...
  4. when prompted, find the temporary folder from step 1, and select all the fonts
  5. press OK and wait for the fonts installation to complete
But at the last step I got the following error message, no matter what I tried:
The font folder is busy and cannot install the selected fonts at this time. You may retry now or cancel and retry later.
Annoying as hell. What gives?

A quick search got me to a certain blog entry, which pointed me to Microsoft's TweakUI tool, available as a separate download on the PowerToys package page (search the downloads side bar at the right):
  1. install Tweak UI
  2. launch it
  3. use the mouse to select the "Repair" branch from the left side selection tree
  4. select "Repair Font Folder" from the drop-down selection box
  5. hit "Repair Now"
Good as new.

Sunday, November 2, 2008

One Liner: Determine Length of Video Clip in Seconds or Frames

Using mplayer you can extract all sorts of interesting details about your video clip:
mplayer -identify -frames 0 video.avi

which, among other stuff, pukes out lines looking like this:


In our case the important line is the one starting with ID_LENGTH, so that the complete one-liner is:
$ mplayer -identify -frames 0 video.avi 2>&1 | grep ID_LENGTH | sed s/ID_LENGTH=//

To extract the number of frames, you need to set the frame rate to one frame per second (stumbled upon this trick at Yahoo Answers):
$ mplayer -identify -fps 1 -frames 0 video.avi 2>&1 | grep ID_LENGTH | sed s/ID_LENGTH=//