My Favorite Vim Tips

Here 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 […]

camelCase to snake_case

Here is a TextMate command that will convert all of the selected text from camelCase to snake_case. This command is specifically designed for PHP. Thanks to PHP not having namespaces (until recently) many developers use PEAR naming conventions resulting in code that has class names like BP_Common::fancy_function(). This command will not convert the BP_Common.

Reality66 Naming Conventions

Here are the coding standards we use at Reality66. The purpose of these naming conventions and standards is to provide an easy to remember set of rules so all Reality66 developers write consistent code without having to constantly reference coding standards documentation. The primary intent is to have a small, easily memorized set of rules […]

If Statement Variable Scope In PHP

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 […]

WordPress register_activation_hook not firing

The 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

Normally 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 […]

John 3:16 In PHP and Ruby

John 3:16 in PHP $son = $god->loved($the_world); foreach($whosoever as $person) { if($person->believe($son)) { $son->everlasting_life($person); } } John 3:16 in Ruby son = god.loved(the_world) whosoever.each do |person| son.everlasting_life!(person) if person.believe?(son) end

Quickly Folding Functions In Vim

The is really a Vim tip on how to fold any code block including functions. It’s really helpful if you want to collapse a function or any other type of code block. Best of all, it is quick and easy to do. Navigate your cursor somewhere inside of the code block you want to fold. […]