Skip to content

Instantly share code, notes, and snippets.

# php_value memory_limit 64M
# magento config ->
php_value memory_limit 1G
@stephpy
stephpy / gist:1348385
Created November 8, 2011 17:04
Doctrine mystery
<?php
# THIS WORK
$qb->orderBy('uc.is_current DESC, uc.date_from', 'DESC')
# THIS NOT WORK
$qb->orderBy('uc.date_from DESC')
?>
@stephpy
stephpy / gist:2694572
Created May 14, 2012 15:27
MAGENTO best code
<?php
/**
* get address street
*
* @param int $line address line index
* @return string
*/
public function getStreet($line=0)
{
$street = parent::getData('street');
_______ _______ _
( ____ \|\ /|( ____ \| \ /\
| ( \/| ) ( || ( \/| \ / /
| (__ | | | || | | (_/ /
| __) | | | || | | _ (
| ( | | | || | | ( \ \
| ) | (___) || (____/\| / \ \
|/ (_______)(_______/|_/ \/
_______ _______ _______ _______ _ _________ _______
@stephpy
stephpy / gist:2858775
Created June 2, 2012 15:11
func_get_args
<?php
function foo() {
$args = func_get_args();
print "<pre>";
var_dump($args);
print "</pre>";
}
foo(1, 2, 3);
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@stephpy
stephpy / gist:3187406
Created July 27, 2012 10:53
array_diff ...
<?php
function array_diff_simple($a, $b)
{
$r = array();
foreach($a as $key => $val) {
if(!isset($b[$key])) {
$r[$key] = $val;
} else {
if(is_array($b[$key]) && !is_array($val)) {
switch (is_nan($diff) === false)
{
case $originalValue == $absValue:
case $originalValue * $absValue == 0 && $diff < pow($epsilon, 2):
case $diff / ($originalValue + $absValue) < $epsilon:
return $this;
}
$diff = new diffs\variable();
<?php
class Foo
{
public function bar()
{
$copy = clone $this;
echo $copy->baz();
}
private function baz()
@stephpy
stephpy / composer.json
Created August 27, 2012 10:34
composer
{
"name": "rezzza/myproject",
"description": "myproject",
"authors": [
{
"name": "Chuck norris",
"email": "chuck@norris.com"
}
],
"licence": "MIT",