Ubuntu Prevent Focus Stealing

If you find yourself typing away whilst something else loads or another window pops open and all of a sudden your typing has gone into a different window then this solution is for you Open gconf-editor. Open a terminal and type gconf-editor and hit return. Now navigate to /apps/compiz/general/screen0/options/focus_prevention_level key and set its value to 4. That’s it. You might actually decide that focus stealing is sometimes useful in which case you can always change it back. Read On →

Magento Post-upgrade: Illegal scheme supplied, only alphanumeric characters are permitted +SOLUTION

So one of our customer’s sites started throwing this error message immediately following an upgrade. Illegal scheme supplied, only alphanumeric characters are permitted Turns out 1.6.2.0 doesn’t like anything other than a-z and 0-9 in the store run code and the customer in question had underscores (_) in the store run code. The simple fix was to strip it out and alter the url to store code logic to match. Hope this helps someone else out there. Read On →

Tip: Javascript late-loading trick

Having issues with javascript dependencies or awkwardly structured html defining objects you need before run? This is a little trick I used combined with csnover’s roundrect.js to provide IE versions < 9 with border-radius rounded corners. Create a separate source file e.g. mylateloader.js and in it include the following code :- function myInArray(needle, haystack) { var length = haystack.length; for(var i = 0; i < length; i++) { var str = jQuery(haystack[i]).attr('src'); if(typeof(str) != 'undefined' && str.search('.*'+needle+'.*') > -1) return str; } return false; } jQuery(document).ready(function(){ var script = document.createElement('script'); url = myInArray('mylateloader.js', document.getElementsByTagName('script')); script.src = url.replace('mylateloader.js','mycoolminifiedfile.min.js'); document.getElementsByTagName('head')[0].appendChild(script); setTimeout("mycoolobject.run()",2000); }) That way, at document.ready(), mycoolminifiedfile.min.js is loaded from the same directory on the server as the late loader js and 2 seconds later, the mycoolobject.run() is called.

Tip: Copy CSS Selector in chrome

Okay, this is hacky but it really works, and saves a lot of time! To copy the css selector of an element in chrome, you need your developer tools open popped-out of chrome, not docked but here is the trick :- Inspect the element that you want, be sure it’s selected in developer tools, then press F12. This will open a second developer tools window inspecting the first developer tools. Then, insert the following two lines of javascript magic, one at a time - the first pulls jQuery into the developer tools and the second runs a function to build the css path and output it into the console! Read On →

PHP List Function Silently Failing? Solution

If you use PHP’s list function to quickly extract array values out into dollar variables then you might have an issue where it just doesn’t work for some reason. The problem is that list only works with numeric arrays. If you are using an associative array (with strings for keys instead of numbers) then list will not work. There is any easy solution though, simply change: $array = array('a'=>1, 'b'=>2, 'c'=>3); list($a, $b, $c) = $array; To: $array = array('a'=>1, 'b'=>2, 'c'=>3); list($a, $b, $c) = array_values($array); And it will work as you expect.

TIP: SSH add a tunnel to a running session

Useful tip - if you’ve ever been ssh’d into a remote machine and don’t want to break the connection or open a new session just to add a new tunnel, there is a way Press [return] then ~ then C to get to an ssh> prompt, then you can add tunnels as you would at the command line e.g. -L 80:localhost:8080 Then press [return] to return to the session you were running. Read On →