Skip to content

Instantly share code, notes, and snippets.


David Alexander davidalexander

View GitHub Profile
davidalexander /
Created Jul 16, 2011
Recursively Delete .svn Directories
find . -type d -name .svn -exec rm -rfv {} \;
davidalexander / gist:1086437
Created Jul 16, 2011
Shell command to find size of folder
View gist:1086437
# single folder
du -sh [FOLDERNAME]/
# subfolders
du --max-depth=1 [FOLDERNAME]/ | sort -n -r
davidalexander / gist:1086440
Created Jul 16, 2011
VMware Fusion - Find Magic IP
View gist:1086440

VMware Fusion

Most of us (developers) already use virtualization in some form for testing, but in order to take advantage of this particular environment – MAMP with virtual hosts – we need to update the hosts file on the virtual machine so that it resolves the domains to the Mac's IP.

One catch: if you’re on a latop, chances are the Mac’s IP will change often. That’s why we need to get the secret IP the VM uses to talk to the Mac. Here’s how we find it:

Type ifconfig vmnet1 into a Terminal window. You should get a return like this:

davidalexander / gist:1086441
Created Jul 16, 2011
Make links within a website root relative
View gist:1086441
function make_href_root_relative($input) {
return preg_replace('!http(s)?://' . $_SERVER['SERVER_NAME'] . '/!', '/', $input);
View index.html
<!doctype html>
<html lang="en" class="no-js">
<meta charset="utf-8">
<script src=""></script>
<script src="tabs.js"></script>
<div class="tab-container">
View gist:1086455

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

davidalexander / iframe.js
Created Jul 16, 2011
Add a class to the html tag if the page is being loaded in an iframe
View iframe.js
if (window.location !== window.parent.location) {
document.documentElement.className += ' iframe';
davidalexander / gist:1086732
Created Jul 16, 2011
jQuery Dismiss Lightbox with ESC
View gist:1086732
// Bind a custom event to the lightbox that can be triggered when it needs to be dismissed:
$('.lightbox').bind('dismiss', function() {
// code to dismiss lightbox
// Then just trigger that event when escape it pressed:
$(document).bind('keyup', function(e) {
if(e.keyCode == 27) {
davidalexander / gist:1086773
Created Jul 16, 2011
.htaccess Environments
View gist:1086773
RewriteEngine On
RewriteBase /
# Default to master
RewriteRule .* - [E=ENVIRONMENT:master]
davidalexander / .htaccess
Created Jul 16, 2011
Magento fix for IE9 issues
View .htaccess
### IE users need a little help (Magento+IE9=bad times) ###
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
BrowserMatch MSIE ie
Header set X-UA-Compatible "IE=EmulateIE8,chrome=1" env=ie
<IfModule mod_headers.c>
# Because X-UA-Compatible isn't sent to non-IE (to save header bytes),
# We need to inform proxies that content changes based on UA