Deprecated: Assigning the return value of new by reference is deprecated in /home/burlyman/public_html/blog/hosting-settings.php on line 472

Deprecated: Assigning the return value of new by reference is deprecated in /home/burlyman/public_html/blog/hosting-settings.php on line 487

Deprecated: Assigning the return value of new by reference is deprecated in /home/burlyman/public_html/blog/hosting-settings.php on line 494

Deprecated: Assigning the return value of new by reference is deprecated in /home/burlyman/public_html/blog/hosting-settings.php on line 530

Deprecated: Assigning the return value of new by reference is deprecated in /home/burlyman/public_html/blog/hosting-includes/cache.php on line 103

Deprecated: Assigning the return value of new by reference is deprecated in /home/burlyman/public_html/blog/hosting-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/burlyman/public_html/blog/hosting-includes/theme.php on line 623
BurlyHost.com, Inc. Web Hosting Blog » Uncategorized


Archive for the ‘Uncategorized’ Category

Watch those examples.

Saturday, October 4th, 2008 by Tim Greer
del.icio.us Digg Facebook FeedMeLinks Furl Ma.gnolia NewsVine Netscape Reddit Slashdot SphereIt SpurlStumbleUpon Technorati YahooMyWeb

In efforts to help those online with questions and problems, sometimes the answers are more dire than the question or problem the original poster (or “OP”) had to start with, if the OP acts on them without recognizing a problem with the example. It’s always best to double check and re-read your suggestion or example and not post it at all if you lack the time to double check what you are offering in a response, and to mention the potential of problems it could cause if your untested example was used without verifying it’s actually what the OP needs… and to make it clear that it is untested so the OP doesn’t attempt to use your example. Moreover, your tested code or example instructions might not work flawlessly for their specific issue anyway, even if you think you fully understand their question or problem.

A good example that sticks out, is a recent web hosting forum thread had someone explain they wanted to replace any opening PHP tags in any .php and .tpl file that were currently “<?”, and to replace it with “<?php” instead. There are valid reasons for this, such as <? can be confused as a PHP opening tag, if it’s an XML tag, so while “short tags” in PHP are usually fine, it is a valid reason to want to always ensure you use <?php instead of <?, as it’ll be correct across more systems and reduce the chances of problems and conflicts later (and it’s more portable this way).

People offered various examples, where one person used a regular expression with a Perl command in shell, which is a common and powerful way to accomplish such things. It was to read in any *\.{php,tpl}$ files, find and replace the value and, before modifying the current file, create a backup of the pre-modified file as $filename.bak. This is always a good idea, as well as having a good, reliable backup of the data before modifying it (so you don’t have to rename files, perhaps selectively, on a live environment site). I was just browsing over the technical forum to see what I could help with, as I had some extra time that day, and saw the post with a suggested solution, and I saw the OP state they ran it and all was fine. I almost missed it, and perhaps I was too late in seeing this, so I posted a follow-up to that thread urging them not to run the example and explained the problem.

The person offering the suggestion was well intended and obviously knew what they were doing, but simply didn’t catch the typo in their example. We all do this at some point, and they were appreciative I caught it, as I would be if someone caught an example I gave that was confusing or could pose a problem for the viewers of a thread (more on that later). The example given would, instead of replacing any instances of “<? ” with “<?php “, actually replace any single instance of white space (” “) with <?php. The example used the regular expression of s/<?\s/<?php/g which globally s/// replaces “<?” (the left side of the operation (less than, question mark, and a space)) with “<?php ” (with the right side of the operation -> <?php (less than, question mark, php, and a space),) or that was the intention anyway.

However, this had an unintended and unexpected result; The problem was that the right side of the operation <?\s (\s = a space character) was that ? is actually a character used in regular expressions to be used to state/mark the preceding character, class or string, for example, is “optional”. Therefore it was asked to match \s (a white space) with an “optional” leading “<” character, so “<? ” OR ” ” would be replaced with “<?php “. Thus, the phrase “Hello, world, how are you?” in a file would be replaced with “Hello,<?php world,<?php how<?php are<?php you?” with no opening (short) PHP tag (<?) in sight to execute the replacement. The file would be filled with broken, irrelevant and unwanted PHP open tags, adding it everywhere it saw a space in the file. The solution was to make the ? character to be seen as ?, meaning it needed to be escaped (backwacked) to disable the “optional” meaning and actually mean just ?. This is done by adding a backslash directly before the character (\?).

