Archive for March 2008

Do What I Mean and Not What I Say!

If you posted a comment recently and don’t see it on the blog, I apologize. I managed to accidentally delete some when going through comments to approve them. If you wouldn’t mind, please repost them, as most had very good content relevant to their respective posts. Thanks!

Dual-Booting XP and Kubuntu on a Sony Vaio

So it turns out the Holy Grail, Promised Land, or whatever you want to call it, does exist after all. After a number of different approaches and attempts, I finally got my Sony Vaio VGN-NR298E dual-booting Kubuntu and Windows XP. The solution turned out to be a well-known one: nLite.

With it, I was able to not only roll the drivers for my SATA drive into a custom XP CD, but also SP2 as well. It also offers options to include other drivers as well as post-SP2 Windows hotfixes and custom configuration options. I have to give major kudos to the nLite folks, as I imagine I would have given up at attempting to do this had it not worked as splendidly as it did.

So, without further ado, here’s the final recipe for succes in this endeavor. Obligatory disclaimer: I take no responsibility should you not have the same success or suffer damages by following these instructions. Other obligatory disclaimer: The only reason I went to this much trouble to dual-boot to XP is because I can’t find another solution that allows me to play my games.

  1. Download nLite. Use it to make a local copy your Windows XP CD.
  2. Download the standalone Service Pack 2 installer. Point nLite to it as a service pack to include.
  3. Download the Intel 82801HEM/HBM SATA AHCI Controller driversExtract them for unattended installation and point nLite to them.
  4. At this point, you can choose other drivers to include on the CD. Below is a list of those that are relevant to the Vaio. Be sure to have either Ethernet or Wifi drivers included in the CD or on a storage medium that Windows can recognize natively without external drivers.
  5. I ran into a small issue at this point that may or may not be pertinent to your case: the only machine on which I had a CD burner available was a Linux server machine. nLite was helpful in this regard, though, and offered an option to make the ISO file it created mkisofs-compatible. Using this, I was able to copy the ISO over the network to the Linux server, use mkisofs to test it and cdrecord (man page examples on this utility are helpful) to burn it.
  6. Boot the custom CD. Note that you no longer have to hit F6 at the point where you normally would to install custom drivers; the installer will simply detect that they’re available on the CD and load them from there. Installation should be pretty normal after this point. Partition your drive however you like, being sure to leave enough room for Kubuntu to load. You’ll probably notice the installer forces you to leave 8 MB free, presumably for the NT boot loader. Once you’re in Windows, you can reset your screen resolution and manually install any drivers you didn’t roll into the CD. Once you’re connected, install any further Windows updates that might be necessary.
  7. Once XP is set up to your liking, pop the Kubuntu CD in, boot from it, and access the installer on the desktop once KDE has loaded. In order to not have Kubuntu overwrite your XP installation, you’ll have to opt to partition manually. You’ll notice that the installer sees the 8 MB that XP made you reserve earlier. I’m not sure why, but the installer sees this as free space. At any rate, I just consolidated that space into the Kubuntu partition and let it set aside its 3 MB to load GRUB. I’m not sure how to keep the NT boot loader and not load GRUB, so if you prefer that route, you’ll have to dig around on your own to find out how. Set up your root and swap partitions and continue.
  8. Installation should again proceed fairly normally. Once you’ve loaded your installation for the first time, connect your machine to an ethernet cable and launch Adept, the package manager GUI for Kubuntu. Do a search for Windows and you should find a package called Windows Wireless Drivers. Install this for wireless if you need it. Beyond that, install updates and you should be good to go.

And that’s all there is to it, folks. It was a wild ride to figuring out the process, so I hope my efforts help someone else looking to do the same thing. Cheers!

Watch Your Include Path

It’s pretty rare that I encounter a bug in the software I run that hampers my ability to work or my server environment’s ability to function normally. However, I encountered one last week that has taken me and several Rackspace support technicians nearly a week to figure out, namely PHP bug #43677.

The bug is in at least PHP 5.2.5, if not in previous releases in the 5.2.x branch. For the moment, we’ve downgraded the PHP installation to RHEL version 5.1.6, which I’m told includes backports of relevant bug fixes from the 5.2.x branch, to see if that doesn’t stabilize the situation.

So, if it seems that PHP starts to “forget” your include_path setting, your issue may be with PHP and not Apache as I initially suspected since the include_path setting was being set via an Apache configuration file. Hope this saves someone else time and grief.

