Skip to content

Instantly share code, notes, and snippets.

@lstrojny
lstrojny / app--code--local--Varien--Autoload.php
Created April 16, 2013 11:27
Replace Magento autoloader with composer based autoloader. Note: you are losing the ability to use the compiler.
<?php
/**
* Classes source autoload
*/
class Varien_Autoload
{
/** @var \Composer\Autoload\ClassLoader */
private static $autoloader;
/** @var self */
@josephj
josephj / array_merge_recursive_distinct.php
Last active September 10, 2023 07:52
Useful PHP script when you want to merge multiple arrays like Y.merge().
<?php
/**
* Copy from http://www.php.net/manual/en/function.array-merge-recursive.php#92195
*
* array_merge_recursive does indeed merge arrays, but it converts values with duplicate
* keys to arrays rather than overwriting the value in the first array with the duplicate
* value in the second array, as array_merge does. I.e., with array_merge_recursive,
* this happens (documented behavior):
*
* array_merge_recursive(array('key' => 'org value'), array('key' => 'new value'));
@antonmedv
antonmedv / DotNotation.php
Last active August 11, 2022 13:47
Dot notation for access multidimensional arrays.
<?php
/**
* Dot notation for access multidimensional arrays.
*
* $dn = new DotNotation(['bar'=>['baz'=>['foo'=>true]]]);
*
* $value = $dn->get('bar.baz.foo'); // $value == true
*
* $dn->set('bar.baz.foo', false); // ['foo'=>false]
*
@stevenharman
stevenharman / exit_code_matches.rb
Created April 10, 2012 22:39
Rspec matchers for testing exit codes.
require 'rspec/expectations'
module ExitCodeMatchers
extend RSpec::Matchers::DSL
matcher :terminate do
actual = nil
match do |block|
begin