RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]

Yeah, that’s it. So:

  1. /path/dir/ is redirected to /path/dir
  2. /path/dir/?a=1&b=2 is redirected to /path/dir?a=1&b=2

{ Comments on this entry are closed }

At any time, press:

Ctrl + Shift + L

For a list of available shortcut keys defined in your Zend Eclipse PDT.

Go:

Window > Preferences > General > Keys

To edit the shortcut keys. Or simply press Ctrl + Shift + L twice.

For Zend Eclipse PDT to instantly show a tool tip hint of what the parameters of a function / method are so you don’t have to look up the original definition, just place the cursor in the parameters parenthesis and press one of them:

Alt + ?

Alt + Shift + /

Ctrl + Shift + Space

Which is defined under the title “Context Information” when you press Ctrl + Shift + L.

If a function or method name is elusive to you, type the beginning part of it and press:

Alt + /

Ctrl + Alt + /

And PDT would try and auto-complete it for you. It is defined under the title “Word Completion” when you press Ctrl + Shift + L.

{ Comments on this entry are closed }

The default array() indentation of Eclipse for PHP Developers when you create an array seems to be 2 tabs which I think are too much. To reduce it to just 1 tab:

Window => Preferences => PHP => Editor => Typing => formatter preference page => Edit… => Indentation => Default indentation of array initializers

Or

Window => Preferences => PHP => Code Style => Formatter => Edit… => Indentation => Default indentation of array initializers

To change the default indentation for wrapped lines:

Window => Preferences => PHP => Code Style => Formatter => Edit… => Line Wrapping => Default indentation for wrapped lines

{ Comments on this entry are closed }

Many’s the time after you have uploaded some PHP script to your server and point the web browser to the address it gives 500 Internet Server Error. If you have suPHP installed this is very likely because the uploaded PHP script (files and directories) have wrong permissions set to them.

With regards to Linux permissions, suPHP requires all directories to be at least 755 and all files to be at least 644 for any PHP script to run. If the directory or the PHP script has the wrong permissions set to them, suPHP would give out 500 Internet Server Error until you have corrected them. In addition, the directory and the PHP script must be owned by the current user and group or they wouldn’t run either.

To fix this is very easy, just perform the following command after you have uploaded the PHP script:

chown -R youruser /home/youruser/public_html/*
chgrp -R youruser /home/youruser/public_html/*
find /home/youruser/public_html/* -type f -exec chmod 644 {} \;
find /home/youruser/public_html/* -type d -exec chmod 755 {} \;

The 1st line sets everything (files and directories) under /home/youruser/public_html/ to be owned by user youruser.

The 2nd line sets everything (files and directories) under /home/youruser/public_html/ to be owned by group youruser.

The 3rd line sets all files under /home/youruser/public_html/ to be 644 in permissions.

The 4th line sets all directories under /home/youruser/public_html/ to be 755 in permissions.

{ Comments on this entry are closed }

How Does Your Brand Measure Up?

by Yang Yang on September 17, 2012

Did you read the recent Yahoo finance news article about 2013’s Top 10 Best Brands and Worst Brands in America? A company called “CoreBrand” conducts an annual survey to determine the most and least respected corporate brands based on the company’s “Familiarity and Favorability data.” This goes beyond the most well known, the most heavily advertised or the highest profit making companies. This measures people’s perceptions of a company’s trustworthiness and respect among consumers. Most of these major brands have an international presence, but the survey results are based on American sentiments.

According to the study results released August 20, these are the 2013 Top 10 Most Respected Brands:

  1. PepsiCo and Coca-Cola (tied)
  2. Hershey’s
  3. Harley-Davidson
  4. Bayer
  5. Johnson & Johnson
  6. Kellogg’s
  7. Campbell’s Soup Company
  8. Colgate-Palmolive
  9. Estee Lauder

And, according to the same study, these are the Top 10 Least Respected Brands in 2013:

  1. Delta
  2. Philip Morris
  3. H&R Block
  4. Denny’s
  5. Big Lots
  6. Best Buy
  7. J.C. Penney
  8. Capital One
  9. Rite Aid
  10. Foot Locker

Some of these results may surprise you, as your own personal experience with an individual company may have been excellent and you consider yourself a loyal customer. In some cases, you might have issues with their competition or there is no convenient alternative, so you must use their products or services regardless of whether you like the company or not.

The point is, if you are a business in today’s world and your customers were to be asked how satisfied they are with your products or services, how would your brand measure up? Most people want to believe that every customer is happy and consider complaints to be a reflection on the disgruntled customer themselves, not something that the company has actually done wrong or needs improvement. A smart manager realizes that a complaint is an opportunity to not only make things right for the customer, but a warning flag that something in your operations is not delivering up to expectations and needs to be fixed.

In my post about Amazon’s affiliate program, I mentioned how easy it is to earn money as an affiliate with Amazon because:

  1. Amazon itself is a globally recognized brand with a good reputation
  2. Amazon carries popular brands already familiar to people and rarely has products returned
  3. Although Amazon started out selling books, they have evolved and grown into a company that sells just about anything

Not only does Amazon do an excellent job of meeting each customer’s needs, they are constantly asking for reviews and have top notch customer service. Even if the product you sold didn’t meet your customer’s expectation, if you handle complaints well, in most cases you can keep that customer’s respect and rebuild their trust.

Safeguard all that hard work building your business and creating a brand. If your customer service is lacking, people no longer hesitate to take their complaints to the internet and warn their friends on sites like Facebook, YELP, TripAdvisor.com and Angie’s List. Bad reviews do scare away new business and cost you customers. Brand.com reviews the best ways to optimize search listings and protect brands for small business as well as large corporations.

The U.S. government’s Small Business Administration also has some excellent advice about managing a company’s online reputation and other business issues. Even companies that do not have a web site must be concerned with their online reputation and monitor the most popular sites regularly to protect their brand from negative reviews in directories and social media.

{ Comments on this entry are closed }

vBulletin: Paid Subscription Not Showing Up

by Yang Yang on September 14, 2012

I was trying to start a premium membership for Kavoir Backyard and after I have created a Paid Subscription profile, nothing shows up in user control panel nor at /backyard/payments.php.

As you can see from the thread I started in the official vBulletin forum for help, I have done everything necessary to create the subscription profile and it’s definitely active. But somehow, it simply doesn’t show up at all.

Subscription Manager

Paid Subscription profile

I see no “Paid Subscription” link in user control panel left sidebar nor any subscription order forms. The payments.php page says “Kavoir Backyard Webmaster Forum does not have any paid subscriptions available to which you can subscribe.”.

What’s wrong? What did I leave out? The solution!

Turned out it’s because I didn’t specify the payment details for Paid Subscriptions. You should use Payment API Manager to specify the payment API: Paid Subscriptions –> Payment API Manager.

paid subscription payment API

By default there’s NO active payment API and you have to explicitly select one such as PayPal and enter the details. Once it’s all configured and active, Paid Subscriptions link and premium membership order forms are correctly displayed to the registered users in the control panel.

Disappeared again after upgrade?

After upgrade, the paid subscription is disappearing again. To make it show up, just de-activate the payment method in Payment API Manager and re-activate it again by first setting Active to No and then back to Yes again (click Update twice).

Weird how things work in the world, huh.

{ Comments on this entry are closed }

By default browsers such as Firefox sends the Referer information to the target URL in the HTTP header, as defined by HTTP protocol, so the destination URL / website knows where you have come from. For instance, when you click this link to one of my friends’ sites, it would know you have arrived at Princessly from this page:

https://www.kavoir.com/2012/08/make-firefox-to-not-send-http-referer-or-on-a-per-site-basis.html

Because Firefox sends this information in the HTTP header.

While this is very valuable data to many parties, such as the website owners (who can analyze traffic sources) and market analysts (who wants to know people’s interests and habits so as to sell well), it can be bad for our privacy because it is disclosing our browsing information to the websites we are visiting. You may want to disable Firefox from sending the referrer.

How to disable Firefox to send HTTP referrer?

Just type:

about:config

In your Firefox address bar and click “I’ll be careful, I promise!”.

In search, type:

referer

And an entry reading “network.http.sendRefererHeader” would come out with a value that’s 2 by default. Right click on the entry and click “Modify”. Input 0 and click OK.

Restart your Firefox, and now it should not send any referer information any more. And no website would ever know where you were before coming to them.

Not Send Referer on a Per-Site Basis in Firefox?

However, sometimes this may break something as legitimate sites are also using referer information to better serve you. There must be some sites that you don’t quite trust and wanted to disable referer for them.

Simple. Just use the RefControl add-on for Firefox.

After installation, you should see a tiny button on the Add-on Bar, at the bottom of the Firefox window. When you are at the website, click on the button and select “RefControl Options for This Site” and you will have this dialog box:

block referer in Firefox

Just select your intended option for this particular site. If you do not want to send any referer information to this site, just select “Block – send no referrer” and click OK.

That’s it. Now Firefox will send no HTTP referer information to this particular site but will keep sending it to all other sites.

{ Comments on this entry are closed }

When I encounter the incorrect key file for table error, it’s almost certainly because the disk is full and MySQL can’t write to the tmpdir. The solution is simple, just move tmpdir to another partition with enough disk space.

Open my.ini and change tmpdir to another directory with enough disk space. Restart MySQL and that should do it.

However on Windows, such as for WAMP, you need to make sure you use slashes (/) rather than backslashes (\) in the path for tmpdir in my.ini, or it would be this error and mysqld would simply refuse to start:

InnoDB: Error: unable to create temporary file; errno: 2

{ Comments on this entry are closed }

By default, phpMyAdmin shows an estimated number of records for InnoDB tables that have more than 20,000 rows. It can vary by every fresh as much as 50% or even more. Makes it hard to get an exact number of records for the tables as we have to explicitly run an SQL query to do that:

SELECT COUNT(*) FROM table_name

While it would make it a bit slower for phpMyAdmin to open up the database tables list page because it has to count the exact total number of records of each table in the database by this query, it’s worth it for some of us as we want to know the exact number of rows the InnoDB table currently has. phpMyAdmin does it for MyISAM tables, and we want it to do the same with InnoDB tables.

So how can we make phpMyAdmin show exact number of records for InnoDB tables?

Simple. Just open the config.inc.php in your phpMyAdmin installation directory and add this line:

$cfg['MaxExactCount'] = 2000000;

This configuration parameter sets the threshold that phpMyAdmin executes COUNT(*) against the table.

In this case, if the total number of recrods in this InnoDB table is larger than 2,000,000, the Rows count will be estimated, starting with a wave sign, ~; on the other hand, if the total number of records in this InnoDB table is smaller than 2,000,000, phpMyAdmin will run COUNT(*) against the table so an exact Rows count is displayed.

You get the idea.

To make phpMyAdmin show exact number of rows on all InnoDB tables, simply make the parameter $cfg[‘MaxExactCount’] large enough.

{ Comments on this entry are closed }

Today, most of our online data transmissions pass through fiber-optic cables. And as most of us know, fiber-optic cables are simply long, thin strands of glass which allow light to bounce and refract from one-end to the other without leaving the cable. It’s a bit like shining a flashlight down a long, mirrored tube.

One of the great benefits of fiber-optic cabling is that it can transmit multiple signals at the same time by combining different colors. (Photons with different wavelengths) Because of this, the number of simultaneous signals which can pass through a fiber optic cable is theoretically limited only by the accuracy and precision of the hardware. Compare this with a copper wire, which can only send one signal at a time.

But few people really appreciate how much incredible science goes into fiber optic networking, or the fascinating principles which govern this technology that has such a profound impact on our daily lives.

One of these principles is what’s often called the “Lifeguard Principle”, also referred to as the “principle of minimal action” or “principle of least action”.

Now I’m not a scientist, and I may slightly over-generalize in certain areas. But I’ll attempt to present these principles in the most accurate way that I can in laymen’s terms.

We all know that the shortest path from point A to point B is a straight line. But what about the FASTEST distance?

How to get from A to B?

For example, let’s assume that you’re a lifeguard that sees a drowning swimmer off in the distance. The shortest route to that swimmer would be to follow a straight line towards the swimmer through land and water.

From A to B in shortest path

But in a life-or-death situation, every second counts. The running portion of this trajectory may be very fast, but the swimming portion will be very slow. If you waste too much time swimming, the person you’re trying to save might drown.

From A to B in potentially shortest time (fasted path)

Another approach might be to run along the beach until you reach the point which offers the shortest swimming distance. Although this may take care of the swimming problem, now you’ve spent too much time running. Yes, this route may be faster than the “straight line” approach, but it’s still possible to shave off a few more precious life-saving seconds.

Somewhere in between these 2 strategies, there is a sweet spot where the combination of swimming and running time is reduced to the absolute minimum.

From A to B in shortest time (fasted path)

It’s possible to calculate this optimal trajectory using complex calculus, but I won’t bore you with that for this article.

Now let’s take this principle and apply it to a photon of light instead of a lifeguard.

If you’re standing in a boat and you point a laser at a fish in the water, what will happen?

Photons automatically travel in fasted path

Of course, we all know that the light beam will bend when it hits the surface. But how does the beam “decide” which angle to bend at?

Scientists have been able to calculate the speed at which light travels through different substances such as air and water. And when you combine the speed of light through air and the speed of light through water, you can make an interesting observation.

If you add up the time it takes for the light to go from the laser to the water and the time it takes for the light to travel from the water’s surface to the fish, it turns out that the trajectory which is taken by those photons is the shortest possible route for a photon of that wavelength.

In other words:

If the photon was a lifeguard and the fish was a drowning swimmer, the light would always pick the route which requires the least amount of time to reach the swimmer. And it’s this principle which dictates how the light decides to refract when it reaches the water’s surface.

To an untrained layman, this seems almost miraculous. It’s almost as if the photon could see into the future and plot a path to its final destination before it ever left the laser. And it’s almost as if the photon was able to perform the difficult calculus required to find the shortest possible path.

Of course, it’s not quite that simple. But it’s a clear demonstration of how beautiful science can be.

This least-action principle is also critical to optical networking technology. When you send a message through a fiber optic cable, it truly does take the fastest possible route to its final destination. And if it wasn’t for the principle described above, Internet connectivity would not be possible.

There are many other implications which result from this phenomenon, but they are simply beyond my understanding so I couldn’t speak to those issues.

About The Author: Patrick Jobin is a technical writer with Storagepipe Solutions, a leader in serious server online backup services for datacenters and corporate networks.

{ Comments on this entry are closed }