Skip to content

Instantly share code, notes, and snippets.

@apotashov
apotashov / MigratedPathLookup.php
Created December 3, 2021 08:33 — forked from 5n00p4eg/MigratedPathLookup.php
Drupal 8 migrate menu links with node references
<?php
namespace Drupal\oht_migrate\Plugin\migrate\process;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\Annotation\MigrateProcessPlugin;
use Drupal\migrate\Plugin\migrate\process\MigrationLookup;
use Drupal\migrate\Plugin\MigratePluginManagerInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\ProcessPluginBase;
@apotashov
apotashov / useConfirmationDialog.js
Created September 19, 2021 14:33 — forked from iskenxan/useConfirmationDialog.js
useConfirmationDialog hook and implementation
import React, { useCallback, useState } from 'react';
import ConfirmationDialog from 'components/global/ConfirmationDialog';
export default function useConfirmationDialog({
headerText,
bodyText,
confirmationButtonText,
onConfirmClick,
}) {
const [isOpen, setIsOpen] = useState(false);
@apotashov
apotashov / databaseService.php
Created May 19, 2021 10:37 — forked from WengerK/databaseService.php
Drupal 8 - Print raw SQL queries for debugging
<?php
/**
* Debugging using the database connection.
*/
/** @var \Drupal\Core\Database\Connection */
$connection = \Drupal::service('database');
$query = $connection->select('node', 'node');
$query->fields('node', ['nid'])
@apotashov
apotashov / gist:fbd07e16e665a3a6ded0b8e477f109fc
Last active May 7, 2021 14:29 — forked from ryanjbonnell/gist:c0f04ded19c35333f004
MacOS: Install PHP_CodeSniffer on Mac OS X for Drupal Coding Standards
# Install PEAR (PHP Extension and Application Repository)
$ sudo php /usr/lib/php/install-pear-nozlib.phar
$ sudo pear upgrade-all
$ sudo pear install --alldeps PHP_CodeSniffer
# Add PEAR to `php.ini` Include Path
$ nano /etc/php.ini
;include_path = ".:/php/includes"
include_path = ".:/php/includes:/usr/lib/php/pear"
@apotashov
apotashov / d8-hook-update-n.php
Last active May 7, 2021 14:02 — forked from ftm-bill/d8-hook-update-n.php
Drupal 8: hook_update_N() Examples
<?php
// Add base field to entity
$storage_definition = BaseFieldDefinition::create('email')
->setLabel(t('Email address'))
->setDescription(t('The email address associated with the event participant.'))
->setDisplayOptions('form', [
'region' => 'hidden',
'weight' => 0,
]);
@apotashov
apotashov / multiple_ssh_setting.md
Last active May 7, 2021 14:12 — forked from jexchan/multiple_ssh_setting.md
GIT: Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@apotashov
apotashov / .bash_profile
Last active May 7, 2021 14:36 — forked from monkeymonk/.bash_profile
MacOS: BASH Configuration and Aliases (eg. `sudo nano ~/.bash_profile`)
# BASH Configuration and Aliases
# source: http://natelandau.com/my-mac-osx-bash_profile/
# source: https://github.com/mathiasbynens/dotfiles
# Sections:
# 0. Execute Only Once (if you want)
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
@apotashov
apotashov / .bash_profile
Last active May 7, 2021 14:22 — forked from natelandau/.bash_profile
BASH: Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@apotashov
apotashov / git-aliases.md
Last active May 7, 2021 14:23 — forked from tyomo4ka/git-aliases.md
GIT: The Ultimate Alias Setup on OS X (brew)

The Ultimate Git Alias Setup on OS X (brew)

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bash_profile
@apotashov
apotashov / gulpfile.js
Last active May 7, 2021 13:12 — forked from youknowriad/gulpfile.js
Gulp: ES6 + ES5 Workflow
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var del = require('del');
var source = require('vinyl-source-stream');
var _ = require('lodash');
var extReplace = require('gulp-ext-replace');
var less = require('gulp-less');
var gulpMerge = require('merge-stream');
var ngTemplates = require('gulp-ng-templates');