Thursday, January 31, 2008

Sunday, January 27, 2008

PDF Viewer with Text Highlighting

Unfortunately xpdf, evince, acroread etc. cannot highlight text or add comments to PDFs. PDFedit cannot select text properly for many PDFs.

However, there is a nice and free alternative, but you need wine to run it: PDF-Xchange-Viewer. There's also a thread on this on the SuSE forum.

Update: Apparently with newer wine versions you don't need the script below anymore, since opening files out of the PDF-Xchange-Viewer works directly. Also see the comments below on this.

After installing the viewer, the following script handles file opening:

#!/bin/bash

# PDF-XChange-Viewer crashes wine when File->Open is used.
# Command line argument filenames work, though.
# However they may only point to files in the current working directory.

PDFXVIEWER="C:\Program Files\Tracker Software\PDF-XChange Viewer\pdf-viewer\PDFXCview.exe"

if (($# != 1)); then
echo "usage: $0 filename"
exit 1
fi

cd `dirname "$1"`
wine "$PDFXVIEWER" `basename "$1"`

Friday, January 18, 2008

create iso image

dd if=/dev/dvd of=image.iso

Tuesday, January 15, 2008

reset printer

cupsdisable hp1gray && cupsenable hp1gray

Monday, January 7, 2008

measure the width of a LaTeX savebox

\settowidth needs \usebox!

\newsavebox{\mybox}
\sbox{\mybox}{hello world!}
\newlength{\myboxlen}
\settowidth{\myboxlen}{\usebox{\mybox}}
\noindent
\rule{\myboxlen}{1pt}\\
\usebox{\mybox}
box size: \the\myboxlen.

advanced computations are possible using the calc package.

Sunday, January 6, 2008

vim C / C++ auto completion

Scripts (extract zip in ~/.vim)

Needs ctags:
sudo apt-get install exuberant-ctags

Use Ctrl-x Ctrl-o for C++ omni-completion.

My omnicppcomplete settings can be found here.

You need to add your tags file if it's not in the current working directory:
:set tags+=/path/to/my/tags

Thursday, January 3, 2008

rewrapping paragraphs in vim

taken from here:

If you ever edited text and still wanted to make your lines break at about 70 characters, you know it's sometimes needed to "rewrap" the lines to make them fill those 70 characters again.

VIM has the ideal solution for this. Select a block of text and press gq. Instant rewrap! This even "understands" basic things like dashed lists, indentation of a block of text, and even Usenet quotation marks like '>'.

To rewrap the current paragraph, press gq}. Since this is a bit tiresome, I remapped this to Ctrl-q in my ~/.vimrc:
map <C-q> {gq}