Skip to content

Instantly share code, notes, and snippets.

@edulan
edulan / transpose.php
Created August 10, 2011 12:08
PHP matrix transpose using a functional approach
<?php
$matrix = array(
array('a', 1, 2),
array('b', 3, 4),
array('c', 5, 6),
array('d', 7, 8)
);
$transpose = array_reduce(
$matrix,
@amenk
amenk / xdebug.ini
Created July 1, 2013 13:39
Xdebug links for PHPStorm Remote Call Plugin
; Output links compatible with the PHPStorm Remote Call plugin running on the host.
; source: https://github.com/computerminds/parrot/pull/20/files
xdebug.file_link_format="javascript:var rq = new XMLHttpRequest(); rq.open(\"GET\", \"http://localhost:8091?message=%f:%l\", true); rq.send(null);"
@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
@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
//
@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 {
@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 }
@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
@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 ]]
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,
@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>