Therefore, a simple oversight of the difference between<?\s and <\?\s could cause dramatic and dire results. The poster that offered the solution, again, knew what he was doing and immediately recognized the mistake, but this goes to show that one single small mistake in an example or suggestion, command line, fix or instruction can cause unexpected and awful results. You should therefore always double check your example, even if it is just an example. This is a well versed suggestion in usenet newsgroups, such as comp.lang.perl.misc, as seasoned programming instructors that participate there will remind you, even on examples, you should always check for success or failures, when applicable, such as if a file was successfully opened before trying to iterate through each line of the file handler, because the OP will perhaps not realize this, try running your example and have all sorts of unexpected results and problems. It’s best to create some simple and safe environment to test your example chunk of code, perhaps in a controlled manner, before offering a suggestion, or otherwise to clearly state it is untested and potentially dangerous (if it could be) for them to run.

This goes back to a similar experience I had in the Perl newsgroup recently, where the OP asked what the meaning of m@ was in their example of $string =~ m@@si; I had explained that this was a regex to match (m//) and that @ was just a delimiter and that “m(anything) is making (anything) the delimiter. m// is just most common to see, but m,, or m!! and so on, are perfectly acceptable. It can help save typing over using m// when you have a lot of / characters you’d otherwise have to backwack (escape). (i.e., m!<b>this</b><i>that</i>!si saved typing and makes it more readable than m@<title>\s*(.*?)\s*<\/title><b>this<\/b><i>that<\/i>@si, especially if you have a lot of characters within the regex that are also your delimiters)”.

Well, someone (Ilya) called me on it, and rightfully so, stating that, what I said would be correct, except m(anything) is using `(’ and `)’ as delimiters. This is true, I used a too literal example of “(anything)”, where “(anything)” wasn’t intended to say an entire word or a word within parenthesis would be a valid open and closing delimiter in a regular expression. Good point, even though it’s probably obvious, what if the OP didn’t know (they probably didn’t, since they had to ask originally anyway), and my response could have caused them a lot of confusion.

In fact, the OP actually replied to my example and said ” And what would be the reason for using ( and ) as delimiters in this case? “, and I had found I was explaining my example, and it clearly caused them some confusion, not to mention that certain other characters can’t just be used as a delimiter and could (or not) based on a few other variables (not literal $variables, of course), so you can’t really use anything, and especially “(anything)”.

I suppose this is obvious, but most of us are known to take it for granted; Clarification and a little time to consider the OP might not understand and take you too literally, or run a piece of code or a command, or follow some instruction you didn’t mean as a complete and perfect solution for them, could spell disaster or result in lot of confusion and follow up questions (and maybe more of your time, when it’s less of an opportune time for you to explain, except you are now responsible to, since you caused the confusion or problem). Therefore, taking a few seconds or minutes more, double checking for typos and considering that the OP might copy and paste and run whatever you tell them, dictates you make some type of effort to clarify, re-read what you wrote so it’s not taken wrong to too literally, and hopefully test it, if applicable, before you hit that submit/send button.

Perl Programming and regular expression fun.

Saturday, October 4th, 2008 by Tim Greer
del.icio.us Digg Facebook FeedMeLinks Furl Ma.gnolia NewsVine Netscape Reddit Slashdot SphereIt SpurlStumbleUpon Technorati YahooMyWeb

Recently, in the Perl Programming language usenet newsgroup (comp.lang.perl.misc), a poster posed a question, asking if a certain task was possible, thinking it wasn’t. I read it and immediately thought “Sure, that’s possible, it’s easy…” and went on to post a solution a short time later. However, I had to think about it for a minute, because I never considered doing something like this. To be more accurate, have done things just like this, but wouldn’t have approached it this way. Of course, there’s more than one way to skin a cat and some ways are far more creative, fun, challenging or inventive than others.

