Get latitude and longitude of an address using google maps

Google doesn’t make it easy to show you the latitude and longitude of an address you search in google maps, but there’s an easy way to get the info.

  1. go to google maps, type the address, and click search
  2. once you’ve found it, go to your address bar and clear what’s in it
  3. paste: javascript:void(prompt('',gApplication.getMap().getCenter())); into the address bar
  4. use the coordinates for whatever you wish!

VirtualHostX and mod_rewrite

To enable mod_rewrite manually, see: OS X server tips but if you are using VirtualHostX it changes your default config file. Add the following code to the Directives box:

Options FollowSymLinks
AllowOverride All AuthConfig
Order deny,allow
Deny from all

if you’re using the new version of VirtualHostX, make sure that you select Directory from the dropdown, then use:

Options FollowSymLinks
AllowOverride All AuthConfig

WordPress plugin DB access framework

While designing a recent WordPress plug-in for TruthMedia that was designed to follow MVC, I had an awful lot of database work to do, and it needed to all be properly secured, which was a lot of work, and while making a rather large change to the way the database worked, I realized that writing all the db code by hand was crazy inefficient.

So I wrote a class that you can extend with any model class of your own, and it will automatically have create, read, update, and delete functionality with no more work required. It also uses all of the WordPress security features to properly escape everything and prevent injection. Although, if you can crack it I’d love to hear from you!

Click here to download!

This is how it works:

  1. Create a new class (ex. person)
  2. Give that class instance variables (ID, FirstName, LastName, Address, PhoneNumber, PostalCode, HairColour…)
  3. Make sure that you add accessor methods (getters and setters) for the ID (although it’s good practice to have them for all instance variables). Depending on your project, it may be a good idea to run stripslashes() on your string get functions so that they don’t show up with escaping. You may want to run WordPress’ attribute_escape() on setters, however, again, depending on your set up this may be unnecessary.
  4. Write your SQL code to create a table named (wordPress prefix)(plugin prefix)person (ex. wp_wec_person)
  5. Make sure you call your primary Key personID **This is very important, without this, the system breaks down**
  6. If you wish to store variables in this class, you can modify them to be private, and they won’t be written to the database

In your class, extend the class name, so for example:

class person extends wec_db {

var $ID;

var $FirstName;

function __construct($id = null, $autoload = true){

//If we are given an ID







//getters and setters, and any other methods for this object


Setup Note: to keep your plugin from stepping on the toes of others, make sure you change the prefix at the top of the class. Also, changing the name of the class to (plugin prefix)db (example:wec_db) will make sure that it doesn’t interfere with anyone else’s if they’re using this class!


Create / Add

$person = new person();





$person = new person($personID);


$person = new person($personID);


$person = new person($personID, false);




$person = new person($personID, false);


Post any questions in the comments! I’d love to hear from you!

Cause a field to be auto-focused when the page is done loading

So, wouldn’t it be user friendly, if when you went to a form page in a document, if the cursor was automagically positioned at the first field in the form?

Why, yes it would. Try:

Event.observe(window, 'load', function(){
     try {

     catch (e) {}

after your </form> tag. This requires the prototype javascript library

Using WP_Query in WordPress 2.7

So I was trying for the last week or so to use three loops on a single page, to display categorized pages, and couldn’t figure out why it didn’t work. (I used the plugin page category plus to put pages in categories).

Anyways, if you want pages to be shown in a categorical listing, use post_type=page in the query string. Otherwise it’ll only show posts by default, which didn’t happen in previous versions! Mine looked like this: <?php $sportsQuery = new WP_Query(‘category_name=Sports Pages&post_type=page’); ?>

//Loop goes here…

Hope this helps somebody. I know I’ll be coming back to it when I forget!

For more info see: