Skip to content

Instantly share code, notes, and snippets.

View steverobbins's full-sized avatar

Steve Robbins steverobbins

View GitHub Profile
@astorm
astorm / gist:7800119
Created December 5, 2013 04:30
A method to make the most careful of system designers weep.
protected function _getProtectedPropertyFromObject($property, $object)
{
$r = new ReflectionClass($object);
$p = $r->getProperty($property);
$p->setAccessible(true);
return $p->getValue($object);
}

It's been 9 years since the release of PHP, but my muscle memory still wants a double beat (as opposed to tripple) when I type function definitions.

class Baz
{
    function getSomething()
    {
    }

}

SET @DATABASE = 'prod';
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
WHERE `information_schema`.TABLES.table_schema = @DATABASE
@molotovbliss
molotovbliss / betterindexer.php
Last active May 1, 2017 20:37
Magento: only reindex invalidated indexes shell/indexer.php replacement
<?php
/**
* Add the parameter "reindexallrequired" to only index the indexers
* that are in need of processing to avoid doing full reindexes
* that disregard the state of the index as indexer.php does
*
* Usage:
* php shell/betterindexer.php reindexallrequired
*
* http://magento.stackexchange.com/a/62272/69
#!/bin/bash
################################################################################
# FUNCTIONS
################################################################################
# 1. Check required system tools
_check_installed_tools() {
local missed=""
@mgdm
mgdm / iteration.php
Last active October 12, 2017 16:12
Mandelbrot code demonstrating Recki-CT
<?php
/**
* @param double $cReal
* @param double $cImag
* @param int $maxIterations
* @return int
*/
function mandelbrotIteration($cReal, $cImag, $maxIterations)
{
@raybogman
raybogman / SupportDesk_FixAcl.php
Last active July 6, 2018 19:00
SupportDesk_FixAcl
<?php
/**
* SupportDesk_FixAcl.php v1.1
* SupportDesk (www.supportdesk.nu)
* 10/7/2015
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* It is available through the world-wide-web at this URL:
@SchumacherFM
SchumacherFM / README.md
Last active September 21, 2018 10:05
Avoiding database deadlocks in Magento 1.7

After having many deadlocks due to a high order volumne I've applied the these fixes to the core. Some can be found in a Magento forum. Before the fixes we could only process 1 order every 5-10 secs. Updating to Magento 1.8 is currently not an option but in 1-2 months.

1st Deadlock

Mage_Sales_Model_Abstract::_afterSave must be removed and replaced with afterCommitCallback. This is important to move the grid update (of sales_flat_order_grid) out of the transaction.

2nd Deadlock

Rewrite the method of the Mage_CatalogInventory_Model_Observer::reindexQuoteInventory() to remove the price reindexing from the transaction. That index process will also be fired in event sales_model_service_quote_submit_success.

@mpchadwick
mpchadwick / Mpchadwick_Missing_Acl_Checker.php
Created July 11, 2015 03:42
Mpchadwick_Missing_Acl_Checker.php
<?php
require_once 'abstract.php';
/**
* Generate a CSV of modules with admin routes that haven't implemented _isAllowed()
*/
class Mpchadwick_Missing_Acl_Checker extends Mage_Shell_Abstract
{
const MODULES_PATH = 'modules';
@peterjaap
peterjaap / removeTestDataResetEntitySeries.sql
Last active May 30, 2019 02:48
Remove orders, invoices, shipments, creditmemos, customers and quotes from Magento
# Empty relevant tables
DELETE FROM sales_flat_creditmemo;
DELETE FROM sales_flat_invoice;
DELETE FROM sales_flat_order;
DELETE FROM sales_flat_quote;
DELETE FROM sales_flat_shipment;
DELETE FROM customer_entity;
# Reset increment_ids
# Beware of store_ids when using multiple stores