# Older blog entries for pedro (starting at number 73)

Unintentionally funny DVR episode synopses #243

"Property Virgins. 'A Woman Who Survived a Lightning Strike Is Shocked by Real Estate Prices' Home prices shock a lightning-strike survivor."

Syndicated 2011-04-18 02:37:41 from (l)andscape: (a)lien

random thought

Hardware is just software you can't change.

Syndicated 2011-04-13 20:28:38 from (l)andscape: (a)lien

how to slice a sandwich

What's your preferred sandwich slicing angle? Vertical (shortest cut), Diagonal (longest cut), or Horizontal (medium cut)?

I have always been a diagonal cut man, myself. That's how mom did it. I don't like the way vertical cut sandwiches taste. But currently, I'm more interested in whether *anyone* does the horizontal cut... I don't think I've ever seen that outside of the laboratory.

Perhaps geometry is at work here. Diagonal ...cut sandwiches represent right triangles, which are pretty cool -- arguably more important than parallelograms, since parallelograms can be made from triangles. And of course, 3 is the magic number.

But also, notice that the golden ratio of 1:1.62 appears in vertical cut sandwiches, but does not appear in horizontal cut sandwiches. In our experiments here at Tastytronic Labs, our sample bread measures about 5.25 by 4.25 inches (the units of the United States of America!).

A vertical cut sandwich is roughly 2.63 x 4.25 inches, while a horizontal cut (known as "the devil's cut" in medieval times) results in a sandwich that is ~2.13 x 3.44. By applying the golden ratio (1:1.62) to 2.63 (vertical cut sandwich width), we get 4.26 -- almost exactly the vertical cut length. However, applying it to 2.13 (horizontal cut sandwich slice width) we only get 3.45 -- considerably less than the horizontal cut slice length.

And thus we find a possible explanation for why the "horizontal cut" is so rare. It's at least safe to say that Aristotle's mom did not cut sandwiches horizontally.

Syndicated 2011-04-05 19:22:49 from (l)andscape: (a)lien

libconfig problems in Debian and Ubuntu

Are you still using Hardy Heron? Have you had issues using libconfig -- a configuration parsing library by Mark Lindner -- in Debian or Ubuntu? Here's why. Turns out this has been solved in later releases.

Syndicated 2011-04-02 21:58:59 from (l)andscape: (a)lien

getopts -- another one for posterity

Just a little addition to posterity about getopts. 'getopts' is a handy bash builtin that parses parameter strings. It exists so parameters can be processed in a consistent way, and so you don't have to reinvent the wheel every time you want to use command line switches. It's part of POSIX, is really pretty easy to use, and many languages have libraries which work in a similar way. Anyway, there are many tutorials online, but the one at bash-hackers.org is the best I've seen for bash.

I was inspired to write this post because I've been wrestling with a problem. I used getopts inside a function that I was using for logging. It just wasn't working right and the behavior was strange. The answer, which perhaps should have been obvious in retrospect, is that getopts uses a variable, OPTIND, to index into the parameter list. You can use OPTIND to "shift off" the options you found with getopts, leaving the remainder.

This works great if you run getopts once, at the beginning of a script. But because of bash's scoping, if you use getopts inside a function, the value of OPTIND remains where it was left at the end of the previous getopts execution. So, if you're going to use getopts inside a function, you should reset OPTIND when finished or, to be safe, at the beginning of the function before running getopts.

I'm so glad I spent a few hours chasing that one down.

Syndicated 2011-03-11 18:32:26 from (l)andscape: (a)lien

mairix rocks

If you're like me, and if you're reading this there's at least a possibility you are, you don't keep your email at Gmail or in Thunderbird of Mail.app or wherever -- you keep it the way Ray Tomlinson intended -- on a server where you read it in plain text format. I use mutt with mboxes, but there are a lot of other possibilities. Anyway, after 10 or 20 (or more!) years of archiving your mail, it sometimes gets hard to find what you're looking for. Well, mairix is just the tool for you -- it incrementally indexes messages, and returns search results as a folder of messages for you to look it. It's free software, it's fast, and available in Ubuntu.

Syndicated 2011-02-09 23:09:24 from (l)andscape: (a)lien

ah, time for my yearly smattering of blog posts

Annnnnnnnnnd we're back.

Today's hot tip:

@filearray = <FILE>;

...is a bad idea if <FILE> is rilly large!

Thank you good night.

Syndicated 2010-10-30 04:00:40 from (l)andscape: (a)lien

disabling the caches in Linux

Sometimes you'd like to disable the file (and other caches) in Linux for performance testing reasons. Well, now you can. Simply:

To drop pagecache only, enter: echo 1 > /proc/sys/vm/drop_caches

2 is dentries and inodes only, and 3 is pagecache, dentries, and inodes. You can easily whip together a little script to drop caches regularly enough to simulate running with no caches.

(This information is also under "drop_caches" in linux/Documentation/filesystems/proc.txt.)

Syndicated 2009-09-12 16:19:34 from (l)andscape: (a)lien

"You wouldn't like me when I'm angry..." OR "Dr. Jekyll and Jiminy Cricket"

