Skip to content

Instantly share code, notes, and snippets.

View missoxd's full-sized avatar

Misso Marchewsky missoxd

View GitHub Profile
@missoxd
missoxd / combinations.php
Last active November 12, 2015 19:54
Anonymous recursive function - Returns array with all possible combinations, (if array values are arrays, they will be transformed to objects)
<?php
$flatten = function ( & $combines) use ( & $flatten) {
$current = pos($combines);
$current = array_map(function ($v) {
return is_array($v) ? (object) $v : $v;
}, $current);
if (!next($combines)) {
$end = end($combines);
@missoxd
missoxd / magento2-custom-script.php
Last active June 22, 2020 20:24
Magento 2 custom script boilerplate
<?php
require __DIR__ . '/app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$objectManager->get('\Magento\Framework\App\State')->setAreaCode('adminhtml');
$registry = $objectManager->get('\Magento\Framework\Registry');
$registry->register('isSecureArea', 'true');
<?php
$errno = 0;
$errstr = '';
$fp = fsockopen('165.227.126.241', 80, $errno, $errstr, 30);
if (!$fp) {
echo $errstr .'('. $errno . ')';
} else {
@missoxd
missoxd / soap-debug.php
Last active December 3, 2018 17:59
SOAP Debug that dumps XML response, with some boilerplate for Magento 1
<?php
class SoapClientDebug extends SoapClient
{
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
error_log("REQUEST:\n" .$request . "\n");
error_log("LOCATION:\n" .$location . "\n");
error_log("ACTION:\n" .$action . "\n");
error_log("VERSION:\n" .$version . "\n");
@missoxd
missoxd / magento1-cookie-check.php
Last active December 3, 2018 12:12
Magento 1 Cookie settings check
@missoxd
missoxd / magento2-logger.php
Last active February 4, 2019 19:04
Log a message in Magento 2.
<?php
$om = \Magento\Framework\App\ObjectManager::getInstance();
$logger = $om->get(\Psr\Log\LoggerInterface::class);
$logger->emergency('message');
$logger->alert('message');
$logger->critical('message');
$logger->error('message');
$logger->warning('message');
<?php
# require magento
require_once(__DIR__ . '/app/Mage.php');
# init app
Mage::app();
# set store - default: admin
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
@missoxd
missoxd / pipefy.php
Created March 7, 2019 05:04
Simple pipeline middleware like for closures
<?php
$pipeline = [];
$pipeline['first_pipe'] = function (array $params, callable $next) {
echo "first pipe\n";
$params['first_pipe_part_1'] = true;
print_r($params);
<?php
#
# O desconhecido sempre existirá, ele é ilimitado, mesmo quando não.
# The unknown will always exist, it is unlimited, even when it is not.
# -- Misso Marchewsky, 2019-03-29 02:00:00
#
while (true) {
$knowledge++;
if ($knowledge === $end_of_the_unknown) {
<?php
// @see: https://stackoverflow.com/a/18208549
// ----------------------------------------------------------------------------------------------------
// - Display Errors
// ----------------------------------------------------------------------------------------------------
ini_set('display_errors', 'On');
ini_set('html_errors', 0);