Skip to content

Instantly share code, notes, and snippets.

View SchumacherFM's full-sized avatar

Cyrill Schumacher SchumacherFM

View GitHub Profile
@SchumacherFM
SchumacherFM / Magento-HHVM.md
Last active May 17, 2018 18:26
Running Magento Enterprise Edition with Facebook HipHop HHVM

Running Magento Enterprise Edition with Facebook HipHop HHVM

Prerequisites

Hardware

MacBook Air (MBA) Mid 2012

@SchumacherFM
SchumacherFM / Renderer.php
Last active February 18, 2018 17:50
Love it! ;-) Best practice switch/case statement in PHP. Magento 3rd party module. #fail
<?php
switch ($templateOption->getType()) {
case "select":
$block = "painModule/select";
$template = "painModule/type/select.phtml";
break;
case "radiobuttons":
$block = "painModule/radiobuttons";
$template = "painModule/type/radiobuttons.phtml";
break;
@SchumacherFM
SchumacherFM / switch.php
Created October 10, 2013 04:30
The always nice and awesome and total cool Switch Statements :-(
<?php
/**
* Returns a PDO parameter constant to bind a variable with
*
* @param string $type Which variable type to check
*
* @return int PDO parameter constant
*/
public static function getBindConstant($type)
@SchumacherFM
SchumacherFM / arrayToInt.php
Created October 18, 2013 01:49
array_map('intval',...) vs arrayToInt()
<?php
$integers = range(100, 1000);
foreach ($integers as &$int) {
$int = (string)$int;
}
function arrayToInt(array $arr)
{
@SchumacherFM
SchumacherFM / ace.js
Created October 25, 2013 02:46
Ace Editor (http://ace.c9.io/#nav=about) with Diff
/*
load js libs:
'/Resources/public/js/lib/ace/ace.js'
'/Resources/public/js/lib/ace/mode-diff.js'
'/Resources/public/js/lib/ace/theme-chrome.js'
https://github.com/Slava/diff.js/blob/master/diff.js
*/
var data = { /*json from server ... */
after: [
@SchumacherFM
SchumacherFM / Subscribe.php
Created December 19, 2013 01:05
Adding a simple block cache per customer to MageMonkey will improve the load of the Magento Checkout OnePage Review section after the first hit. Maybe the cache keys are not that optimal. As I have seen the code in line 41-48 I've started immediately to cry :-( License: GPL https://twitter.com/centerax/status/413285266996989952
<?php
/**
* Checkout subscribe checkbox block renderer
*
* @category Ebizmarts
* @package Ebizmarts_MageMonkey
* @author Ebizmarts Team <[email protected]>
*/
class Ebizmarts_MageMonkey_Block_Checkout_Subscribe extends Ebizmarts_MageMonkey_Block_Lists
@SchumacherFM
SchumacherFM / Stats.md
Last active October 9, 2018 05:47
Comparing different storage systems for Magento

Magento Caching Test

Testing three type of caches: persistent, non-persistent and two-level.

Prerequisites

  • MacBook Air
  • 13-inch, Mid 2012
  • Processor 1.8 GHz Intel Core i5
  • Memory 8 GB 1600 MHz DDR3
@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.

@SchumacherFM
SchumacherFM / OAuth.php
Created March 26, 2014 00:38
Magento 1.7 and maybe 1.8 OAuth redirect bug according http://www.magentocommerce.com/boards/viewthread/438434/ This solution integrates without any rewrites or overrides.
<?php
class Zookal_Customer_Model_Observer_Controller_OAuth
{
/**
* @param string $url
*
* @return bool
*/
@SchumacherFM
SchumacherFM / keybase.md
Created April 1, 2014 09:03
Keybase proof

Keybase proof

I hereby claim:

  • I am schumacherfm on github.
  • I am cyrill (https://keybase.io/cyrill) on keybase.
  • I have a public key whose fingerprint is 076A 9DCE D5C2 63EE 438B 2BF7 3D7A E252 C8C7 9677

To claim this, I am signing this object: