Jim's Depository

this code is not yet written
 

On the Google Finance pages you can get graphs of stocks, which if you mess with the “settings” tab, you can also display after hours trading. After hours trading is generally much lower volume and less volatile compared to normal hours. 

Notice on the image that the 7 normal hours seem rather large compared to the 17 off hours. The X axis is a nonuniform time axis, during normal hours it is 12 pixels/hour (a very programmery value to pick) but the off hours are about 7.6 pixels/hour (not a very programmery value, but perhaps it is really 23 of 12).

The end result is a harmonious display but with greater resolution in the more important data. Very nice.

(The sample graph is from the day Steve Jobs announced his medical leave from AAPL. Usually after hours is quite boring.)

Attachments

goog.gif 28691 bytes

Web surfing with U-Verse was getting annoying. I was regularly getting pages that would mostly load, but were delayed from 5 to 20 or more seconds in rendering because some elements failed to load. Noticing that the worst pages were ones with large numbers of DNS names to resolve I swapped my U-Verse supplied DNS server for OpenDNS and things became much faster. (I since swapped that to my own local bind9 because OpenDNS kept hijacking my web sites, this is also fast.)

You can see on my “time to ping google” network check exactly where I changed DNS away from AT&T’s servers.

Odd points to ponder: the DNS for www.google.com has a 5 minute life, short enough to expire between tests, but you’d think have it in cache from other client use once in a while. There is an odd quantitization in the earlier data for which I have no explanation. The other ping test running at the same time, by IP directly, does not show this effect and does not show a change at the DNS change.

******Moral:** Don’t trust your ISP for anything but packets in and out, and suspect they will screw that up too.

Note: This may or may not affect your U-Verse. I suspect they have many DNS servers and perhaps they aren’t all lame, or perhaps they have a throttling policy or something and they are all lame. Only you will know.

Attachments

dsn-change.png 20340 bytes

Today I challenge Google. I have placed a pair of google ads in the right hand column. Let’s see if Google can figure out what my depository is about. If Google chooses a coherent category for ads, I’ll replace the page subtitle with their impression of this site.

So far I’m a little insulted. They are pushing… how to say without using the word… “spectacles to protect your vision organs”, and “graphic designers”. I don’t think they care for my look.

Ack! Google is giving me annoying animated graphic ads. I signed up for "text and image" ads, apparently they consider distracting animations to be an image.
Those google ads are nice. I almost never get enticed by an ad, but two of the google ads on this site have lured me into visiting the advertiser. (Google's terms forbid me from clicking, so I have to type in the URL.)

Virtually 100% of the writing on this site is mine, so they have their little demographic cross hairs right on my brain, and it works.

I find myself missing a flow of control construct in C. Let’s say I want to locate a value which might come from a number of sources then do something with it.

if ( code == 36) value = 99; else { // a bunch of code to see if it is in the cache if ( code_in_cache(code)) value = code_from_cache(code); else { // notice how each place I have to look is  //accumulating nesting?
… }
}

If I were willing to split the code into a separate function I could just use return e.g.

int gratuitous_function( int code) { if ( code == 36) return 99;
// a bunch of code to see if it is the cache
if ( code_in_cache(code)) return code_from_cache(code);
// notice how I am not accumulating nesting?

}

That is better, but I don’t like breaking the linear flow of the program and it is likely that the function will require access to many of my local variables making a complicated interface. Worse, I may be setting several values and that gets ugly.

I generally try to cope like this…

