Skip to content

Instantly share code, notes, and snippets.

View ProcessEight's full-sized avatar
💻
Working remotely

Simon Frost ProcessEight

💻
Working remotely
View GitHub Profile
@victorbstan
victorbstan / php_object_to_array.php
Created December 17, 2010 04:18
recursively cast a PHP object to array
<?php
/*
This function saved my life.
found on: http://www.sitepoint.com/forums//showthread.php?t=438748
by: crvandyke
It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?!
*/
$array = json_decode(json_encode($object), true);
@nikic
nikic / microbench.php
Created June 22, 2012 23:42
Microbenchmark of generator implementation
<?php
error_reporting(E_ALL);
function xrange($start, $end, $step = 1) {
for ($i = $start; $i < $end; $i += $step) {
yield $i;
}
}
@nikic
nikic / coroutine.php
Created July 14, 2012 13:25
A coroutine example: Streaming XML parsing using xml_parser
<?php
error_reporting(E_ALL);
/* Data can be send to coroutines using `$coroutine->send($data)`. The sent data will then
* be the result of the `yield` expression. Thus it can be received using a code like
* `$data = yield;`.
*/
/* What we're building in this script is a coroutine-based streaming XML parser. The PHP
@Vinai
Vinai / releases.txt
Last active July 6, 2021 05:24
Magento Release Dates
Major Magento Releases
CE 1.0 (Mar 2008)
CE 1.1 (Jul 2008)
CE 1.2 (Dec 2008)
CE 1.3 (Apr 2009)
EE 1.6 (Nov 2009)
EE 1.7 (Jan 2010)
CE 1.4 (Feb 2010)
EE 1.8 (Apr 2010)
@MikeWilkie
MikeWilkie / local.xml
Last active November 28, 2018 04:47
Magento – Disable Excessive Logging and Reporting in app/etc/local.xml
<?xml version="1.0"?>
<!-- license -->
<config>
<global>
<!-- global config -->
</global>
<frontend>
<events>
<!-- disble logs -->
<controller_action_predispatch>
@Vinai
Vinai / or-example.php
Last active September 28, 2021 20:48
SearchCriteria OR Example for Magento 2
<?php
declare(strict_types = 1);
namespace Training5\VendorRepository\Controller\Test;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\Api\Filter;
use Magento\Framework\Api\FilterBuilder;
@alankent
alankent / pkglist.php
Created May 13, 2016 04:59
Connect to Magento 2 Composer repo and list packages you can access
<?php
/**
* Return the path of the auth.json file.
*/
function findAuthJson() {
// Windows sets HOMEDRIVE and HOMEPATH, but cygwin sets HOME.
if (!isset($_SERVER["HOME"]) && isset($_SERVER["HOMEDRIVE"])) {
@nicksantamaria
nicksantamaria / fork-example.php
Created October 20, 2016 22:35
Example: Parallel processing in PHP using pcntl_fork()
<?php
/**
* @file
* Basic demonstration of how to do parallel threads in PHP.
*/
// This array of "tasks" could be anything. For demonstration purposes
// these are just strings, but they could be a callback, class or
// include file (hell, even code-as-a-string to pass to eval()).
@ProcessEight
ProcessEight / Magento.md
Last active April 4, 2022 13:22
Magento 1 Cheatsheet: Common Magento 1 tasks

Magento Cheatsheet (For Magento 1)

Database operations

Download Sonassi database helper

wget sys.sonassi.com/mage-dbdump.sh && chmod +x ./mage-dbdump.sh

Download Magerun