Because quick and dirty is fun!

In answer to this AskMe question, a quick one-liner works. Since I'm always forgetting the rudimentary perl I know, here it is for posterity:

curl \| perl -nle 'while(m/class="(\\S+)".\*href="([^"]\*)">(.\*)\\<\\/a/g){print "INSERT INTO foo \\(bar, baz\\) VALUES \\( \\"$1\\", \\"$3\\"\\);"}' \| mysql

Documenting some absurdity.

I realized I had never checked this page for validation, so I did. It didn't come close. Mostly this is because I'm lazy and mistype HTML and occasionally fail at regexps when doing search-and-replace, but even after fixing those the Youtube and Braek embeds were gratuitously invalid. After googling I found this method which isn't too bad, except no way was I going to do all that just to embed a stupid youtube video. Happilly I use blosxom which is delightfully modifiable and the fancyquotes extension which I've extended a bit to include this clause: :: } elsif ($block =~ /\/\w{8}/i || $block =~ /youtube\.com\/v\/([^&]+)/i ){ $new_body .= ' <script type="text/javascript">swfobject.registerObject("myFlashContent-'.$filename.'", "9.0.0");</script><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="484" height="392" id="myFlashContent-'.$filename.'"><param name="movie" value="'.$block.'"><!--[if !IE]>--><object type="application/x-shockwave-flash" data="'.$block.'" width="484" height="392"><!--<![endif]--><a href=""><img src="" alt="Get Adobe Flash player"></a> <!--[if !IE]>--></object><!--<![endif]--></object>'; Obviously I've added the appropriate js to the lib directory and added a header value for it, but it wasn't all that difficult actually. Right now it uses an id tagged with the filename of the source file but I really should add a sequential tag so there can be more than one embed per post. If only I could care.

dS/dt ≥ , Bitch

From The Entropy Law and the Economic Process, first published in 1971: [The fundamental limit of natural resources] also exposes the futility of the human pride that overcame some scholars on learning that by A.D. 2000 we may be able to feed people with proteins derived from crude oil and thus solve the population problem completely and forever. Highly probable though this conversion is, we can rest assured that sometime, perhaps sooner than one may think, man will have to reorient his technology in the opposite direction—to obtain gasoline from corn, if he will still be around and using internal combustion engines. In a different way than in the past, man will have to return to the idea that his existence is a free gift of the sun. (emph. mine) The best part about science? Being far more right than you ever suspected.

Fiction books to read

  1. Gravity's Rainbow. ~10% through.
  2. Permutation City by Greg Egan
  3. Daemon by Leinad Zeraus
  4. Spook Country by Gibson
  5. The Mote in God's Eye
  6. Footfall
  7. The Many-Colored Land, The Golden Torc, The Nonborn King, and The Adversary by Julian May

gPXE + AoE + gigE = XP - SATA

For a while I've been putting off building/buying a new desktop since my Shuttle died. I've been using an old Dell server as a "desktop" and it worked fine for my daily Linux stuff but it didn't have PCIe so I couldn't play TF2 or SupCom or anything. Good for working, bad for relaxing. Finally I begged/borrowed/stole enough parts to get a machine with my 7800GT up and running. (Aside, dropped the 2xSATA hard drives in and rebooted with not a single bit of hardware in common between the two machines, Arch picked everything up and every bit of functionality Just Worked. No hardware support in Linux my ass.)

Problem. This machine only has space/slots for 2 SATA drives and I run LVM2 over MD software raid in linux religiously, and I didn't leave a spare partition for Windows. I could get a PCI sata controller but that would involve spending money. And more importantly it would be sane.

Enter the insanity. I have Gigabit ethernet to the desktop, my server has enough space to handle a windows install and conveniently, gPXE lets you boot Windows XP from an AoE 'SAN'. This, terrifyingly, does work; I'm typing from it now. As a bonus I get my windows install on a multi-disk RAID without having to buy a raid card. Next step is to have the same install boot from VMware (though not at the same time obviously).

A couple of notes on what I found out doing this for real:

  • Have your network card's drivers ready. Use Intel Pro/1000 cards for sanity.
  • Use the gpxe:all-drivers lkrn if you have grub installed, otherwise start with the .iso and burn a cd. Space is cheaper than reboots when you guessed the driver wrong. Rom-O-Matic is your friend.
  • Don't bother if you don't have the ability to install windows for real on the first partition of a physical disk, getting the drivers into an existing XP install isn't worth it even if it is possible and editing the partition table to move a later partition forward is not fun unless you're a real MBR guru (sfdisk!).
  • The instructions say to use a file, but vblade can export an arbitrary block device, if I had free unallocated LVM space I'd make a LV and get cheap snapshotting in addition to RAID.
  • 4GB isn't enough. A fresh SP2 install basically fills it and I haven't investigated expanding the file, though it ought to be doable using the dd seek command as below. If I get annoyed enough I'll recreate it with a 10-15 GB LV/sparse disk which should be enough for Windows AND Steam.

To make a second (10GB) disk in the meantime I did (in gentoo):

#create a 10G sparse file
dd if=/dev/zero of=aoe_data.img bs=1 seek=10737418240 count=0
#add a vblade
echo "config_vblade1=\"0 1 eth1 /home/aoe_data.img\"" >> /etc/conf.d/vblade
#enable and start it
ln -s /etc/init.d/vblade.vblade0 /etc/init.d/vblade.vblade1
/etc/init.d/vblade.vblade1 start

On the windows side, first attach the disk (use the MAC of your server obviously).

aoe mount 00:DE:AD:BE:EF:00 0 1

Then you can go into Administrative Tools -> Computer Mangement -> Storage -> Disk Management (Local) (Don't have that menu item?) and find the disk that you just made. Note the label, it's Disk 8 on my machine. To be sure you can right-click to Properties and make sure it says "Location: AoE e0.1" or similar. Create a new Dynamic Disk volume (so you can expand it later if you want), format it NTFS and set the right drive letter. To make it come up on boot, I had to dig. Thanks to this and this you can do this (where 8 is the number of the "disk" in the local storage snap in (save as C:bring_e_online.txt maybe.):

select disk 8 online

Then regedit HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRun and add the value "C:mount_aoe_drive_e.bat", call it whatever you like. The contents are:

aoe mount 00:DE:AD:BE:EF:00 0 1 diskpart /s C:\bring_e_online.txt