Skip to content

Instantly share code, notes, and snippets.

View davidalexander's full-sized avatar

David Alexander davidalexander

View GitHub Profile
@davidalexander
davidalexander / .htaccess
Created July 16, 2011 21:15
Magento fix for IE9 issues
### 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
@davidalexander
davidalexander / gist:1086773
Created July 16, 2011 20:47
.htaccess Environments
# http://thenerdary.net/articles/entry/htaccess-environments
RewriteEngine On
RewriteBase /
### SET UP ENVIORNMENTS ###
# Default to master
RewriteRule .* - [E=ENVIRONMENT:master]
@davidalexander
davidalexander / gist:1086732
Created July 16, 2011 20:26
jQuery Dismiss Lightbox with ESC
// 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:1086437
Created July 16, 2011 15:17
Shell command to find size of folder
# single folder
du -sh [FOLDERNAME]/
# subfolders
du --max-depth=1 [FOLDERNAME]/ | sort -n -r
@davidalexander
davidalexander / gist:1086441
Created July 16, 2011 15:23
Make links within a website root relative
<?php
function make_href_root_relative($input) {
return preg_replace('!http(s)?://' . $_SERVER['SERVER_NAME'] . '/!', '/', $input);
}
?>
@davidalexander
davidalexander / iframe.js
Created July 16, 2011 16:43
Add a class to the html tag if the page is being loaded in an iframe
if (window.location !== window.parent.location) {
document.documentElement.className += ' iframe';
}
@davidalexander
davidalexander / gist:1086440
Created July 16, 2011 15:20
VMware Fusion - Find Magic IP

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 mtu 1500 
@davidalexander
davidalexander / index.html
Created July 16, 2011 15:33
Simple jQuery Tabs
<!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">
@davidalexander
davidalexander / remove_svn.sh
Created July 16, 2011 15:14
Recursively Delete .svn Directories
find . -type d -name .svn -exec rm -rfv {} \;
@davidalexander
davidalexander / magento_trigger_500.php
Last active August 29, 2015 14:10
trigger magento 500 error
<?php
// Trigger 500 response
// allows styling of "There has been an error processing your request" page
// note setIsDeveloperModes should be false to prevent xxception being thrown
throw new Exception('you shall not pass');