More Kubuntu Developments

I finally figured out how to control the monitor brightness via this forum thread using the xbacklight command. I’m really happy for that, because it was a bit of a strain on my eyes and I couldn’t find a way to do it through the desktop manager. One other nice point about the forum thread is that it also walks you through how to execute this command automatically when battery power kicks in.

Kubuntu doesn’t install it by default, but if you search Adept for ndiswrapper, you should get an option to install Windows WiFi Drivers. This includes drivers for the Intel PRO/Wireless 4965 AG/AGN card, and once installed, it worked without requiring me to track down and install drivers manually.

I wanted to see if some of my games would work under Kubuntu. I tried Wine, but wasn’t able to get it to run Warcraft III without crashing immediately after selecting the play option from the splash screen. Apparently the supporting libraries for my particular graphics card (Intel 965 chipset) are fairly buggy when it comes to hardware acceleration.

I also attempted to install VMware in order to run the game in a virtual machine, but that was a dead end as well: the game won’t run with the display drivers provided by VMware tools and that it’s not possible to install the host machine’s drivers and have them work correctly. Incidentally, this forum thread provided some feedback about how to remove a partial installation so that aptitude will allow you to do a reinstallation. sudo dpkg –purge –force-remove-reinstreq vmware-server ended up doing the job.

So, as much as I hated the idea of having to go back to Windows, I set out to configure my system to dual-boot. Small problem: I have a SATA drive, which requires special drivers that Hitachi claims can only be installed via a floppy drive. My laptop doesn’t have one, and I’m not overly inclined to purchase an external one just to install XP.

My friend Jeff Jones pointed me to a forum thread detailing how to integrate the SATA drivers as well as Service Pack 2 into a custom XP CD. Since I didn’t have another existing XP installation, I had to use a VMware machine. It took some digging to find the Intel 82801HEM/HBM SATA AHCI Controller drivers and how to extract them for unattended installation. I used XP-ISO-Builder to create a custom ISO image and  DeepBurner Free to burn it to CD.

In attempting to boot with the CD, though, I got as far as being prompted to install the drivers before being presented with the error “The file iaStor.sys is corrupted.” Setup wouldn’t proceed any further, so I gave up on it for now. If you have any experience with a working solution rolling SATA drivers into a custom XP CD, I’d be interested to know. Feel free to leave a comment on this blog entry.

Kubuntu + Vaio = Nice

So the tax return ended up coming in around my birthday. Since it had been a long while since I’d gotten an upgrade, I decided to treat myself to a new Sony Vaio VGN-NR298E. The first order of business once I got it, of couse, was to wipe it clean of Windows Vista. Not having ever settled on a Linux distro of preference before, I decided to give Kubuntu 7.10 a try.

After installing and booting up for the first time, I found that the wireless didn’t work right out of the box. I was able to find this forum thread, which included a link to the Intel PRO/Wireless 4965 AG/AGN network card drivers in the section marked “Wlan.” I installed ndiswrapper-common and ndiswrapper-utils-1.9, the latter of which appeared to include a version of the netw4x32 driver. However, when I issued the command ndiswrapper -l, it indicated that the driver was invalid. I removed it with ndiswrapper -r netw4x32, then downloaded the latest version from the aforementioned link and installed it as per the forum thread’s directions.

I also needed a solution to allow me to manage the music and files on my Creative Zen Vision: W. I’d had great experiences with their MuVo line, but I have to say that the experience with the Zen hasn’t been nearly as good. Creative has extremely subpar Windows-only software for interacting with the hardware, the design of which was obviously intended to keep third parties from developing their own software.

Oddly enough, I’d never heard of this before, but Gnomad2 was quite the excellent solution for my situation. It’s a simple program with an FTP client-like interface for transferring music and files to and from the Zen. If you enable the universe and multiverse repositories, you should be able to find it by searching Adept.

I also ran into the reputable difficulties with the keyboard function keys. The volume function keys will only let me toggle the volume up and down a single level relative to its current level. The brightness keys don’t work at all, which is annoying as I end up missing the feature that worked fine on my old Dell Inspiron 1150. I’ve tried a few suggested solutions for getting these to work, but no luck so far. Any feedback on this is welcome.

