Skip to content

Instantly share code, notes, and snippets.

View dstorozhuk's full-sized avatar

Dima dstorozhuk

View GitHub Profile
@dstorozhuk
dstorozhuk / .bash_aliases
Last active August 12, 2021 05:25
Git aliases
# Put this in ~/.bash_aliases
# `source ~/.bash_aliases` to activate
alias dcr='drush cr'
alias ddis='drush dis -y '
alias ddl='drush dl -y '
alias den='drush en -y '
alias dcex='drush csex -y'
alias dcim='drush csim -y'
alias ga='git add '
alias gb='git branch '
@dstorozhuk
dstorozhuk / CssServer.php
Created February 28, 2017 07:15
Extends the Leafo\ScssPhp\Server. Add source map. Part of Drupal 8 module.
<?php
/**
* Created by PhpStorm.
* User: dima
* Date: 11/12/16
* Time: 11:58 AM
*/
namespace Drupal\bootstrap_sass_helper;
@dstorozhuk
dstorozhuk / Install image magic
Created June 22, 2017 05:59
Install image magic
Installing PHP PECL IMagick on Ubuntu:
--------------------------------------
1. $ sudo aptitude install php-pear imagemagick php5-dev libmagick9-dev
2. $ sudo apt-get install libmagickwand-dev
3. $ sudo pecl install Imagick
4. $ sudo nano /etc/php5/apache2/php.ini
4. enter extension=imagick.so -> save (ctrl+x / Y)
6. $ sudo apache2ctl configtest
@dstorozhuk
dstorozhuk / IdentificationNumber.php
Created June 27, 2017 05:12
Расшифровка идентификационного номера (Украина) в PHP получение даты рождения и пола
function IdentificationNumber($number)
{
$result = array();
$result['number'] = $number;
$result['sex'] = (substr($number,8,1)%2) ? 'Мужчина' : 'Женщина';
$split = str_split($number);
$execute = $split[0]*(-1)+$split[1]*5+$split[2]*7+$split[3]*9+$split[4]*4+$split[5]*6+$split[6]*10+$split[7]*5+$split[8]*7;
$number = substr($number,0,5);
$date = date('d.m.Y',strtotime('01.01.1900 + '.$number.' days - 1 days'));
list($result['day'],$result['month'],$result['year']) = explode('.',$date);
@dstorozhuk
dstorozhuk / import.php
Last active May 8, 2020 05:30 — forked from crittermike/import.php
Importing Drupal 8 config programmatically
<?php
// Import arbitrary config from a variable.
// Assumes $data has the data you want to import for this config.
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html');
$config->setData($data)->save();
// Or, re-import the default config for a module or profile, etc.
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module');

The Scroll Behavior specification has been introduced as an extension of the Window interface to allow for the developer to opt in to native smooth scrolling. To date this has only been implemented in Chrome, Firefox and Opera.

There's a complete polyfill here (3.3KB minified). But most of the times, the following is enough for me (641 bytes minified):

smooth-scrolling-poyfill.js

Use as: scrollToElem('#elem-selector');

@dstorozhuk
dstorozhuk / TermReferenceBoost.php
Created October 1, 2020 14:03 — forked from schnippy/TermReferenceBoost.php
Drupal 8.x Search API processor plugin for boosting search items by term reference field
<?php
// This plugin allows the administrator to boost items in an index based on a taxonomy term.
//
// Drop into an existing plugin module or create a new one, ex. create an info.yml file as
// modules/custom/search_api_boost_term_reference/search_api_boost_term_reference.info.yml
//
// name: 'Search API Boost by Term Reference'
// description: 'Define custom boost priority in Search API index by term reference field'
// core: 8.x
@dstorozhuk
dstorozhuk / ionos.sh
Created November 17, 2023 13:23 — forked from leymannx/ionos.sh
1&1 ionos shared webhosting command line PHP Drush Composer Drupal
# https://www.ionos.com/community/hosting/php/using-php-composer-in-11-ionos-webhosting-packages/
php -v
# PHP 4.4.9 (cgi-fcgi) (built: Nov 7 2018 13:27:00)
# Copyright (c) 1997-2008 The PHP Group
# Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
/usr/bin/php7.1-cli -v
# PHP 7.1.25 (cli) (built: Dec 10 2018 10:11:36) ( NTS )
# Copyright (c) 1997-2018 The PHP Group

How to Build and Install Latest cURL Version on CentOS

# Written by The Suhu (2021).

# Tested on CentOS 7 and CentOS 8

Previously I've written about How to Build and Install Latest cURL Version on Ubuntu. In this article in this article explain how to build and install latest cURL version on CentOS.