Skip to content

Instantly share code, notes, and snippets.

View v1talii-dev's full-sized avatar

Vitalii Demchuk v1talii-dev

View GitHub Profile
@v1talii-dev
v1talii-dev / README.md
Created June 16, 2018 06:26
Ubuntu: create desktop shortcut
  • Создайте файл Postman.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/opt/Postman/Postman
Name=Postman
@v1talii-dev
v1talii-dev / simple-download-ods.php
Created June 5, 2018 10:04
PhpExcel: export to ods
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
@v1talii-dev
v1talii-dev / .gitignore
Last active June 4, 2018 17:59
D7: .gitignore
# Editor params.
/.idea
/.editorconfig
# Ignore configuration files that may contain sensitive information.
sites/*/*settings*.php
sites/example.sites.php
# Ignore paths that contain generated content.
files/
@v1talii-dev
v1talii-dev / mysql-docker.sh
Created June 2, 2018 23:23
Docker: Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@v1talii-dev
v1talii-dev / README.md
Last active June 2, 2018 22:30
Drupal: docker install

Установка Docker4Drupal для D7

Предварительная настройка

  • Создаем папку drupal

  • Скачиваем последний релиз docker4drupal

  • Извлекаем содержимое архива в папку drupal

@v1talii-dev
v1talii-dev / demo.php
Created June 1, 2018 11:42
D8: redirect after user update
<?php
/**
* Implements hook_form_FORM_ID_alter().
*/
function mymodule_form_user_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_id === 'user_form') {
$form['actions']['submit']['#submit'][] = '__mymodule_form_user_submit';
}
}
@v1talii-dev
v1talii-dev / theme.info.yml
Created May 31, 2018 06:09
D8: remove core styles
libraries-override:
system/base: false
system/admin: false
system/maintenance: false
system/drupal.system: false
system/drupal.system.modules: false
system/diff: false
system/drupal.system.date: false
contextual/drupal.contextual-links: false
quickedit/quickedit: false
@v1talii-dev
v1talii-dev / demo.php
Created May 17, 2018 06:54
D8: Add a custom submission handler to a form
<?php
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\HttpFoundation\Request;
function MYMODULE_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_id == 'node_trends_form' || $form_id == 'node_trends_edit_form') {
foreach (array_keys($form['actions']) as $action) {
if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
$form['actions']['submit']['#submit'][] = 'mymodule_form_submit';
@v1talii-dev
v1talii-dev / demo.php
Created May 15, 2018 12:19
D8: get file real path
<?php
$file = File::load($file_id);
$uri = $file->getFileUri();
$stream_wrapper_manager = \Drupal::service('stream_wrapper_manager')->getViaUri($uri);
$file_path = $stream_wrapper_manager->realpath();