I couldn’t adjust myself to Konqueror as it felt like an unfamiliar, slow, and crippled version of Firefox. I ended up installing that along with the Flash Player add-on for it and my usual group of extensions. I also found the default installation lacking a program capable of playing some video formats, so I installed VLC (also available from Adept).

Overall, though, I think I’m liking Kubuntu. Hopefully Lorna Jane will be able to help me get further accustomed to it.

IE6 Compatibility Testing via Virtualization

In my last entry, I noted that I was testing my use of SWFUpload in both IE6 and IE7. You may wonder how I managed this. Google has plenty of information on “hack” methods to get both versions of IE to coexist on a single XP installation.

If you have the machine power for it, though, there is a method that is actually supported by Microsoft to accomplish this. It employs virtualization which is becoming increasingly popular in the computing world. It is useful for two particular applications: to make server environment installations independent of the host operating system and hardware and to allow multiple operating systems to coexist on the same hardware without the need for partitioning storage devices.

In 2003, Microsoft bought out a company called Connectix which specialized in virtualization software, one of their main products being Virtual PC. Microsoft subsequently released a rebranded version of VPC as a free download.

Once the need to test applications on IE6 and IE7 for cross-compatibility was realized, Microsoft also began sporadically releasing a freely downloadable series of up-to-date Windows XP images with IE6 pre-installed and expiration dates after which the images would no longer function. The latest image is set to expire in early June 2008.

With Microsoft pushing adoption of Windows Vista and IE7, it’s uncertain as to whether or not Microsoft will continue releasing these VPC images. However, it does appear that Microsoft plans to continue developing Virtual PC. Therefore, if you have an extra Windows XP license to spare, this arrangement is a nice and relatively lightweight solution to making IE6 and IE7 available for testing on the same machine.

More SWFUpload

So I ran into a little issue with SWFUpload. The user reporting the issue was using the latest version of IE6 on Windows XP. When they clicked a button set to call selectFiles on the SWFUpload instance in use, IE would display a JavaScript error stating something to the effect of, “Exception thrown and not caught.” When I actually checked the contents of the exception instance, the actual problem was reported as “Invalid function name.”

Working my way backward through the chain of execution, I could see that IE recognized selectFiles. At this point, I thought to check the Adobe Flash Player version to ensure that it matched the version of the SWFUpload Flash component that I was running. Sure enough, it was outdated. Once I installed version 9 and restarted IE, everything worked as expected.

I haven’t tried this on IE7 under a pre-9 Flash Player version (and in fact I’m not entirely certain you can get an older version of Flash Player that will run under IE7), so this may or may not also be possible under IE7 as well as IE6. If you want to test for the issue, simply catch any exception thrown when called selectFiles and alert the user accordingly.

How-To (and How-Not-To) on Web Scraping

A friend of mine who shall remain nameless pointed a post out to me on the PHP DZone web site recently. Noting that the article’s content was misinformed at best and downright ignorant at worst, even when examining it sheerly from the author’s knowledge of PHP as a language, this friend asked that I set the author straight.

I gladly obliged with a comment on the post, having become somewhat of an authority on the application topic myself. As much of an unorthodox practice as web scraping may be, there are some methodologies for it that are obviously better than others. The aforementioned post illustrates a lot of the ones to avoid, and my arguments against them.

Later, I randomly encountered a post on the blog at xml.lt on the topic of web scraping using the DOM extension. This article showcases recommended practices and reasoned arguments against bad (and unfortunately common) alternatives. The author comes across as being significantly more informed on both the language and the application in the article’s content and code examples.

If you’re looking for references on topic of web scraping with PHP, there’s always the article I wrote for the December 2007 issue of php|architect magazine, of which you can still purchase an electronic copy in PDF format. At some point, I also hope to write a short book on the subject. Until then, if you have related questions, you can generally reach me in the #phpc channel on Freenode, under the nick Elazar. I’m always glad to give out advice on web scraping and PHP, as I’m sure my good friend Jared Folkins (who is also my “Little Sis” from the PHPWomen Big Sis/Little Sis mentoring program) will attest.

Graphs and Relational Databases

Situations involving hierarchical data and relational databases are quite common in web applications. Trees lend themselves quite well to providing organizational structures a web site, such as sitemaps and breadcrumb trails. A slightly less common and different type of situation, where the application is just as useful and a solution is a bit more complex to derive, is one involving graphical data (as in graphs, not graphics) and relational databases. These situations have issues like the shortest path problem and find their solutions in graph theory such as the A* algorithm or Dijkstra’s algorithm. An example of such a situation is an airline web site that requires the ability to locate connecting and round-trip flights and find the flight path with the lowest cost in terms of time or ticket price.

If you use MySQL, this chapter from “Get It Done with MySQL 5″ is a fairly verbose but comprehensive guide to using MySQL to store graphical data. It includes background information such as terminology used in graph theory and has numerous implementation examples of adjacency list graph models, nested set graph models, and breadth-first and depth-first graph search algorithms.

For Oracle users, there’s a slightly more application-oriented tutorial that assumes more theoretical knowledge on the part of the reader. It shows that Oracle’s hierarchical data features unfortunately can’t be used in cases where cycles might exist in graphs (which is handy if you’re trying to detect them) and then goes on to show an implementation that uses temporary tables to store a summary of a graph analysis. A worthy side note is that part 2 of that tutorial deals with a more specialized approach using state machines that may or may not be applicable to your situation.

If you’d like more information on this topic, a good place to look is your local university. Most with a computer science program offer a course in theory of computation, which deals with topics like these as well as context-free grammars in the context of developing programming languages. Even if you never actually use this information to develop a language yourself, it can still serve a good purpose: it make you more informed when engaging in discussions about language development, and it can increase your appreciation for the beauty of a language from a user perspective.

PHP, MySQL, and Oracle: An Odd Triangle

Maggie Nelson posted a blog entry recently with a review of an article entitled “Database Design for PHP Programmers” in the February 2008 edition of php|architect magazine. In it, she remarks on the article being MySQL-oriented and how limited MySQL explain plan support is compared to Oracle. I’ve had some thoughts in my head for a while that are related to these points, so I finally decided to, knock on wood, put pen to paper.

First, I’ll agree with Maggie that Oracle beats MySQL hands down in a number of areas. Explain plans in Oracle are significantly more detailed and informative than they are in MySQL. Oracle offers features to support hierarchical data, whereas the most MySQL can recommend is to use the nested set model. Oracle also fully supports set operators, while MySQL still only supports unions. Oracle offers Oracle XE and Oracle SQL Developer to lower the barrier of entry for new developers. MySQL itself is free, but MySQL only currently offers similar developer-targetted features in the form of four separate tools, one of which (Workbench) is still very much in beta. These are just a few places where Oracle comes out the clear victor against MySQL. From a developer perspective, it’s no contest.

The story doesn’t end there, unfortunately. The major issue with Oracle is licensing, which still costs a pretty penny these days. Oracle is lowering this barrier a little to include midsize companies, but obviously MySQL still comes out more cost-effective. MySQL itself isn’t completely innocent of causing licensing issues, but it has at least remained free and compatible with PHP in terms of licensing up to this point. The LAMP platform became popular with good reason: it gives smaller companies a scalable, zero-cost, effective means of rapidly developing applications. At the moment, the most Oracle can claim is two out of those three points.

In addition to licensing, Oracle also comes with additional administration costs. I’ll use the managed server hosting provider Rackspace, with which I’ve had a fair amount of experience, as an example of this. They provide hosting for some fairly big names, Apple being one of them. Take a look at the database services they offer. They support both MySQL and Oracle. If you look closely, though, you’ll notice this statement on the Oracle page: “Oracle Server Support is not available to our Managed Support Level customers. For information about our Intensive Support Level, please click here.” I think that about sums up my point.

I would actually like to see us switch to Oracle where I work. As a developer, I prefer its feature set, enough so that I’m willing to overlook some of its nastier qualities. However, with the additional costs that would come with licensing and administration by Rackspace (which is still very reasonable for what they provide), I don’t think the cost difference is one that I can justify. Until the licensing and administration requirements that come with it are lessened, I don’t believe Oracle is going to be an ideal solution for me or the average PHP developer.

Additionally, though I’m still a bit skeptical, the Sun buyout of MySQL could accelerate MySQL’s development and in time put it closer to being on par with Oracle’s feature set. Only time will tell on that one, but I’d say it’s just as much of a possibility as Oracle expanding its offerings to include smaller companies. It’s still too early after the buyout to make any remotely definitive predictions as to its long-term effects on MySQL as a product.

But, as Dennis Miller would say, “That’s just my opinion, I could be wrong.” What’s your take?