Skip to content

Instantly share code, notes, and snippets.

@unirgy
unirgy / PHP-SIGNED.md
Last active November 30, 2017 16:56
PHP-SIGNED

PHP-SIGNED

Abstract

This is a proposal for PHP extension to disable running unapproved PHP code, uploaded using security holes or by any other means.

Components

  1. Master key is saved in php.ini (hidden in phpinfo)
  2. Signatures are saved in a file that lives in web or app root folder, 1 line per file/signature
class Sample_Model_Observer
{
protected $colToAdd = 'colname';
/**
* @param Varien_Event_Observer $observer
*/
public function urapidflow_profile_action( $observer )
{
$action = $observer->getData( 'action' );
$profile = $observer->getData( 'profile' );

Magento Scaling Hypotheses

Magento’s checkout throughput can increase to at least 8 times its current capacity and up to 26 times more in ideal conditions.

  1. The current checkouts per hour limit for large, real-world Magento stores is 4,500
  2. This limit cannot effectively be increased with more and/or better hardware
  3. The improper type handling in Magento’s SQL code is the cause of the current limit
  4. If one SQL query is fixed, large Magento stores can scale to a new, real-world limit of 120,000 checkouts per hour
  5. For commodity hardware, this new limit might be 36,000 checkouts per hour
<?php
class Apple_IDontCare_Model_Menu_Item_Plugin
{
public function afterGetTitle($result)
{
return '^' . $result . '^';
}
}
@IvanChepurnyi
IvanChepurnyi / Table.php
Last active July 11, 2022 10:44
Optimized options load
<?php
/**
* Optimized version of attribute source options model
*
* That allows to preload options once and reuse them instead of doing calls to db all the time
*
*/
class EcomDev_Optimization_Model_Resource_Attribute_Source_Table
extends Mage_Eav_Model_Entity_Attribute_Source_Table
@ekyo
ekyo / explain.zshrc
Created August 29, 2013 21:19
add the following to your .zshrc to be able to use 'explain' Example Use: > explain ls -ltrsa list directory contents -l use a long listing format -t sort by modification time, newest first -r, --reverse reverse order while sorting -s, --size print the allocated size of each file, in blocks -a, --all do not ignore entries starting with .
explain(){ curl -s $(echo "http://explainshell.com/explain/$1?args=${@:2}" | sed -e 's/ /+/g') |
sed -n '/<pre/,/<\/pre>/p' | sed -s 's/<[^>]*>//g' | sed -e 's/^ *//g;s/ *$//g' | grep '.' | cat }
delimiter ;;
drop procedure if exists build_catalog;;
create procedure build_catalog(IN categories INT, IN products INT)
begin
SET @category_count = 1;
SET @CATNAMEPREFIX = "Category ";
SET @CATURLKEYPREFIX = "cat-";
SET @CATURLPATHPREFIX = "catpath-";
SET @ROOTCATEGORY = 2;
SET @INCLUDEINMENU = 1;
@parhamr
parhamr / 0: Magento 1.12 Enterprise multi-store cluster configuration.md
Last active October 13, 2023 14:20
A highly available, fault tolerant, distributed, and load balanced LEMP cluster.
@JeffreyWay
JeffreyWay / gist:6176883
Created August 7, 2013 18:19
Add this to your bash_profile. Now, whenever you need to fetch your ssh-key, just type sshkey, and it'll be copied to your clipboard.
alias sshkey="cat ~/.ssh/id_rsa.pub | pbcopy && echo 'Copied to clipboard.'"
@bastianccm
bastianccm / Observer.php
Last active December 20, 2015 00:29
app/code/local/Mage/Catalog/Model/Observer.php, extended version including caching for topmenu, can save up to 200ms page loading - will be available as a module sooner or later ;-) Instead of always parsing the whole category layer to identify the active category the whole category structure is cached and only the data tree is parsed and the ne…
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php