Skip to content

Instantly share code, notes, and snippets.

View kvantstudio's full-sized avatar

Pavel kvantstudio

View GitHub Profile
@kvantstudio
kvantstudio / settings.local.php
Created May 20, 2023 09:48 — forked from keopx/settings.local.php
Drupal 8 Redis settings.local.php
<?php
/**
* Set redis configuration.
*/
/** @see: https://docs.platform.sh/frameworks/drupal8/redis.html */
if (extension_loaded('redis')) {
// Set Redis as the default backend for any cache bin not otherwise specified.
// $settings['cache']['default'] = 'cache.backend.redis';
@kvantstudio
kvantstudio / README.md
Created April 27, 2023 10:10 — forked from antfroger/README.md
Using xdebug with Windows 10, WSL2, Docker and VS Code

Configuring xdebug to work with Windows 10 (WSL2), Docker and VS Code

Configuring your dev environment to be able to use xdebug when you're working on Windows 10 (with WSL2) and Docker with VS Code can be (a bit) tricky.
This is a quick reminder of how I've done that.

Configuring the environment

  1. Install and configure xdebug in Docker

Install xdebug according to the Docker image you're using

/**
* Send Google analytics tracking event.
*
* @param mixed $action
* Event action.
*/
public function sendGoogleTrackingEvent($action) {
if (!$this->isProduction()) return;
$googleAnalyticsUA = 'UA-XXXXXXXX-XX';
@kvantstudio
kvantstudio / Blocks.md
Created February 28, 2021 11:37 — forked from bdlangton/Blocks.md
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
@kvantstudio
kvantstudio / 00_npd.md
Created December 13, 2020 09:20 — forked from nalgeon/00_npd.md
Определить самозанятого по ИНН

Определить самозанятого по ИНН

В поддержку «Дадаты» иногда обращаются с вопросом «как проверить, является ли физлицо самозанятым». Налоговая служба не предоставляет открытых данных по самозанятым, поэтому такого сервиса нет в «Дадате».

Но можно воспользоваться API налоговой. Мы подготовили примеры, как это сделать на самых популярных языках — Python, PHP и JavaScript.

API налоговой бесплатное, но используете его вы на свой страх и риск. Никто не гарантирует, что оно будет работать корректно и стабильно.

Пример ответа API налоговой, если ИНН принадлежит самозанятому:

@kvantstudio
kvantstudio / drupal-8--nginx.conf
Created November 22, 2020 09:06 — forked from cyberlex404/drupal-8--nginx.conf
example ISP manager DRUPAL 8 nginx config
server {
server_name svkote.cyberlex404.com www.svkote.cyberlex404.com;
charset off;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/svkote.cyberlex404.com/*.conf;
access_log /var/www/httpd-logs/svkote.cyberlex404.com.access.log;
error_log /var/www/httpd-logs/svkote.cyberlex404.com.error.log notice;
ssi on;
@kvantstudio
kvantstudio / field_type_schema_change_helper.md
Created July 14, 2020 17:57 — forked from JPustkuchen/field_type_schema_change_helper.md
Drupal 8 Field type schema column change helpers.
@kvantstudio
kvantstudio / d8-responsive-image-programmatically.php
Created May 3, 2020 18:00 — forked from szeidler/d8-responsive-image-programmatically.php
Load and render responsive image from field in Drupal 8
<?php
function _load_header_image($variables) {
if ($node = $variables['node']) {
// Load main_image
$file = $node->field_main_image->entity;
if ($file) {
$variables = array(
'responsive_image_style_id' => 'header_image',
'uri' => $file->getFileUri(),
@kvantstudio
kvantstudio / ssh-copy-id.ps1
Created February 29, 2020 11:39 — forked from soar/ssh-copy-id.ps1
ssh-copy-id for windows
# ssh-copy-id analog for Windows systems
# Script to install your public key on a remote machine
# The remote machine must accept password authentication,
# or one of the other keys in your Putty Agent, for this to work.
#
# (c) soar - http://soar.name
# Dialog for public key selection
Function Select-File()
{