Skip to content

Instantly share code, notes, and snippets.

@dkorpar
dkorpar / Magento JS Components
Created November 29, 2019 16:12
Magento text/x-magento-init language injection for PHPstorm
<LanguageInjectionConfiguration>
<injection language="JSON" injector-id="xml">
<display-name>Magento JS Components</display-name>
<place><![CDATA[xmlTag().withLocalName(string().equalTo("script"))]]></place>
<xpath-condition>@type=&quot;text/x-magento-init&quot;</xpath-condition>
</injection>
</LanguageInjectionConfiguration>

Configure Valet+ to NOT require a password for sudo

echo "%admin ALL = NOPASSWD: /usr/local/bin/valet" | sudo tee /etc/sudoers.d/valet-nopasswd

Enable macOS Server Performance Mode

For more details see this page.

sudo nvram boot-args="serverperfmode=1 $(nvram boot-args 2>/dev/null | cut -f 2-)"
sudo reboot
@dkorpar
dkorpar / subCountItems.php
Created November 11, 2018 20:44
Subarray for the given sum
<?php
/*
* Find a subarray with the minimum number of items
* which sum is equal to the requested sum.
*
* Items [1, 2, 3, 5] and sum of 5 will return [5]
* Items [1, 2, 3, 5] and sum of 4 will return [1, 3]
* Items [1, 2, 3, 5] and sum of 8 will return [3, 5]
* Items [1, 2, 3, 5] and sum of 9 will return [1, 3, 5]
@dkorpar
dkorpar / image-optimize-compress.md
Created March 19, 2018 21:26
Optimize/compress JPEG/JFIF files

Optimize/compress JPEG/JFIF files

Jpegoptim is used to optimize/compress jpeg files. Program supports lossless optimization, which is based on optimizing the Huffman tables. And so called "lossy" optimization where in addition to optimizing Huffman tables user can specify upperlimit for image quality.

NOTE! By default jpegoptim modifies the input files (if they are optimized), to preserve original files use option -d to specify alternate directory for saving the optimized files to.

Only normal files are optimized (symbolic links and special files are skipped). Also, any other hard links to the file being optimized are unaf-fected.

Installation

@dkorpar
dkorpar / git-patch.md
Created March 19, 2018 21:24
Creating and appying Git patches

Creating and appying Git patches

Creating patch files in the examples below are primarely meant for usage in cweagans/composer-patches, although can be used with plain Git. Instructions of including generated patches are explained in the repo itself.

Another package with a similar (if not the same) functionality is available at jamescowie/composer-patcher, but not tested though.

git format-patch

Creates new files with all changes from the current (feature branch) against another (source) branch. The idea behind this is to have a new branch, made of and ahead of a branch that diff will be run against. Patch will include only commits that are ahead of a source branch.

@dkorpar
dkorpar / instructions.md
Created December 4, 2017 11:02
MEQP configuration in PhpStorm

MEQP configuration in PhpStorm

Magento recommends the consistent use of a code sniffer to enhance the readability of your code and help ensure that it meets Magento code standards. A code sniffer is a tool that automates the process of identifying code irregularities.

It allows automatically check your code against some of the common Magento and PHP coding issues, like:

  • Raw SQL queries;
  • SQL queries inside a loop;
  • Direct class instantiation;
  • Unnecessary collection loading;
  • Excessive code complexity;
@dkorpar
dkorpar / maintenance.html
Last active October 31, 2017 11:03 — forked from pitch-gist/gist:2999707
Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
html, body { width:100%; height:100%; }
h1 { font-size: 42px; line-height: 1; }
body { box-sizing: border-box; font: 20px Helvetica, sans-serif; color: #333; padding: 30px; }
article { display: block; text-align: left; margin: 0 auto; max-width: 650px; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }