Skip to content

Instantly share code, notes, and snippets.

View sylvainraye's full-sized avatar

Sylvain Rayé sylvainraye

View GitHub Profile
@dnahrebecki
dnahrebecki / EstimateClocCommand.php
Created February 16, 2022 13:39
Command for generating LOC statistics for a Symfony project
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@FredericMartinez
FredericMartinez / tinymce4Adapter.js
Last active March 17, 2021 15:10
Remove <p> WYSIWYG Magento 2
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*
* => app/design/adminhtml/Namespace/project_name/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
*/
/* global popups, tinyMceEditors, MediabrowserUtility, Base64 */
/* eslint-disable strict */
define([
@gplanchat
gplanchat / php_unserialize_to_json.sql
Last active July 28, 2022 10:01 — forked from damoclark/php_unserialize_to_json.sql
PHP unserialize in Postgresql to json
/**
Decode a php serialized value to json. This function only supports basic
data types:
- arrays (will always become a json object)
- booleans
- integers
- floats
- strings
- NULL
@mehdichaouch
mehdichaouch / magento2_debug_ui_component.js
Created December 17, 2020 10:16
Magento 2 - Debug UI Component (showing spinner) #magento2 #uicomponent
// https://magento.stackexchange.com/questions/310578/how-to-debug-ui-component-only-showing-spinner
// https://devdocs.magento.com/guides/v2.4/javascript-dev-guide/javascript/js_logger.html
require(['Magento_Ui/js/lib/logger/console-logger',
'Magento_Ui/js/lib/logger/levels-pool'],
function(logger, levels) {
logger.setDisplayLevel(5) // 2 = WARN 5 = ALL, see levels-pool.js
}
);

Run on changed files:

php bin/phpcs {} -p --encoding=utf-8 --extensions=php --standard=vendor/oro/platform/build/Oro/phpcs.xml

php bin/php-cs-fixer fix {} --verbose --dry-run --config=vendor/oro/platform/build/.php-cs-fixer.php

php bin/phpmd {} text vendor/oro/platform/build/phpmd.xml --suffixes php 

where {} is the changed file

@piotrekkaminski
piotrekkaminski / MPERF-10565.diff
Created April 8, 2019 18:04
MPERF-10565.diff - logging to a file that does not exist issue
diff --git a/app/Mage.php b/app/Mage.php
index 0e650eebb4f..9c18e222689 100644
--- a/app/Mage.php
+++ b/app/Mage.php
@@ -798,9 +798,9 @@ public static function log($message, $level = null, $file = '', $forceLog = fals
',',
(string) self::getConfig()->getNode('dev/log/allowedFileExtensions', Mage_Core_Model_Store::DEFAULT_CODE)
);
- $logValidator = new Zend_Validate_File_Extension($_allowedFileExtensions);
$logDir = self::getBaseDir('var') . DS . 'log';
@nicanaca0
nicanaca0 / ImportProductsCommand.php
Last active May 1, 2024 11:05
Simple CSV Product importer for Sylius. Includes the product, the variant, channel pricing, taxons images and associations (1.0.0-beta.2)
<?php
namespace AppBundle\Command;
use Sylius\Component\Core\Model\ChannelPricingInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Product\Model\ProductAssociationInterface;
use Sylius\Component\Product\Model\ProductAssociationTypeInterface;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
@toonetown
toonetown / shimo-pulse-vpn
Last active February 14, 2023 14:20
Leverages ssh and openconnect to connect Shimo to PulseSecure hosts
#!/bin/bash
: ${NUM_FAILURES_ALLOWED:=10}
: ${SLEEP_PING_TIME:=10}
if [ "${1}" == "-c" -a -n "${2}" ]; then SHIMO_SCRIPT_CFG="${2}"; shift 2; fi
if [ -n "${SHIMO_SCRIPT_CFG}" ]; then
: ${SHIMO_HOME:="${HOME}/Library/Application Support/Shimo"}
: ${SHIMO_SCRIPT_HOME:="${SHIMO_HOME}/Scripts"}
: ${SHIMO_CONFIG_DIR:="${SHIMO_SCRIPT_HOME}/${SHIMO_SCRIPT_CFG}"}
@udovicic
udovicic / INSTRUCTIONS.md
Last active January 6, 2021 19:16
Instructions for setting up Magento 2 code analysis with PHPSTorm

Setting up MEQP Coding standard checks in PHPStorm

Overview

In order to submit extensions to Magento marketplace, source code needs to pass Magento Extension Quality Program Coding Standard checks.

You can either do it manually, by following this guide in official Github repository, or by fixing things as you code, by setting up check in PHP Storm.

Install and configure Code Sniffer on system

@alankent
alankent / validate_m2_package.php
Last active February 15, 2016 10:39
Magento Marketplace beta Composer package ZIP file validator script.
#!/usr/bin/php
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See https://github.com/magento/magento2/blob/develop/COPYING.txt for license details.
*/
/**
* validate_m2_package.php - a script that checks a given M2 zip package to ensure
* it is structured correctly and has all the required files.