Future of Desktop Linux

My PC runs Windows 7 Ultimate and Ubuntu 9.10. Windows for Adobe software and gaming, Ubuntu for development. Recently my Nvidia graphics card started playing up, so I removed it. Thankfully, my motherboard has a fairly adequate ATI card built in. I removed the card, restarted Windows and continued as normal. Windows detected the card, installed appropriate drivers. All I had to do was reselect my resolution.

Later the same evening, I restarted into Ubuntu.

Ubuntu greeted me with it’s cute little white logo, all is well. Then the problems started. I’m notified the proprietary Nvidia drivers aren’t functioning and asked if I’d like to reconfigure my graphics settings. Yes please! Apparently I’m not allowed, it can’t save the new settings. I ask nicely to edit the configuration manually, and restart. Success! No. Apparently my ATI X1250 and 21″ CRT can’t support more than 1152×768. I try “vesa”, “ati”, “radeon”, “radeonhd” with no success, and finally move on to the ATI website to get official drivers.

I’m not going to rant about ATI, but suffice to say: If they can’t be bothered to make an installation that requires less than an hour of my time, requiring steps 99% of the population wouldn’t stand a chance of completing, I’m not going to bother. I’m simply going to save myself the bother in future by never using ATI again.

I fixed my problem by following a complex guide on the Ubuntu website, purging all traces of Nvidia drivers and reapplying the “radeon” driver. I then went to an unrelated website about advanced configuation of “xorg.conf” and guessed a number of settings to type in. Fairly certain my edits would simply cause the system to crash, I crossed my fingers, restarted and… It worked! It actually worked. I got my 1600×1200 back. I lost all 3D support, but at least I don’t have to bother keeping Wine installed anymore…

What’s my point?

I really want to recommend Ubuntu to friends and family, like most of the Linux fan base would. Frankly though, that’s years away from happening. There are so many fairly fundamental usability issues in Gnome and KDE that mean installing it for my parents would result in many hours per week in technical support to them.

Something as simple as adding items to the “quick launch” or “start menu” equivalents is a sweat inducing trial of endurance for anything but the most technical person. Running scripts on startup that require elevated privileges is something that’s eluded me so far, and I open a terminal to “sudo” run them manually every time I start the PC.

Ubuntu is a great operating system though. Having a LAMP server setup on my desktop PC in a few lines of text makes me very happy. The range of 1-click install software on hand is wonderful. I just wish some of the fairly basic features you expect to find (like intelligent driver selection…) were worked on a little more.

PHP 5

I hear Geocities has gone forever. Well, it’s hardly surprising, but it is a little sad. I remember signing up for one of their quaintly named sites all those years ago. Still, I went investigating and found Yahoo Web Hosting! (I feel everything with Yahoo! needs exclaiming, it is like some kind of marketing ploy of theirs, right!?)

I was curious to see what kind of features such a major player like Yahoo! would offer in their web hosting, and after a few clicks I found Perl and PHP support. Now before you pull out the party hats and invite your friends over, I mean it has “PHP” support. 4.3.11 to be precise.

This leads me onto a pet hate of mine. The PHP community have been moving ever forward and have hit a great milestone with version 5.3. It’s a great, rapidly maturing language – I use it daily. Hourly, even. Version 5 of PHP has been around for an eternity (in IT years, they’re like dog years you know…) and yet a large subset of the internet web hosting companies STILL INSIST ON USING PHP 4!!! WHY!?

I suggest next time you find a company “offering” you PHP 4, you send them a polite email reminding them version 5 was released in July 2004, and while you appreciate 5 years clearly isn’t long enough for them to evaluate and upgrade, perhaps now is the time to “take the plunge”.

For the record, my Lamped hosting offer 5.3.1.

PHP, JS and CSS Compression

I wasn’t feeling very well today, so I thought I’d do something more light-hearted and fun.

Yes, that’s right! I wrote a website compression utility!