The question was an interesting challenge, because the poster wanted to only use a regular expression to dynamically detect and replace any duplicate instances of any single character in a string to only keep the first instance and remove the rest following. Most people assumed that the duplicate characters in the string would be predetermined/already known, but they weren’t (e.g.; it could be any single character repeated in the string, or multiple characters repeated throughout, not just one character you already knew about that could be used more than once).

They had posed the following string examples:

a”bc’def’g’ -> a’bcdefg
”’ab’cd’efg -> ‘abcdefg
abc’d'e”f’g -> abc’defg

My posted solution was a simple and effective one line of relevant code:

$string =~ s|(.)| ($` =~ m/$1/) ? ” : $1 |eg;

This takes any single character, captures it and then processes it by counting how many times it finds it, and if it’s over once, it ignores duplicates of it, and the replacement (after the first replacement) is empty, rather than the captured value. =~ s|…|…|g; replaces globally for each (.) single character it finds and captures into $1, while /e processes the right side of the regex and uses $` to check the number of times $1 is matched by checking with ($` =~ m/$1/), which results in a number due to the parenthesis and the operators are assigned to replace with “” (nothing) “” if it’s true ? or else (:) $1 if it’s false (less than one, hasn’t shown a match yet for that single character).

I created the following script to example this (pardon the fact I didn’t put it in a loop to show the varied strings and parsed output):

#!/usr/bin/perl
use warnings;
use strict;

my $linea = “a”bc’def’g'”;
my $lineb = “”’ab’cd’efg”;
my $linec = “abc’d'e”f’g”;

print “$linea -> “;
$linea =~ s|(.)| ($` =~ m/$1/) ? ” : $1 |eg;
print “$linea\n”;

print “$lineb -> “;
$lineb =~ s|(.)| ($` =~ m/$1/) ? ” : $1 |eg;
print “$lineb\n”;

print “$linec -> “;
$linec =~ s|(.)| ($` =~ m/$1/) ? ” : $1 |eg;
print “$linec\n”;

The output:
~]$ ./script.pl
a”bc’def’g’ -> a’bcdefg
”’ab’cd’efg -> ‘abcdefg
abc’d'e”f’g -> abc’defg

Following this example, another poster (Ben Morrow) followed up with some other methods of accomplishing the same task, also using only regular expressions:

Without using /e:
~% perl -le’$_ = “abccbdcdc”; 1 while s/(.)(.*)\1/$1$2/g; print’
abcd

Using 5.10’s \K we can remove the replacement part:
~% perl5.10.0 -le’$_=”abccbdcdc”; 1 while s/(.).*\K\1//g; print’
abcd

and if we reverse the string before and after (so we can use look*ahead* instead, which can be variable-length) we can remove the while loop:

~% perl -le’$_ = reverse “abccbdcdc”; s/(.)(?=.*\1)//g;
print scalar reverse’
abcd

Now, how cool is that? I offered one method, and Ben offered three additional methods, totaling four various ways to accomplish the task using only regular expressions. Perl’s regular expressions and varied ways about coming up with solutions, truly makes it a great language. This is only one of many cool tricks and challenges people have posed that impresses me about Perl’s power, but this was just a recent one that stuck in my mind. Since I didn’t see any existing examples out there, this could be useful information to learn from and use if you should run into such a challenge some day.

There are a million reasons to use regular expressions, and if used properly, they are a very powerful, time saving and accurate feature of any language. The above is just one of many examples that illustrate the Tim Toady (TIMTOWTDI -> “There Is More Than One Way To Do It“) power of Perl. Doing that much logic in a very short, simple regular expression. One of about 10,000 things that show how cool Perl is. By far, my language of choice when coding.

Attempts to impress the web hosting industry and clients, by going against logic and common sense.

