Skip to content

Instantly share code, notes, and snippets.

View IvanChepurnyi's full-sized avatar
🚀
Building awesome high performance microservices

Ivan Chepurnyi IvanChepurnyi

🚀
Building awesome high performance microservices
View GitHub Profile
@IvanChepurnyi
IvanChepurnyi / Layout.php
Last active August 29, 2015 14:19
<remove /> strange behaviour, with core acl="" attribute for layout file.
<?php
// This code allows all calls to <remove /> being ignored
// if a block with acl attribute is valid for admin user.
// Shall I keep it in LayoutCompiler? IMO, this looks more like a bug, than a needed feature!
foreach ($ignoreNodes as $block) {
if ($block->getAttribute('ignore') !== null) {
continue;
}
$acl = (string)$attributes->acl;
if ($acl && Mage::getSingleton('admin/session')->isAllowed($acl)) {
@IvanChepurnyi
IvanChepurnyi / vhost.conf
Created September 27, 2013 23:47
This simple rewrite will help you to run phpunit from PHPStorm in Vagrant box without patching php.jar
location ~ ^/_intellij_phpunit_launcher.php$ {
expires off; ## Do not cache dynamic content
set $args "$args&dir=$document_root&config=phpunit.xml.dist";
fastcgi_pass unix://var/run/php5-fpm.sock; # Replace with your fpm pass
fastcgi_read_timeout 600;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
Verifying that +ivanchepurnyi is my blockchain ID. https://onename.com/ivanchepurnyi
<?php
ini_set('memory_limit', '2G');
class ExampleByReference
{
public function __invoke(&$array)
{
foreach ($array as $index => &$value) {
$this->itemRoutine($value);
@IvanChepurnyi
IvanChepurnyi / Observer.php
Created September 16, 2013 22:31
Optimized catalog price rules
<?php
class EcomDev_Optimization_Model_Rule_Observer extends Mage_CatalogRule_Model_Observer
{
protected $_preloadedPrices = array();
public function beforeCollectTotals(Varien_Event_Observer $observer)
{
$quote = $observer->getQuote();
$date = Mage::app()->getLocale()->storeTimeStamp($quote->getStoreId());
@IvanChepurnyi
IvanChepurnyi / OrderController.php
Created July 19, 2012 13:11
Any reason for using collection to retrieve single address instead of using load method of model?
// From app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php
/**
* Edit order address form
*/
public function addressAction()
{
$addressId = $this->getRequest()->getParam('address_id');
$address = Mage::getModel('sales/order_address')
->getCollection()
->addFilter('entity_id', $addressId)
@IvanChepurnyi
IvanChepurnyi / optimize-composer.sh
Created September 30, 2016 16:00
Optimizes autoloader for the best performance on production system
#!/bin/bash
magentodir=$1
cd $magentodir
read -d '' script << PHP
<?php
\$composer = json_decode(file_get_contents('composer.json'), true);
if (!is_array(\$composer['autoload']['psr-0'][''])) {

Usage is quite simple, you need to create in your $HOME a directory called .acme and place there such a config.yml file in it with the following options:

# E-mail to use for the setup.
# This e-mail will receive expiration notices from Let's Encrypt.
email: YOUR@EMAIL.COM

# List of certificates to issue.
certificates:
    # For each certificate, there are a few options.
    #
@IvanChepurnyi
IvanChepurnyi / php-fpm-cli
Created September 12, 2016 01:32
Benchmark Scripts (Root User Usage)
#
# The MIT License (MIT)
#
# Copyright (c) 2014 Mathias Leppich <mleppich@muhqu.de>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@IvanChepurnyi
IvanChepurnyi / install-unison.sh
Created October 28, 2016 17:44
Install Unison on Ubuntu LTE 12.04 from source
#!/bin/bash
apt-get install python-software-properties
add-apt-repository ppa:avsm/ppa
apt-get update -y -f
apt-get install ocaml opam -y
mkdir -p /usr/src/unison/
cd /usr/src/unison/