Skip to content

Instantly share code, notes, and snippets.

Avatar

David Alexander davidalexander

View GitHub Profile
@davidalexander
davidalexander / gist:11351615
Created Apr 27, 2014
magento - get all quoted translation strings
View gist:11351615
# https://twitter.com/mrsopacua/status/447892121283223552 (@mrsopacua)
find app/design/frontend -type f -exec perl -ne 'while($_ =~ /(?<=\W)__\(\s*([\x27\x22])(.+?)\1\s*\)/g) { print "$2\n"; }' {} +
@davidalexander
davidalexander / largest_tables.sql
Created Jul 16, 2014
get largest 10 tables in all SQL databases
View largest_tables.sql
-- http://www.mysqlperformanceblog.com/2008/02/04/finding-out-largest-tables-on-mysql-server/
SELECT
CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM
information_schema.TABLES
@davidalexander
davidalexander / gist:f938f8b4d14b82581cfb
Last active Aug 29, 2015
resend order emails from Magento admin for local testing
View gist:f938f8b4d14b82581cfb
<?php
// app/code/core/Mage/Sales/Model/Order.php
// comment the following lines arround ln.1272
// if ($this->getEmailSent()) {
// return $this;
// }
@davidalexander
davidalexander / admin_reset.sql
Created Sep 9, 2014
Magento Admin gives 404 due to admin website not having id of 0
View admin_reset.sql
SET FOREIGN_KEY_CHECKS=0;
UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;
@davidalexander
davidalexander / magento_trigger_500.php
Last active Aug 29, 2015
trigger magento 500 error
View magento_trigger_500.php
<?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');
@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 {} \;
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">
@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: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);
}
?>