Saturday, October 4th, 2008 by Tim Greer
del.icio.us Digg Facebook FeedMeLinks Furl Ma.gnolia NewsVine Netscape Reddit Slashdot SphereIt SpurlStumbleUpon Technorati YahooMyWeb

Some companies really try too hard. Often, they are doomed from the start. Even if they are “successful”, it’s usually attributed to nothing more than luck. Few operate or value experience and skills and appreciate their clients. Often, owners and managers that (poorly) run these companies will proclaim themselves “entrepreneurs” and “clever businessmen”, believing they are the reason for the company’s success, when it’s usually their staff that they ironically lack appreciation and respect for that really explains any small or large amount of success they might have. Yes, being a child of wealthy parents that are willing to shell out tons of cash to over expose their child’s web hosting business, doesn’t actually make you the reason for the company being a success.

Moreover, they outspend themselves for the sake of trying to impress “bigness” and “importance” upon potential clients, and even more sadly and ironic, other companies in the web hosting industry. They will stop at nothing to stay “on the top” of lists, paying affiliates 10 to 50 times what a client would pay them for hosting even if that client stayed on them for many years, just to get the client in the first place. Further to this, then toss in a free domain for life. Even more crazy, they will promise unrealistic and impossible hosting plan limits, in the hundreds of gigs to many terabytes of both disk space and bandwidth, or even claim there is “no limit” (unlimited). They offer these unrealistic limits for only a few dollars per month, even though their entire server they host a 100 or more clients on, costs them $1,000 per month, and only holds 1/10th of the space they promise for just one single client’s account.

Let’s face it, stuff costs money. There’s no way around it. You don’t pay a thousand dollars per month for a dedicated server that has 1 (one) Terabyte of disk space and 5 terabytes of bandwidth and then sell 2 terabytes of space and 15 terabytes of bandwidth for $5/mo. You don’t have to have a degree in mathematics or physics to understand that they would lose hundreds of dollars per month to host that one $5/mo. account, if they actually intended to live up to their promise and provide the disk space and bandwidth the client paid for.

They rely on extreme overselling to “average” out the usage, claiming that if 100 clients on the server only use 100 megs of disk space and 1 Gig of bandwidth, that they can offer the other “high usage” clients their promised limits. This isn’t true, at all. This still means that they don’t have enough physical disk space to meet that single client’s needs if that client did use anywhere near their promised limit. I personally know of a very popular, very large and known web hosting provider that promises huge limits and unlimited, yet I know for a fact that they can’t deliver what they promise, so they find reasons to kick users for not using too much CPU or memory resources, but because they are presenting a risk of financial loss (because they can’t give away that much resources).

That company claims to have large disk arrays so each server can offer that much. Well, they actually don’t. Their disks (in total) on the servers range from 250 gigs to 750 gigs, with only one or two available, or in a raid array to total about 1.5 terabytes. Yet, even then, without any other users and without any OS install, logs, etc., not disk usage at all, it’s still not physically possible. They then changed their story to say all sorts of things about using different technologies to cluster servers and their disk space to “overall” average out the total across the server farm. They have no such method implemented and regardless of how you view it, those disks and that bandwidth still cost money (a lot of money), and once again, once a single client poses a risk to the usage of the server’s disk space or bandwidth, they are now a financial burden, because their extreme overselling tactics backfired on them.

They have an easy out though, and often use it, claiming the site was getting too many accesses, using too much CPU time or too much memory. Sometimes this is true and a legitimate cause, and this is a case that any web host, extreme overseller or not, will have to take corrective action to protect the server, its services and the other clients (assuming it’s a shared or reseller server). However, in these cases, it’s often not true and is claimed because it’s an easy excuse to kick the client without having to face public ridicule if the client could prove they were kicked off the host because they tried to use their promised resources that they paid for! The theory by extreme oversellers is flawed and is essentially saying that “if a site used that much disk space and/or that much bandwidth, they will use up too much CPU and/or memory on the system before they ever became a financial threat and we’d kick/suspend them anyway”. This isn’t always the case, but you can bet that it’s the case claimed when they suspend/kick them.