do {

if ( code == 36) { value = 99; break; }
// a bunch of code to see if it is in the cache
if ( code_in_cache(code)) {  value = code_from_cache(code);  break;  } // notice how I am not accumulating nesting? … } while(0);

That works fine until I locate the value inside a for loop, then the break will take it out of the for loop.

I think what I really want is a named block…

block foo {

if ( code == 36) { value = 99; break foo; }
// a bunch of code to see if it is in the cache
if ( code_in_cache(code)) {  value = code_from_cache(code);  break foo;  } // notice how I am not accumulating nesting? … }

I guess I could always be a barbarian just use a goto and a label.

Why not simply:

if (code == 36) {
   value = 99;
} else if (code_in_cache(code)) {
   value = code_from_cache(code);
} else if (...) {
   // Notice how there is no nesting?
}

Oh, I neglected the "// a bunch of code to see if it is in the cache" part.  Yeah, don't be afraid of using goto-s.  There's nothing wrong with them when used properly.
Yes, it is that bit of logic that makes the } else if { not work.

I installed SLOCCount today on my development machine. You can run it from one of your source directories like… sloccount *.[hc] … and it will tell you not only how many lines of code you have but what it may have cost to write them. So far I’ve written \$15k of code today. I can’t find the right command line option to get it to deposit that in my account.

Since I last wrote on the topic, Into the world of Virtual Hosting, I’ve split my server into two with this part being on a new virtual hosting operation. I chose RapidXen because it has IPv6 support, and is cheap. I’m using a 128M RAM/10G disk package for \$83/year, which is about the same as my 64M/2.5G package over at VPSLink.  

  • The RAM change is a little deceptive, the RapidXen box is a 64 bit machine, so a good part of the extra RAM just goes to cover that bloat.
  • The RapidXen machine is many times faster.
  • The VPSLink machine has become much slower as time has gone on. I can’t tell if they are loading the machine more heavily, or if some IO pig has moved into my server, but life is not as good as it used to be.
  • RapidXen is a smaller operation, I had to wait for a human during the setup.
  • My IPv4 address at RapidXen was pre-blocked as a spam source by AT&T, but no other black lists I could find. Sometime worth checking when you get a recycled IP.
  • You apparently have to open a trouble ticket and ask for console access to your server at RapidXen, I haven’t completed that yet. At VPSLink it is available by default with a Java based SSH client.

One person regularly corresponds with me using Hotmail. I’m frequently amused at the odd non-sequiturs at the end of his sometimes delicate email.

Lately though, the Hotmail graffiti ads don’t even make sense.

For example:

Send e-mail anywhere. No map, no compass. Get your Hotmail account now.

Because I need maps and a compass to use gmail? My Safari icon is a compass, should I not use Safari for Hotmail? Or is it a reference to paper mail where I used a map and a compass to post letters? 

Or perhaps:

Send e-mail faster without improving your typing skills. Get your Hotmail account now.

Faster? My bits already move at about light speed, that can’t be it. Perhaps the delay between pressing SEND and when it leaves the sending computer could be a few milliseconds shorter. How many people sit down to deliberately improve their typing speed so they can send email faster? Who, other than spammers, even cares how fast they send email?

Bus error - founder dumped

That was a nice sixteen years.

I needed a machine to do some DNS server tests. I settled on a \$280 EEE PC 900A (stripped of webcam and half of its storage) from Best Buy. That gets me a 1.6GHz x86 server with 1G of ram that only burns 10 watts and comes with its own little console for when I need it. Not a bad deal. 

Only 4G of storage, but I’m only using about 60% even with a bunch of heavy eyecandy gnome and compiz stuff I installed to see what would happen (it is pretty fast, lower end graphic accelerator, but not many pixels comes out well).

I wiped the friendly linux it came with and installed Debian Lenny and all is good, except I kept noticing intermittent disk hangs lasting several seconds. I think I finally tracked this down to the kernel syncing out written pages. The fix is to not write so much. By mounting the partitions noatime most of my writes go away and I don’t notice hangs anymore.

Reading the first byte of every file in /usr went from 131 seconds to 92 seconds with the change (after a fresh boot each time), that is about a 30% speedup.

I’m pleased with the EEE. My code builds from clean in 1.6 seconds. I rarely use more than 10% of the RAM doing development which leaves plenty of RAM for caches to mitigate the slow flash disk. 

At last, I can put my /boot partition in LVM.

  • Get the Debian box up to Lenny.
  • Note that I accidentally trashed my MBR and had to boot into rescue mode while working out these steps. You shouldn’t do this if you follow all of the instructions, but you ought to have media handy.
  • aptitude install grub-pc (Note: this will remove the old grub package and offer to chain load grub2 from your existing grub. Do this. If you have problems you can still boot.)
  • Verify you can reboot.
  • Remove the old grub MBR and put in the grub2 one with upgrade-from-grub-legacy
  • Hide your /boot/grub/menu.lst so you aren’t tempted to edit it.
  • Your basic configuration, like kernel command line parameters is now in /etc/defaults/grub, there is also /etc/grub.d/* which I hope to never touch.
  • Move your /boot into the LVM. You could tar up your /boot partition, unmount it, and extract it onto the root partition. You could also make a new LVM managed /boot if you like it on its own partition. I was out of space in the volume groups, so I went with /. If you didn’t make a new /boot, remember to take /boot out of /etc/fstab.
  • dd zeros onto your old boot partition to make sure you aren’t deluding yourself.
  • Edit /etc/defaults/grub to add GRUB_PRELOAD_MODULES=lvm
  • Go back and make certain you did the previous step. I made an unbootable system before I learned that little tidbit.
  • Do an update-grub and a grub-install /dev/sda or whatever your disk is.
  • Go back and make sure you did the grub-install… Just update-grub is not enough to pick up the lvm module.
  • Reboot and rejoice.

I am left wondering what silliness lead to GRUB-2 being version 1.96, but I am happy.

You saved me many (more) hours of head pounding with this blog entry.  I am thoroughly grateful.

At some point in the past I managed to screw up my file server's lenny install in such a way that I ended up with the non-lvm ext2 boot partition commented out of fstab and a separate /boot directory on the lvm root.

I forgot about this incident and went about continuing to run apt-get dist-upgrade periodically.  Everything worked until I went to squeeze and rebooted, at which point I made some more poor choices ("Why am I not running the new kernel?  I'll just apt-get remove the old one!") and ended up unable to mount ext2 partitions (while still able to boot from one).

After about eight hours of head scratching I found this page and by following your steps had no trouble upgrading to GRUB 2 which booted the new kernel which fixed all the problems, allowing me to get on with my life (such as it is).

You are awesome and so is GRUB 2.

You should note that grub-pc for lenny is missing part_msdos.mod and will not install, you need to fetch it from backports to get the file.

Thanks for the info though, it helped me to confirm what I was doing would work before I sent a remote machine through a reboot (I know, dangeous, but couldn't be helped)
I have been trying to do this for 3 whole days and I finally found this post by accident. I have tried to do this with Arch Linux and Fedora and had no success. Even Google yielded no answers until I tried "Debian grub2 lvm /boot" and found this. Even though this is not written for squeeze I managed to take the bottom half and make this work. I even went as far as asking on 2 forums and in IRC channels for multiple OS's, even bugged some friends and got the usual "why would you want to do that?". Sir, I cannot thank you enough. Looks like I'm a Debian user now thanks to blogs like this.
Debian Squeeze, VirtualBox 4.0 from backports.

Debian 6.0.4 installer .iso

6 virtual disk devices
-> one physical raid partition per device
-> one RAID6 md0

One physical volume group
logical volume /
logical volume /home

The system does not manage to boot even after going in into the rescue mode and making sure grub is both configured and installed with the lvm module preloading (/etc/default/grub -> update-grub -> grub-install).

It all trips up in grub-pc (GRUB2) somehow and I do not know how to debug it.

GRUB loading.
Welcome to GRUB!

error: file not found.
Entering rescue mode...
grub rescue>


Any pointers? Did I miss and mess up any of the rescue mode superhero stuff?
I tried to wave a rubber chicken and just throw every plausibly connected module at it, but it's still a no-go.

I've seen some indirect talk about mdraid + LVM + EXT4 not being a bootable combo yet, but then again I've seen people boast about their mdraid + dmcrypt + LVM + EXT4 / BTRFS setups.

I guess I will just fall back to a good old fashioned EXT2 boot partition.

Here's my rubber chicken waving approach for the internet:

GRUB_PRELOAD_MODULES="search_fs_uuid raid raid5rec raid6rec mdraid lvm ext2 chain pci"

update-grub

grub-install --modules="search_fs_uuid raid raid5rec raid6rec mdraid lvm ext2 chain pci" /dev/sda
more articles