Recently I ran into a situation when upgrading from MySQL 4.x to 5.x on a dev box of mine. I actually ran into this a year or two ago too, but I forgot to document it (I know, I know) and so I didn’t remember it. I thought I would post it here now to share with all of you in case you run across it yourself. Once the upgrade was done, the application that connected to the database would connect no longer. I kept getting authentication errors no matter what I did. This was a fresh install, I just imported MySQL dump files for my databases, so I thought it was a setting or something that I had forgotten. I checked everything out and could find nothing wrong with the settings, user accounts, passwords, you name it. The app I was launching ran on Windows (specifically, this is my EQEmu server, check it out daBoneyard), and it’s a console app so the Dos window flies by and I hadn’t seen the error message. Finally I decided to put a pause in the batch file and see what the heck was going on. It was then that I was presented with the following error:
Author Archives: Laz
PERL Round Function
Hey all your PERL junkies like me, I have a present for you. Anyone that has done any coding at all other PERL will know (and miss) the round function that most other languages have built in. For those that may not know, the round function lets you do just that, round a number to the specified digit. So, instead of having to use 3.14159265 as an answer for a particular equation, you could round it to 3.14. Nice, huh?
Well, here is a neato little round function that you can drop into your PERL scripts and call to actually round numbers instead of cutting them off with ceil or cut. Check it out:
sub round {
my($number) = shift;
return int($number + .5 * ($number <=> 0));
}
There you go!
**Update**
Thanks to Thierry H. for adding a little mod to the round function allowing you to specify the number of decimals to print. Here is the modified function:
sub round {
my $number = shift || 0;
my $dec = 10 ** (shift || 0);
return int( $dec * $number + .5 * ($number <=> 0)) / $dec;
}
You would call it by giving not only the number to round, but how many numbers to show on the right side of the decimal. It will look like so:
$result = round(123.4567,3);
This should return 123.457 (the 6 in the third slot gets rounded to 7). There ya go, thanks for the mod Thierry! You can check out Thierry’s site here.
WordPress and Permalinks
If you haven’t ever used WordPress for your website or blog, you don’t know what you are missing. I have used almost every CMS out there, including PHP-Nuke, Post-Nuke, e107, PHPWebsite, CPG to just name a few of the more popular ones. However, once WordPress got past the 2.0 versions, it was all over. I love the WordPress platform and use it for many different websites that I manage. I do sometimes run something other than WordPress if I have some specific need that something else does better, but for a good, solid blog and/or website platform I find it hard to beat WordPress.
That being said, one thing I have seen people have trouble with is Permalinks. This is when you change the link structure from the default style like this:
http://example.com/?page_id=N
to something more visually appealing like this:
http://example.com/category/post-name/
or
http://example.com/year/month/day/post-name
The friendly Permalink option is not only easier on your visitors, but it’s easier for search engines as well to index your site. That means that setting Permalinks to something friendly is a good idea on many fronts. You can set the Permalink style in the WordPress admin panel under Options. However, when you do that you also have to update your .htaccess file (on Apache) in order to process the links properly. I have included below a nice .htaccess snippet that you can drop in to get your Permalinks working, check it out:
# BEGIN WordPress Permalink Rules <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress Permalink Rules
I hope that will help in your Permalink adventures!
Website Design Tips or Things Not To Do
Ok folks, I have decided to toss out some general tips for those of you who consider yourselves website designers. I have been seeing lots of poorly designed sites out there, and it has frustrated me enough that I have to mention a few of the top offenses. Read this and take heed, you might think you are cool and a super leet rumpshakin pimp webmaster dude but, you’re not. Follow me:
- Keep your audience in mind. Don’t forget that you are writing a website for a wide variety of users, not a small minority. Sites that don’t render in anything but IE and have the little button “Best Viewed in Internet Exporer” drive me insane, and in fact I won’t do business with sites like that. Most of what I am going to talk about in this post centers around this main issue.
- DON’T BASE THE WHOLE SITE ON JAVA-FREAKIN-SCRIPT! Did I make myself clear? I can’t tell you how many sites I have found that not only don’t have any navigation links without Javascript enabled, but won’t render at all without it. Here’s a clue, if I just described your website, you are a moron. Javascript is great, but it’s also dependent on the browser again which means you can’t rely on it for critical things like navigation (if that’s the only navigation), rendering the site in the first place, form input validation (duh!), etc. Anyone who uses it for form input validation is crazy, you don’t trust that to something that can be manipulated on the client side … HELLOOO?!
- DON’T BASE THE WHOLE SITE ON FLASH! Did I stutter? Not only does it take way too long to load, especially for people on dial-up (yes, people are still using dial-up, in fact, the majority of web surfers still do), but we run into that whole client side thing again. Don’t alienate people because they don’t have the right plugin, I don’t care how widespread you think it is. I know, you are thinking that it’s only 5 or 10 percent of the visitors, but why throw away that many opportunities? Come on man, get with it.
- Don’t over do it with the gadgets. Yes, fly up pop out whirl around shout at you menus are cute, but they detract from the whole purpose of your site, to convey whatever information you have to the visitor. Now, if you have no content maybe you should have all that stuff.
- The same goes for too many graphics. Load that page up with too many pics and you are back to having it take too long to load and people getting fed up and moving on. From the research that I have read, you have about four seconds to get the page loaded and grab a visitors attention before you have lost them. Think about how fast you yourself move on when surfing. Uh huh, see?
I think that’s enough for now, it’s a good start anyway. At the very least you should get an idea of where I am going. Keep your sites clean, simple and easy to navigate. Great designs are fine and well, great even, but do it right!
Cool Keyboard Shortcuts For Windows
I have been checking out ways to do things easier and faster, plus just plain get around faster in Windows. I have been putting together a list of shortcuts that are handy to have and I thought I would share them with everyone! As I find more I’ll be adding to the list, so check it now and then. For now I have a pretty good start I think, so go take a look …
New Computer Goodness From Alienware
Well folks, I thought I would share some good stuff that is happening on my end of the ‘net. After using my last computer for about 3 1/2 years, I decided it was time to upgrade. This is no small task for me, mainly because I am picky as hell but what can I say. For starters, I have always built my computers, again because I am picky and I want them my way. I have been doing this for more than a decade and this time I wanted to simply buy one. This meant that I had to do a lot of research to find a good quality machine that was going to live up to my expectations and also not break the bank. After lots of reading and digging I finally settled on Alienware. Now, Alienware has always had a reputation for building top notch machines and I must confess I have always wanted one. Even though the HP Blackbird looked like a mighty fine machine, I just couldn’t justify the cost. That plus did I mention I really wanted an Alienware???