Skip to content

Instantly share code, notes, and snippets.

View evgv's full-sized avatar
🏠
Working from home

Eugene Zubkov evgv

🏠
Working from home
View GitHub Profile
@evgv
evgv / html5_validation_pattern.markdown
Last active March 2, 2018 09:39
HTML5 Vvalidation patterns

HTML5 validation patterns

Validate telephone (Ukraine)

Pattern

  ^\+38(\s+)?\(?(039|050|063|066|067|068|091|092|093|094|095|096|097|098|099)\)?(\s+)?[0-9]{3}-?[0-9]{4}$

Code

@evgv
evgv / magento2_apache2_virtualhost_configuration.markdown
Last active January 12, 2018 09:43
Magento 2. Apache2 virtualhost configuration (local development)

Magento 2. Apache2 virtualhost configuration (local development)

I use AssignUserID option to differentiate access rights for my user and server user, if you also use this option, then you need to install an additional apache2 module mpm-itk, instructions below.

   sudo apt update
   sudo apt install libapache2-mpm-itk
   sudo service apache2 reload
@evgv
evgv / magento_data_install_add_static_block.markdown
Last active February 12, 2018 13:43
Magento. Data install script. Add static block.

Magento. Data install script. Add static block.

Create static block programmatically with install script.

Config. Need to add resources.

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Vendoe_Extension>
@evgv
evgv / php_ini_path.md
Created December 14, 2017 07:52
php.ini file path

php.ini file path

    $inipath = php_ini_loaded_file();

    if ($inipath) {
        echo 'Loaded php.ini: ' . $inipath;
    } else {
 echo 'A php.ini file is not loaded';
@evgv
evgv / php_code_snippet_slice_string_by_words.markdown
Last active February 22, 2018 13:43
PHP. Code Snippet. Slice string by words.

Slice string by words

   /**
     * Slice string by words count and add `...` into the end
     * 
     * @param string $string
     * @param int $maxWords
     * @return string
 */
@evgv
evgv / mage_resize_category_image.md
Last active November 3, 2017 09:17
Magento. Resize category image

Magento. Resize category image

    /**
     * Resize category image
     * @param Mage_Catalog_Model_Category $category
     * @param int $width
     * @param int $height
     * @return boolean
@evgv
evgv / php_search_empty_values_in_array.md
Last active November 22, 2017 09:58
PHP. Function to check if array has any empty value

PHP. Search empty values in array also work with associate arrays

/**
 * Search in array empty values
 * 
 * Return `false` if all values filled (0, '0' i is not empty)
 * Return array with keys of empty values from given array
 * Work with associate arrays
@evgv
evgv / js_facebook_api_catch_like_events.md
Created October 3, 2017 12:19
Js. Facebook API. Catch like/unlike events
    window.fbAsyncInit = function() {
        FB.Event.subscribe('edge.create',
            function(response) {
                alert('Liked!');
            }
        );
        FB.Event.subscribe('edge.remove',
            function(response) {
 alert('Unliked!');
@evgv
evgv / mage_get_date.md
Last active December 2, 2022 08:50
Magento. Get date

Get date

Im Magento you can get date in different formats use core/date helper

Y-m-d H:i:s // 2016-05-15 19:05:15
  $now   = Mage::getModel('core/date')->gmtDate();
l, F d, Y H:i:s A e // Sunday, May 15, 2016 3:05:15 PM America/New_York
@evgv
evgv / nginx_basic_setup_steps_for_ubuntu.md
Last active August 14, 2017 11:24
Nginx basic setup steps for Ubuntu

Nginx basic setup steps for Ubuntu

Update apt and install nginx

sudo apt-get update
sudo apt-get install nginx

Start/stop server