Cam McVey: Web, Electronics, Music, Stuff

My plot of online goodness.

Category: Web Developement

Useful tools and apps

Picture of toolsI thought I’d write a quick post to talk about some of the wee tools and apps that I use pretty much every day to make life a little easier. Some were particularly useful in my transition from Windows to OS X. Hope you find this useful!

Alfred 2


This is a nice launcher app that you can quickly pop up, type anything, and it sort of knows what you’re getting at and gives you a quick list of files, apps, web seach, etc. to get the info you’re looking for. Saves a couple of keypresses when doing a new Google search.



When I first moved over to a Mac from Windows, I couldn’t believe OS X splatted these .DS_Store files in EVERY folder. What a pain! It took me about half a day to get sick of that, so I found Asepsis which cleverly deals with these files. Yay.



I hated the fact that the screensaver would kick in while watching videos (but appreciated it at other times). If you want to keep your screensaver but want more temporary control, Caffeine is for you.



When moving from Windows to OS X, I struggled to get my head around the differences and conventions of keyboard shortcuts. CheatSheet is nice in that, when you’re in an app, holding down the CMD key will pop up a ‘cheat sheet’ of all available Keyboard Shortcuts available in that app.



I’m a big user of clipboard apps — they are a time saver (and, occasionally a life saver) — so finding a good one was a priority. This was the best of the several I tried.



Nice wee app that sits in your menu bar and can grab a colour from anywhere on the screen. When you click to select the colour, it sticks it in your clipboard ready to be pasted into whatever you’re working on.



Cowboy, aka Ben Alman (of Grunt and others fame), created this as his personal bash environment setup, so it’s a nice way of setting up your prompt in Terminal and gives you some nice defaults, some useful aliases, and good integration with Git through a nifty prompt.



Eve is great for new OS X users that want to learn keyboard shortcuts because any time you use your mouse to select a menu item, Eve pops up to show you the shortcut you could have used. Forced myself to use it for two weeks before feeling like I could legitimately turn it off.



Useful app that changes the tone of the colour of your screen after sunset. Warms up the colour tone to rest your eyes. Nice wee feature to temporarily disable which is useful when dealing with graphics/video production/manipulation.



Great app to help anyone transitioning from Windows (or anyone looking to customise their keyboad). Lets you reassign what a key does. Very stable and very configurable.



Sister app to KeyRemap4MacBook, I use this to remap my Caps Lock key to something more useful. I wrote about this.

Sequel Pro


Brilliant app used to manage a local (or remote) MySQL server. Really nice interface, powerful helper features to manipulate the data, including a nice query window with exporting of results.



If you need total control over your app windows including size, shape and location, and you have the time and drive to learn it, there’s nothing better out there.



SizeUp is a nifty app that allows you to move and resize your app windows. Quick to learn and quite configurable. Great for overcoming the insanity that is OS X full size vs full screen. Full size doesn’t mean all–of–the–screen, and full screen means you–may–not–work–on–anything–else. Nonsense. SizeUp sorts this out.



I use the terminal a lot (one of the reasons for moving to a Mac was to get a ‘real’ command line). TotalTerminal gives some nice configuration options and makes a terminal a shortcut away. Used many multiple times a day.

Finding the WordPress root folder from outside WP

Have you ever needed to locate the root folder for a WordPress installation? If you’re checking from a page that is loaded up as part of WP, it’s easy; just use the ABSPATH constant, which is set up at the top of your wp-load.php file.

wpcodeHowever, if you need the root folder from within a page that is outside of WP, it’s a little more tricky. You don’t have access to the ABSPATH constant, and you don’t have built in access to the database to check for ‘wp_dir’ in the options table. [Of course, you could query the db if you have access details: something like “select option_value from wp_options where option_name ='wp_dir';” would do it.]

If the page is in a folder that is below the WP root folder though, there’s a nicer way. I wrote a little recursive function that checks a folder for the existence of a named file and, if it’s not there, moves to the parent folder and checks again. If it’s found, it returns the path to the file. So, if the file is below the root folder, this function will eventually find the root WP folder if you search for something like ‘wp-load.php’ or something else that generally lives in that folder.

Here’s the function with some code to demo how it’s used:

function find_file($filename, $path){
	$filepath = $path.'/'.$filename;
	if (!file_exists($filepath)){
		$filepath = find_file($filename, dirname($path));
	return $filepath;
$path_to_wpload = find_file('wp-load.php', __DIR__);

Hopefully that’s useful to someone. If you have an improvement to the function, or another (better) way to do the same thing, please add a comment.

jQuery and JSONP Shenanigans

If you ever catch yourself messing around with jQuery and are trying to make JSONP calls using .getJSON(), just remember that since you’re (probably) making a cross-domain request, the .error() handler is not thrown. Which means, if you have any control over the uri that is being called, DON’T name the response “Error” when there’s a problem as you’ll never see it.

I was making this call:
$.getJSON('//' + someInput + '&callback=?', function(data){…}

and the execution was skipping right over the code in that block, given a response from the server of:
'[{"Error": "Some problem happened"}]'

In the end, the solution was to change the error message from the server from saying “Error” to something else, e.g.:
'[{"Problem": "Some problem happened"}]'

Hope that helps someone out and saves them the 2 hours I just lost. Though I guess I did learn something new!

[Note: this refers to jQuery 1.7.2]