My Favorite Vim Tips

Vim IconHere are some of my favorite tips for working in Vim. I use MacVim but everything below should apply to any version of Vim you are using. Vim is such an amazingly powerful editor you can use it for years and still learn new stuff all the time. This is a small collection of features I use most often and find most helpful. Hopefully they will be helpful to you as well.

Continue reading

If Statement Variable Scope In PHP

PHP Logo Variable scope is the context within your code in which a variable is defined and able to accessed. If you try to access a variable that is out of scope, the variable will be undefined and you will not get the results you are expecting.

In PHP, variables all exist within the same scope when your code is inline or included in an include or require statement. Classes and functions have their own scope. If statements do not have their own variable scope.

Continue reading

WordPress register_activation_hook not firing

WordPressThe register_activation_hook() in WordPress looks for the “wp-content/plugins” directory in the plug-in file’s canonical pathname. So, if your files physically live somewhere other than in your WordPress tree, WordPress (PHP) calculates inappropriate paths.

The Solution: Move all your plug-in files into your WordPress tree and the activation hook should start firing.

Sort Text Column Numerically in MySQL

MySQL LogoNormally when you want to sort numerically on a column in your database you’d make the column some sort of numeric type such as an int. Sometimes, however, you are stuck with someone else’s schema and they have decided to store numbers in a text type column and you need to sort your results numerically because an alphabetic sort on a number does not produce the results you want. There is a quick trick to that makes this easy.

Continue reading

John 3:16 In PHP and Ruby

John 3:16 in PHP

John 3:16 in Ruby