Skip to content

Instantly share code, notes, and snippets.

@ajbonner
ajbonner / adminhtml.xml
Created August 11, 2012 11:32
Disable Magento Adminhtml Menu Option
<?xml version="1.0"?>
<!-- Disable Catalog Price Rules Menu Entry -->
<config>
<menu>
<promo translate="title" module="catalogrule">
<children>
<catalog translate="title" module="catalogrule">
<depends>
<module>Disable_This_Module</module>
@ajbonner
ajbonner / core_file_storage_fix.sql
Created August 16, 2011 17:12
Fix for magento 1.5.x base table or view not found 'core_file_storage'
DROP TABLE IF EXISTS core_file_storage;
CREATE TABLE IF NOT EXISTS core_file_storage (
`file_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`content` LONGBLOB NOT NULL,
`upload_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`filename` varchar(255) NOT NULL DEFAULT '',
`directory_id` int(10) unsigned DEFAULT NULL,
`directory` varchar(255) DEFAULT NULL,
PRIMARY KEY (`file_id`),
UNIQUE KEY `IDX_FILENAME` (`filename`, `directory`),
@ajbonner
ajbonner / tablesize_report.sql
Created July 14, 2011 14:21
Get a list of large tables within a mysql database
SELECT count(*) tables,
concat(round(sum(table_rows)/1000000,2),'M') rows,
concat(round(sum(data_length)/(1024*1024*1024),2),'G') data,
concat(round(sum(index_length)/(1024*1024*1024),2),'G') idx,
concat(round(sum(data_length+index_length)/(1024*1024*1024),2),'G') total_size,
round(sum(index_length)/sum(data_length),2) idxfrac
FROM information_schema.TABLES
WHERE table_schema = 'database-name'
ORDER BY data_length+index_length DESC LIMIT 10;
@ajbonner
ajbonner / mail_attachment.php
Created June 28, 2011 15:42
Add an attachment to an email with Zend_Form
<?php
$mail = new Zend_Mail();
$mail->setFrom('[email protected]', 'Me')
->addTo($to)
->setSubject($subject)
->setBodyText($message);
$file = '/path/to/a/file';
@ajbonner
ajbonner / image_dimensions.rb
Created June 24, 2011 16:58
Get the dimensions of an image using ruby's image_size gem
#!/usr/bin/env ruby
require 'image_size'
pwd = File.dirname(__FILE__)
Dir.glob(pwd+'/*') do |file|
if (File.extname(file) == '.jpg')
fh = File.open(file, 'rb')
size = ImageSize.new(fh.read)
@ajbonner
ajbonner / mysqldump_bypattern.sh
Created June 9, 2011 15:08
Mysqldump data from database tables matching a pattern
#!/bin/bash
if [ $# -lt 5 ]; then
echo "Exports data from mysql database in tables matching a like pattern e.g. 'table_%'"
echo "Usage: $0 dbname dbuser dbpass pattern outputfile"
exit 1
fi
DBNAME=$1
DBUSER=$2