Archive for August 2009

Setting up OpenSSH public key authentication

First upload your public key to the server you want to log in:

scp .ssh/id_rsa.pub user@1.2.3.4:/home/user

On the server, add the public key file to the authorized_keys file:

cat id_rsa.pub >> .ssh/authorized_keys

Now you can login using public key authentication and you don’t have to enter a password anymore.

DNS query to find mail servers

To find which servers handle mail for a particular domain use dig:

# dig google.com MX
;; QUESTION SECTION:
;google.com.			IN	MX
 
;; ANSWER SECTION:
google.com.		561	IN	MX	100 google.com.s9a1.psmtp.com.
google.com.		561	IN	MX	100 google.com.s9a2.psmtp.com.
google.com.		561	IN	MX	10 smtp1.google.com.
google.com.		561	IN	MX	10 smtp2.google.com.
google.com.		561	IN	MX	10 smtp3.google.com.
google.com.		561	IN	MX	10 smtp4.google.com.

Show hidden files in Finder

To display hidden files in Finder type the following commands in the Terminal:

$ defaults write com.apple.finder AppleShowAllFiles TRUE
$ killall Finder

Add new packages to your MacTex installation

To add new packages to your Mactex installation follow these steps:

$ mkdir ~/Library/texmf/tex/latex/newpackage/
$ cp newpackage.sty ~/Library/texmf/tex/latex/newpackage/

That’s it. No need to re-index package list or something.

Snow Leopard (Mac OSX 10.6) is here

mac106buena Snow Leopard (Mac OSX 10.6) is here

Fix overfull problems when too many consecutive empty sections in Latex

I’m using Doxygen to document some C source code. This tool generates multiple sections in the Latex document (one for each variable). These sections are empty (i.e. they only have a title, no text). The problem is that Latex doesn’t automatically break the page when it should, and the section titles go beyond the margins (in fact many titles are not displayed at all).

To solve the issue add the following code to the document’s preamble:

1
2
3
\makeatletter
\renewcommand\@afterheading{}
\makeatother

Convert EPS files to PNG images

Doxygen generates collaboration diagrams in EPS format. If you want to include these graphics in a Latex document that produces PDF output, you have to convert them, for example, to PNG format. To make the conversion we’re going to use Convert. Convert provides image conversion between different formats and belongs to the ImageMagick suite of tools. Just navigate to the directory containing the EPS files and type this command:

for var in `ls|grep eps`;do convert $var ${var}.png;done

This produces PNG images with an .eps.png extension. If you want to leave just the png extension run this python script:

1
2
3
4
#!/usr/bin/python
import os
for fname in os.listdir(os.getcwd()):
        os.rename(fname, fname.replace('.eps.png','.png'))

Mac OSX Preview, merge, crop, delete, add blank PDF pages

To merge and/or remove PDF pages we need the sidebar so press the sidebar button (see first figure). You can switch from thumbnails to table of contents from the button located at the bottom right corner (see second figure).

preview1 Mac OSX Preview, merge, crop, delete, add blank PDF pages

preview2 Mac OSX Preview, merge, crop, delete, add blank PDF pages

Merge PDFs.

Open the first PDF and then just drag & drop the second PDF to the sidebar, between the pages where you want it to appear (see figure).

preview3 Mac OSX Preview, merge, crop, delete, add blank PDF pages

Delete a page.

Select the page you want to delete (in the sidebar) and type Command (The key with an apple) + Backspace.

Add a blank page.

Select Edit -> Insert Blank Page.

Crop an image or file.

First click the select tool. Then select an area of your document or image and hit Command + k.
preview4 Mac OSX Preview, merge, crop, delete, add blank PDF pages

Now you can save the cropped page or image with Command + s.

preview5 Mac OSX Preview, merge, crop, delete, add blank PDF pages