Skip to content

Instantly share code, notes, and snippets.

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' );
@yuya-takeyama
yuya-takeyama / fizzbuzz.php
Created January 23, 2011 18:07
FizzBuzz code golf.
<?for(;$i++<100;)echo $i%15?$i%5?$i%3?$i:Fizz:Buzz:FizzBuzz,"
";
@ashsmith
ashsmith / actionsxml.xml
Created May 30, 2012 12:43
Magento 1.7.0.0 Dataflow Profile for Importing Product Images
<action type="dataflow/convert_parser_csv" method="parse">
<var name="delimiter"><![CDATA[,]]></var>
<var name="enclose"><![CDATA[]]></var>
<var name="fieldnames"></var>
<var name="map">
<map name="sku"><![CDATA[sku]]></map>
<map name="image"><![CDATA[image]]></map>
<map name="image_label"><![CDATA[image_label]]></map>
<map name="small_image"><![CDATA[small_image]]></map>
<map name="small_image_label"><![CDATA[small_image_label]]></map>
var ALPHA = 'abcdefghijklmnopqrstuvwxyz',
ALPHA_UPPER = ALPHA.toUpperCase(),
NUMERIC = '0123456789',
PUNCTUATION = '-!@£$%^&*()[]{}\'"/?.>,<;:\\|~`€#',
UNDERSCORE = '_',
WHITESPACE = '\x20\t\n\r\f\v\xa0\u2028\u2029\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff'; // thanks Mathias!
var SHORTHAND_CC = {
'\\S': ALPHA + ALPHA_UPPER + NUMERIC + PUNCTUATION + UNDERSCORE,
'\\s': WHITESPACE,
@SlexAxton
SlexAxton / updatechromium.sh
Last active December 15, 2015 02:49
add this function to your .zshrc or .bashrc file to update chromium to the latest nightly with a command.
updatechromium () {
Platform='unknown'
platform='unknown'
unamestr=`uname`
case "$unamestr" in
('Darwin') Platform="Mac"
platform="mac" ;;
('Linux') Platform="Linux"
platform="linux" ;;
(*) if [[ $# = 2 ]]
@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
@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 }
@jayelkaake
jayelkaake / Version.php
Created December 30, 2011 22:33
Magento version/edition helper for determining the Magento BASE version (regardless of edition) and adds functions to check if Enterprise, Professional or Community are being run.
<?php
/**
* Magento version/edition helper for determining the Magento BASE version (regardless of edition) and adds functions to check if Enterprise, Professional or Community are being run.
* Adds isMageCommunity(), isMageProfessional() and isMageEnterprise()
*
* @category TBT
* @package TBT_Rewards
* @author WDCA Sweet Tooth Team <contact@sweettoothhq.com>
*/
class TBT_Rewards_Helper_Version extends Mage_Core_Helper_Abstract {
@Vinai
Vinai / boris-mage.php
Last active September 10, 2016 15:33
PHP REPL with initialized Magento environment
#!/usr/bin/env php
<?php
//
// PHP REPL with initialized Magento environment
//
// Thanks to https://github.com/d11wtq/boris
//
// Drop this script in your $PATH and run it anywhere in a Magento directory tree to start the REPL
//
@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