In all fairness, some hosts might have some type of affiliation or sponsorship with the high usage client, because a well trafficked site that provides ads for your hosting service, can benefit both parties. Such as a “hosting site index”, which sadly will usually overexpose their vested interest “sponsor” by putting their ads more prominently and even make it appear on a “top 10 list” as if their sponsor has the better ranking or quality, which is even more unfair to the other hosts that (sadly, too) have to pay to be on that top 10 hosting site list, because their services are less appealing to the naive web user looking at those lists for the best, top 10 web hosting providers. Of course, those are all essentially portals where someone has affiliate links and gets paid per client, and puts up a list of the 10 highest paying referral programs and makes it appear as though all hosts on the list are high quality, well ranked (by votes of happy clients), when in fact, they are nothing more than a trick to get themselves money and the affiliate couldn’t care less if the host was any good, or even a legal operation for that matter.

This issue is broad and varied, and it’s difficult for a client to find honest, real hosts, and hosts that have experience, skills and really know what they are doing (from running the company, to offering support and keeping a secure and stable hosting environment). The competitiveness goes to what I was speaking of originally, above, where these companies literally outspend themselves, creating excessive and unnecessary overhead, where just to stay on top and saturate the market, they’ll pay more for advertising than they have coming in. Everything from getting the top spots on certain web hosting forums and web hosting centric sites, to paying $10, $20, $40+ per click on their ad link (where only 5-10% of the users will actually order service anyway, and the one’s that do, will only be paying a couple of dollars per month). These people are happy to hemorrhage money just to look bigger, and therefore, in their minds, appear better.

With this sort of mentality, no one wins. Not them, not their clients, not their staff, no one. Their staff have no job security, and the methods used to run and manage the company by unqualified owners and managers only drive the qualified staff to leave and seek employment at a company that has a better head on their corporate shoulders. They have no future, unless they revert back to normal plans where they stop trying to only undersell the competition by lowering prices and offering more, when it’s not a truthful limit they claim to offer (they can be very generous and still be realistic and make the same amount of money). The fact is, companies that operate like this, regardless of how much they believe they are marketing geniuses, are only staying afloat, because they are managing to keep enough new clients coming in due to overexposure, for now. When that stops, new marketing money goes away, people get laid off, more clients start getting kicked and the company eventually folds.

No matter how you cut it, no matter what irrelevant and poor examples companies give about cell phones, airlines and the generic word “overselling”, this is a completely other animal altogether. Common sense and very little or even no education about the hosting industry dictates that certain things aren’t possible. With a cell phone, you and thousands of others can leave them on a call 24/7, all day long, all month long and be within the contracts’ terms. Airlines, while they might bump passengers from a flight, will still get you on a flight and still give you the service promised, even if you have to wait several hours. Neither of those examples try and overload circuits from a single client’s use, or overload the weight limit on a plane and claim it’s safe. It’s economically foolish and reckless, and it’s a terrible business model with no future.

Companies will continue to skirt around the laws of physics, because it’s hard to prove that they won’t offer what they claim, when they claim a client abused the system’s resources and kick them when they start to cost more than the client pays them for hosting. If they want to play that game and disrespect their existing and potential clients, and just try and impress people with the biggest numbers for the lowest price, fine. However, let’s not pretend it’s possible. The fact is, they undersell because they have no real service to sell people on. If you offer quality and honest service, people will flock to you, you’ll earn their business and they will be happy. Companies like that only have happy clients, because those clients haven’t had a need for truly exceptional service and probably have never experienced it and have nothing to base their opinions on in comparison. If the client is happy enough, that’s great…. until they get bitten in the end for using a reckless, irresponsible company that has no business in this industry. However, then they will look for the quality, legitimate and honest hosts, whom still offer great service and generous limits (more than they’d need anyway, without making up ridiculous limits that can’t be met), and things balance out in the industry. Unlike those that are overselling to some extreme level that just destroys the integrity of the web hosting industry, because they aren’t helping to make things better at all.


Valid XHTML 1.0 Transitional