Skip to content

Instantly share code, notes, and snippets.

View kandy's full-sized avatar

Andrii Kasian kandy

View GitHub Profile
@kandy
kandy / criticalcss-bookmarklet-devtool-snippet.js
Created March 15, 2019 03:07 — forked from PaulKinlan/criticalcss-bookmarklet-devtool-snippet.js
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@kandy
kandy / install-ioncube.sh
Last active April 2, 2018 07:33 — forked from asabirov/install-ioncube.sh
Easy way to install ioncube on Debian/Ubuntu
cd /tmp
curl -O http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar zxvf ioncube_loaders_lin_x86-64.tar.gz
PHP_CONFD=$(php-config --configure-options|sed 's/.*\with-config-file-scan-dir\=\(\S*\).*/\1/g')
PHP_VERSION=$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;")
PHP_EXT_DIR=$(php-config --extension-dir)
cp "ioncube/ioncube_loader_lin_${PHP_VERSION}.so" $PHP_EXT_DIR
echo "zend_extension = ${PHP_EXT_DIR}/ioncube_loader_lin_${PHP_VERSION}.so" > "${PHP_CONFD}/00-ioncube.ini"
rm -rf ./ioncube
rm ioncube_loaders_lin_x86-64.tar.gz
@kandy
kandy / sql_profiling.php
Created May 12, 2017 10:18 — forked from mslabko/sql_profiling.php
Enable sql profiling for Magento2
<?php
/**
* Enable sql profiling for each page.
*
* Put code to index file in two parts
*/
// place it BEFORE application run
$profiler = \Magento\Framework\App\ObjectManager::getInstance()
->get('Magento\Framework\App\ResourceConnection')
@kandy
kandy / autoprepend.php
Last active November 28, 2017 09:43
simple profiler
<?php
// include in bootsrap or add to auto_prepend_file
// tideways extension required (see: https://tideways.io/profiler/docs/setup/installation)
(function () {
if (!function_exists('tideways_enable')
||!isset($_SERVER['HTTP_ACCEPT'])
|| strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false
) {
return;
@kandy
kandy / bootstrap.php
Created December 13, 2016 08:15
db profiler
<?php
// add to bootstrap.php
register_shutdown_function(function (){
if (strpos(@$_SERVER['HTTP_ACCEPT'], 'text/html') !== false) {
/** @var \Magento\Framework\App\Resource $adapter */
$adapter = \Magento\Framework\App\ObjectManager::getInstance()
->get('Magento\Framework\App\ResourceConnection');
// composer.phar require "jdorn/sql-formatter:1.3.*@dev"
// require_once '/home/user/.composer/vendor/jdorn/sql-formatter/lib/SqlFormatter.php';
/** @var Zend_Db_Profiler $profiler */
@kandy
kandy / Random bytes, ints, UUIDs in PHP.md
Created February 1, 2016 14:21 — forked from tom--/Random bytes, ints, UUIDs in PHP.md
PHP random bytes, integers and UUIDs

Random bytes, ints, UUIDs in PHP

Simple and safe random getters to copy-paste

string randomBytes( int $length )

int randomInt ( int $min , int $max )

string randomUuid ( void )
@kandy
kandy / m2-module-install-2.sh
Created November 21, 2015 12:33 — forked from davidalger/m2-module-install-2.sh
Install module directly or via composer
composer config repositories.alger/phpworld-talk2 vcs [email protected]:davidalger/phpworld-talk2.git
composer require alger/module-skeleton:dev-master
bin/magento setup:upgrade -q && bin/magento cache:flush -q
# OR
git clone [email protected]:davidalger/phpworld-talk2.git app/code/Alger/Skeleton
bin/magento module:enable Alger_Skeleton
bin/magento setup:upgrade -q && bin/magento cache:flush -q
@kandy
kandy / gist:1466343a2739a5e3b647
Created November 6, 2015 12:32 — forked from sprankhub/gist:a386a2969ca7cc6f6552
Fish Shell Autocompletion for the Magento 2 Shell Script
# Installation:
# Copy to ~/.config/fish/completions/magento.fish
# Open new or restart existing shell session
# Commands based on Magento 2.0.0-rc and the command
# bin/magento --raw --no-ansi list
# It is a static list since you probably do not have the magento shell script
# in your path.
complete -f -c magento -a --help;
complete -f -c magento -a -h;
@kandy
kandy / 00. tutorial.md
Last active August 28, 2015 07:13 — forked from maxivak/00. tutorial.md
Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Indexer/etc/indexer.xsd">
<indexer id="cms_page_grid" view_id="cms_page_grid" primary="cms_page" class="Magento\Indexer\Model\Action\Collection">
<title translate="true">CMS Page Grid</title>