Sunday, 25 May 2008

Where is my GRUB?

On the Gentoo mailing list, a nice thread evolved a way to find where did you install your bootloader last time. The question is less trivial than it seems - is it on your disk MBR or on your partition? If you have a non-obvious setup, you may forget... and if you try to upgrade/reinstall GRUB without remembering where it is, bad things can happen.

The solution is:
for i in /dev/[hs]d*
dd if=$i bs=446 count=1 2>/dev/null | strings | grep -q GRUB \
&& echo "GRUB found in $i"

Saturday, 24 May 2008

The hacker's paperclip.

On Slashdot, I found a comment giving little, good tips on how to solve annoying hardware problems with a paperclip.

The power supply tester
Creation: Unbend a paperclip, and then bend it into a big U shape.

Usage: When you are unsure whether a PSU works (a) disconnect it from anything it is connected to (b) insert one leg of the U into the hole in the 20/24 pin motherboard power plug for the green wire (c) insert the other leg into a hole for a black wire (d) plug the PSU into power and turn it on.
If the fans spin up, then the PSU at least partially works. At this point you can use a multimeter to verify the voltages of the different rails with no load.

The CD ejector
Creation: Straighten a thick-gauge (strong) paperclip, and then put a loop in one end that is big enough to put your index finger through, at least to the first knuckle (this helps with gripping it during use).

Usage: When you need to eject a CD from a powered-down computer (laptop OR desktop), push the paperclip into the emergency eject hole. On a laptop, this requires very little force, but on a standard (5.25") Desktop CD-ROM drive, this will take quite a bit of effort.

The multipurpose grabber
Creation: Straighten a regular paperclip, and put a loop on the end, as you did for the CD Ejector. On the other end, put a 90 degree bend, 2mm from the tip.

Usage: You can use this tool to remove or move jumpers (very handy for IDE hard drives), and to remove stuck floppy disks from floppy drives (use the R/W hole or 1.44MB hole as an anchor point).
Credit must be due to beav007.

Monday, 12 May 2008

EPS files and pdflatex

There is this odd quirk in LaTeX. The latex executable compiles your .tex files in the old-fashioned DVI format. As such, it accepts by default only .eps (Encapsulated PostScript) images. pdflatex compiles your .tex files in the standard PDF format. For some mysterious quirk, pdflatex accepts raster formats like .png and .jpg , but does not accept .eps!

Sometimes you want the best of both worlds. An undergraduate of my lab, after some googling, found you can force pdflatex to insert .eps files happily:

1)Install texlive-extra packages, or any other package containing the epstopdf utility.

2) Insert the following code in your .tex file:

\newif\ifpdf
\ifx\pdfoutput\undefined
\pdffalse
\else
\pdfoutput=1
\pdftrue
\fi
\ifpdf
\usepackage{graphicx}
\usepackage{epstopdf}
\DeclareGraphicsRule{.eps}{pdf}{.pdf}{`epstopdf #1}
\pdfcompresslevel=9
\else
\usepackage{graphicx}
\fi

3) Compile using pdflatex with the -shell-escape command line option

It seems to work.

Sunday, 11 May 2008

Templates for CD jewel case cover in SVG - free

A quick useful link. If you need to do a CD jewel case cover and if you, like me, are an Inkscape addict, bookmark this link. These are beautiful templates for doing CD/DVD covers in SVG (Scalable Vector Graphics) format, free to download. Thanks to Kevin Deldycke for releasing them!

Saturday, 10 May 2008

Create a .tar.gz archive

Ok, this is admittedly really noobish. But it's something I always forget. While the tar -xzvf spell for unpacking archives is well known, only seldomly I need to create archives.

However, here's the magic:

tar -pczf name_of_archive.tar.gz /path/to/directory

That's more a reminder for me...

Thursday, 1 May 2008

Find and delete broken symlinks

The Gentoo guide to switch from tetex to texlive contains a little command line gem. It allows you to look for broken/dangling symbolic links and delete them interactively:


find /usr/bin -type l ! -xtype f ! -xtype d -ok rm -f {} \;