Basically, you do “php sitecompress.php mywebsitefolder” and it goes through all the .php, .html, .htm, .js and .css files. Javascript and CSS (inline and external – yes I said inline. It pulls out the scripts and styles embedded in your HTML and compresses those too) go through YUICompressor (courtesy of Yahoo UI library), PHP and HTML go through an internal algorithm to kill the whitespace. No, I didn’t use “php -w filename”, that would (a) be cheating, and (b) not be very good. Seems PHP’s own whitespace removal is a bit lackluster and keeps a lot of unnecessary whitespace.

I’ve run it on a download of microsoft.com and it displays identically. I’ve run it on the source code of PHPBB3 (after realising I have to add a “keep html comments” option, due to their templating system) and that seems fine (strips 4mb off the 37mb install).

I’ll do a bit more testing in the next couple of days and GPL it on Lamped.co.uk.

p.s. Apologies for the poor readability, It’s 00:45 and I’m very tired…

Kloxo/LxAdmin vs cPanel/WHM

Couple of posts ago I mentioned a new VPS. I’ve been working with a cPanel VPS in work for a long time now, and ran WAMP (Windows, Apache, MySQL, PHP) self-configured at home so I was fairly confident I could install and run a basic system on the VPS with my own control panel…

Wrong.

IPTables, BIND, various mail servers… It fast became unmanageable, even when I gave up and installed Webmin. I think my general advice to the community is: Be sure of your LAMP (see, linux not windows) expertise before you try anything like this.

So I reimaged the VPS using LxAdmin (now renamed Kloxo). I should have listened to the advice from the hosting company. Stability issues from the outset. I’m sure there was a configuration issue, but I was having to PuTTY into the server and restart services on a semi-regular basis.

I swallowed my pride, let the moths out of my wallet and finally got cPanel. You know, even considering its cost, I think it’s under-rated. Considering management time, time = money, I’m definitely saving money by paying. Odd sentence, eh?

On a related note, myprohost.com have been very supportive and helpful during my confusion and migration to different systems. Thumbs up to them.

Javascript Object setTimeout

So I’ve been developing a chat room entirely in Javascript and PHP using a lot of ajax. Aside from an eCard I made for friends and family last christmas, I’ve not written more than a few lines of javascript before. I find starting a large project is a good way to learn a language, so off I went…

I wanted to do this properly, so I read up on Javascript OOP development and improved my general knowledge of the excellent jQuery library. I developed the client side script over a week or so and while doing so, found a number of issues with how setTimeout and setInterval work with objects.

Example:

function someObject() {
    this.myVar = 'Test';
    setTimeout(this.myTimeoutCall, 1000);
}
someObject.prototype.myTimeoutCall = function() {
    alert(this.myVar);
}

This alerts out ‘Test’ right? Wrong. It alerts Undefined… Why? Apparently setTimeout and setInterval lose the object scope when they call the timer function. I spent hours in Aptana last night butchering around some Javascript until I came up with 2 functions that ensure your timer code is called in the correct scope, and since there’s little appropriate documentation for it out there, I thought I’d share:

function SetTimeoutObj(o, t, f, a) {

	return setTimeout(function() {

		f.apply(o,a);

	}, t);

}

function SetIntervalObj(o, t, f, a) {

	return setInterval(function() {

		f.apply(o,a);

	}, t);

}

Change your code to use setTimeout(this, time, this.function, [param1, param2, etc]) and hopefully your problems are solved (note: the function parameter list is similar to the original setTimeout, but I moved the duration parameter left one for clarity.)

VPS

I thought it was about time I upped my game in hosting solutions, so I just bought myself a gift – a VPS. I guess it’s about time I brushed up on my bash. Lets see how they go…

So, a blog then…

I thought it was about time I joined the masses and created a blog. It’s fashionable, right?

Well regardless, I thought this would be a handy place to put all the cool things I’m experimenting with through PHP, Windows Server administration and such.