Skip to content

Instantly share code, notes, and snippets.

Avatar

David Alexander davidalexander

View GitHub Profile
@davidalexander
davidalexander / remove_svn.sh
Created Jul 16, 2011
Recursively Delete .svn Directories
View remove_svn.sh
find . -type d -name .svn -exec rm -rfv {} \;
@davidalexander
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
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:

vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500  
@davidalexander
davidalexander / gist:1086441
Created Jul 16, 2011
Make links within a website root relative
View gist:1086441
<?php
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">
<head>
<meta charset="utf-8">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="tabs.js"></script>
</head>
<body>
<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
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
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
davidalexander / gist:1086773
Created Jul 16, 2011
.htaccess Environments
View gist:1086773
# http://thenerdary.net/articles/entry/htaccess-environments
RewriteEngine On
RewriteBase /
### SET UP ENVIORNMENTS ###
# Default to master
RewriteRule .* - [E=ENVIRONMENT:master]
@davidalexander
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>
</IfModule>
<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