I'm a collector of odd facts. I remember hearing this one some time ago, about how grasshoppers morph into brutal locusts under certain conditions but I find that often the "facts" you hear word of mouth aren't always factual. (Unfortunately, a lot of facts in those 1001 Fascinating Fact books are often wrong too... I've thought of writing a 1001 Fascinating Falsehoods [you thought were facts!], but I'll just have to add that to my to do list.)

Anyway, it's true!. I guess grasshoppers are the poster-insect for serotonin induced mania.

Syndicated 2009-07-26 15:43:17 from (l)andscape: (a)lien

remote administration in the post-onboard-serial era

Please Don't Take Away My Serial Port!:

I've been dismayed lately at the lack of serial ports on COTS desktop PCs. I understand eliminating things like parallel ports, game ports, even audio line in... but serial ports are special... and expansion devices are not as good as on-board hardware.

If you ever end up using the PC as a server that you have to administer remotely, you may need a serial console so you can see what's going on at boot time, or to manually select a kernel in the bootloader -- say if your testing kernel fails. When most people need a serial port on a serial-less machine (e.g., to access the serial port on a router from a laptop) they get a serial expansion card or a USB serial dongle. It seems like this should work. But don't count on it.

grub and expansion devices:

Expansion serial ports are barely passable as a solution for Linux/grub users -- and in my opinion are not acceptable for real production systems. In particular, the bootloader and kernel will not be able to send output to expansion devices until after the hardware has been properly recognized and the bootloader or kernel is prepared to handle it. During the time prior to initialization of each system (early in the bootloader and early in the kernel startup sequence), you'll be flying blind.

However, grub does not understand USB *anyway*, so unless you are lucky enough to have a BIOS which supports USB serial ports as native devices (like it does for keyboards and mice), your USB dongle will not allow you to control your bootloader. Period. This is because making a USB serial port work requires a functional USB subsystem, which is more than a bootloader is supposed to handle. As of now, it's not clear if or when grub will support USB. So laptops are screwed.

But a desktop machine can us a PCI card, right? You'd like to think that, wouldn't you? Unfortunately, grub only knows the standard IO ports (memory addresses and IRQs) for COM 1-4 (units 0-3 in grub parlance) -- which means if your PCI serial card appears at a different address, grub will not be able to use it. There is code in the pipe for PCI expansion serial ports in grub, but I'm not sure of its status. It doesn't work in my Hardy Heron Ubuntu, although I'm hopeful that this will work reliably in the future. (If so, then PCI cards could be a good solution for "desktop" PCs.)

The Linux Kernel and Expansion Devices:

OK, so grub support is thin. How about the kernel?

The outlook is better here, inasmuch as there is some hope. The kernel has driver software for using these devices, but again, until your device is initialized, you won't see anything. Getting it initialized early enough to use as a console may require you to use a ramdisk to boot. While most distros already do this, there are valid reasons for wanting to avoid using a ramdisk. Too bad.

If you don't mind using a ramdisk, it may work if you're using a stock kernel and your devices are common enough. If they're uncommon, you may be required to compile alternative drivers into a custom ramdisk, including extra USB stuff. Building custom ramdisks for your hardware is never as simple as it should be, and is a ticking time bomb for maintenance. At some point, the update path will change, you'll get a new kernel but the ramdisk won't be properly modified, you reboot, and suddenly you don't have a console anymore.

But let's say you go this way (out of necessity or because you feel a need for more stress in your life) and you get the ramdisk set up with appropriate drivers for your devices. Now that the kernel can see your hardware, you need to create the appropriate devices. In the old days, that meant creating a physical device and setting permissions on it. But nowadays, devices are created automagically. This is a good thing in general, but it can also be a pain when you only have to fiddle with it every two years.

Anyway, you'll have to monkey around to get your event system (e.g., udev or the older hotplug or what have you) to set up the devices for you properly, including proper permissions. You'll also have to add inittab or event.d rules to start a getty process on the new port if you want a terminal on the console and add rules in securetty if you want to log in as root. Many HOWTOs covering this information are online.

Short version: Expansion COM ports are flaky PITAs. If your computer just had a single built in COM port, it would be easy-peasy, stable and un-cheesy. (Hey HW guys, if you're listening, a serial device could just be an on-board device with bare pins and we can add a ribbon cable if we need it! Everybody wins!)

There is some good news, however. If you can get grub installed, you can make temporary kernel selections before reboot -- without modifying your menu.lst file. The basic idea is that you set up a "fallback" priority for the kernels and then temporarily select your testing kernel as a "one time boot" using the command grub-set-default. Ok -- things are looking brighter. But what if your kernel panics? Now it's hung. Ah, but you can make Linux reboot upon panic by adding the line "kernel.panic = 15" to /etc/sysctl.conf. (Before it panics!)

... But You Still Want That Smart Power Strip:

Of course, if your kernel deadlocks, you're screwed. The kernel's so hung it can't even reboot itself. Time to use that Linux-friendly IP-enabled power strip you've been meaning to buy for a while. I found the above device being sold under a different label on eBay. The interface isn't the best, but it works, it doesn't require any special software, it has four independent outlets, and it's relatively cheap.

Now, if your machine goes dark when you're remotely testing that bleeding edge kernel, just reboot it! If the disk isn't scrogged, it will happily fall back to the known good kernel and you're golden!

Syndicated 2009-07-20 03:41:53 from (l)andscape: (a)lien

64 older entries...