Cam McVey: Web, Electronics, Music, Stuff

My plot of online goodness.

Author: Cam

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

Website: http://www.alfredapp.com/

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.

Asepsis

Website: http://asepsis.binaryage.com/

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.

Caffeine

Website: http://lightheadsw.com/caffeine/

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.

CheatSheet

Website: http://www.cheatsheetapp.com/CheatSheet/

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.

ClipMenu

Website: http://www.clipmenu.com/

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.

ColorSnapper

Website: http://colorsnapper.com/

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.

Dotfiles

Website: https://github.com/cowboy/dotfiles

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

Website: http://www.hotkey-eve.com/

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.

f.lux

Website: http://justgetflux.com/

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.

KeyRemap4MacBook

Website: https://pqrs.org/macosx/keyremap4macbook/

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.

PCKeyboardHack

Website: https://pqrs.org/macosx/keyremap4macbook/pckeyboardhack.html.en

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

Sequel Pro

Website: http://www.sequelpro.com/

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.

Slate

Website: https://github.com/jigish/slate

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

Website: https://www.irradiatedsoftware.com/sizeup/

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.

TotalTerminal

Website: http://totalterminal.binaryage.com/

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.

Doing something useful with your Caps Lock key (on a mac)

Ever not used your Caps Lock key? Yeah, me too — all the time. So, that’s a waste, right? Let’s do something about it.

Picture of a part of a mac keyboard, focussed on the CapsLock key

Mac Keyboard, CapsLock Key

My frustrations with Mac keyboards was something I wrote about in a previous blog post. I mentioned that I had remapped the Caps Lock key, so I thought I would expand on it a bit, in case it would be useful to you.

You’ll need to download two small (very useful) programs and configure some settings, but it’s easy and this will take maybe 10 minutes tops.

First download PCKeyboardHack and follow Steps 1, 2, and 3 detailed on that page. In step two, in the “Setting” tab, look for the entry for Caps Lock, click the little arrow to the left to open it up, and enter “110” in the keycode column. Close PCKeyboardHack.

Now download KeyRemap4MacBook and follow Steps 1, 2, and 3 on that page. After Step 3, in the “Change Key” tab, scroll down until you see the entry “For PC Users”. Open that entry up (click on the little arrow again) then open out the entry for “Change PC Application Key”. Now you can change the behaviour of the Caps Lock Key to any of these entries. I set mine to “Forward Delete” as I missed that functionality when moving from a PC keyboard. Once you’ve selected your chosen remapping, close KeyRemap4MacBook.

Well done, you just made that key more useful!

 

 

Cheese!

The wee man.

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.

On Mac keyboards and frustration

[Caveat: the following is an opinionated piece that you may or may not agree with. Also, my context is as a web developer: some of the following offenders are, of course, useful in other professions.]

Credit: berrytokyo

Credit: berrytokyo

I got a MacBook Pro recently, primarily because all the cool kids are creating the latest, greatest web tools on Mac systems and, frankly, the Windows guys are lagging behind. I found myself increasingly finding awesome tips/tricks/tools that came with the mac-only caveat which finishes with “I don’t know how you do this on a Windows machine, sorry.” I also got it because they’re so brilliantly designed to be both beautiful and powerful, and I dig that.

However, nobody mentioned the gaping hole of productivity that the non-standard (?) weird (UK) keyboard mapping! Argh!

  • The @ and ” symbols are swapped. Ever write an email? Yeah, me too. So I’ve had to re-learn where the @ symbols is. Annoying!
  • Page Up and Page Down are missing. This is really important to me as I use those keys A LOT to move around documents I’m editing.
  • The # symbol is completely missing! Any time you want to add colo(u)r to a webpage, you need that bad boy. Now it’s gone. This the worst change because, as an added annoyance, it’s been replaced with the never-ever-used-in-my-entire-life § (Section) symbol. What? Not to mention the equally useless ± as its shift+ partner.

Suffice to say, my first few weeks of Mac-ownership were filled with never-ending Google searches starting, “mac os x keyboard shortcut for …”. Now, I do know that all of these things can be overcome with judicious use of modifiers (e.g., Page Up is ?+? [cmd + up-arrow]), but even so, it’s a pain.

Then I stumbled on a superb bit of software called KeyRemap4MacBook. It is free and it is brilliant. I have now re-mapped several keys on this laptop to be more useful to me and I am very grateful to the genius Takayama Fumihiko for it. Though I haven’t gone as far a re-mapping the @ and ” symbols, I’ve made the this machine work better for me, and that’s pretty cool.

Right now, here’s how I have it set up:

  • When I hit the ‘§’, I get a lovely ‘#’.
  • Along with PCKeyboardHack, I’ve remapped the Caps Lock key to be “forward delete”
  • The Eject key now shows the desktop
  • The right-hand ? key is now Home (“Go to start of line”)
  • The right-hand ? key is now End (“Go to end of line”)
  • Also really handy: “Press ?+Q twice to Quit Application”

So, I’ve tamed the beast, somewhat. And I’ve forced myself to use the @ key in the wrong place. And I’m now pretty much up-to-speed with my Mac, and am enjoying playing with all the clever toys the cool kids are creating.

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('//remotedomain.com/api/?x=' + 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]

Loopy Deux

A good friend of mine was talking about his guitar pedal board and some issues he was having with a couple of pedals on there. I offered to have a look. Instead of raking around in the guts of his decades-old pedal to make it true bypass, I figured it would be easier to construct something that would allow him to leave his pedal on all the time, but to completely remove it from the audio signal when not needed. I sat down and sketched out an idea that I thought would work and then proceeded to get the parts and assemble it.

THEN I had the bright idea of checking online to see if anyone else had done such a thing and what, if anything, I had missed in my design. Of course, plenty of folks make these type of devices all the time, so no invention here. Ah well!

Well all the stuff arrived and I pulled it together over a week or so — an hour here, an afternoon there — and the Loopy Deux was born. I named “Loopy Deux” because it loops and there’s two of them. I had “Loopy Doo” in my head and realised that “doo” (deux) in French means “two”, so the name stuck! I learned some things through it and had to assemble a number of tools to produce it which will come in handy for the next two projects being born out of this one.

The nice thing about this pedal is that it solves more than one problem. It’s great for removing a particularly noisy or tone-sucking pedal out of the audio signal, but the other nice thing is that it can help you set up several pedals into a particular sound by allowing you to switch them all off or on with a single switch instead of dancing around, trying to get them all switched as fast as possible.

I have some ideas on additional features that would make the pedal even more useful (buffers, blend pots, etc.), but that will have to wait until version deux!

Here’s some photos of the various stages.

By the way, if you are interested in getting something similar made, let me know — I’m always up for a challenge!

Welcome!

Cam McVeyHaving been online since the mid-Nineties, this is probably the 13th attempt at a personal website. And, as always, I have high hopes that this one will be the one. At any rate, please have a wander around here and get in touch if you so wish.

Blessings, Cam