Skip to content

Instantly share code, notes, and snippets.

View ivanweiler's full-sized avatar
👾

Ivan Weiler ivanweiler

👾
  • Favicode
  • Osijek, Croatia
View GitHub Profile
<?php
/**
* Fast direct PHP port of https://github.com/github/version_sorter
* Not really tested
*/
class Strchunk
{
/**
* @var int
DROP PROCEDURE IF EXISTS ClearCoreUrlTable;
DELIMITER $$
CREATE PROCEDURE `ClearCoreUrlTable`()
BEGIN
SET @delete_counter = 0;
SET @table_name = 'core_url_rewrite';
SET @total_records = (SELECT count(*) FROM core_url_rewrite WHERE product_id is not null and category_id is not null);
WHILE @delete_counter < @total_records DO
SET @varSQL = CONCAT('DELETE FROM ', @table_name,' WHERE category_id IS NOT NULL and product_id IS NOT NULL AND is_system=0 LIMIT 500;');
#!/bin/bash
###
# Script for switching PHP versions
# Ivan Weiler
#
# Reference:
# http://robosparrow.github.io/2016/12/10/php-5-on-ubuntu16.html
# https://labbots.com/bash-script-to-switch-php-versions-in-ubuntu/
###

Select component in inspector and dump (in FF for example):

inspect(require('ko').contextFor($0));
inspect(require('ko').dataFor($0));

Get component from registry:

require('uiRegistry').get('componenet.name.in.layout')
@ivanweiler
ivanweiler / sylius-api-examples.md
Last active April 4, 2018 12:37
Sylius API for React workshop
@ivanweiler
ivanweiler / magento-api-examples.md
Last active April 3, 2018 06:04
Magento APIs for React workshop
@ivanweiler
ivanweiler / gist:c1c85922270a41fd8af62759d09822f0
Created March 20, 2018 11:22
Magento2 Apache/htaccess CORS headers
<VirtualHost *:80> # Or whatever VHost you're using
# Your other rules
RewriteEngine on
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ "index.html" [R=200,E=API:1,PT]
# This rewrite rule forces any OPTIONS request to return as a valid response.
# It sets the API environment variable for use below.
#
# You can try to put a placeholder file here for the response (index.html)
# Otherwise it'll look like an error page, but it'll return with a 200 response code.
@ivanweiler
ivanweiler / app_etc_local.di.xml
Last active April 18, 2017 07:45
Magento 2 log database queries
<?xml version="1.0"?>
<!--
/**
* Log Db Queries
* Copy to /app/etc/local.di.xml (di.xml glob follows {*di.xml, */*di.xml} pattern)
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\File"/>
<type name="Magento\Framework\DB\Logger\File">
@ivanweiler
ivanweiler / log.php
Last active August 10, 2016 13:39
Mage::log
\Magento\Framework\App\ObjectManager::getInstance()
->get('\Psr\Log\LoggerInterface')
->debug(print_r($a, true));
//var/log/debug.log
@ivanweiler
ivanweiler / gist:e312598ad1df25581c530a6adcd8cc8c
Last active June 26, 2017 10:42
bin/magento php cli options
php -d xdebug.remote_autostart=1 bin/magento
xdebug.ini
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.max_nesting_level = 500
#default formating
xdebug.overload_var_dump = 0