Skip to content

Instantly share code, notes, and snippets.

View vladdancer's full-sized avatar
🖖

Vlad Moyseenko vladdancer

🖖
View GitHub Profile
@vladdancer
vladdancer / recreateMigrationMapTables.drush.php
Created November 5, 2021 14:17
Recreate migrate map tables for specific migration #migrate #drupal8
<?php
/**
* @file
* recreateMigrationMapTables.drush.php
*
* Usage:
* @code
* drush scr recreateMigrationMapTables.drush.php [MIGRATION_ID]
* @endcode
*/
@vladdancer
vladdancer / routine.sh
Created September 27, 2021 14:25
Drupal routine #php #drupal
# Check php compatibility
# source: https://www.specbee.com/blogs/drupal9-and-its-compatibility-with-php-8-learn-whats-new
vendor/bin/phpcs -p . --standard=PHPCompatibility \
--runtime-set 7.4 \
--extensions=php,module,install,inc \
--report-full==./php7.4-compatibility.txt
@vladdancer
vladdancer / dry_run.php
Created September 13, 2021 16:49 — forked from vasi/dry_run.php
Drupal migrate dry run
<?php
use Drupal\migrate_plus\Event\MigrateEvents as MigratePlusEvents;
use Drupal\migrate_plus\Event\MigratePrepareRowEvent;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
function dry_run_migration($migration_id) {
// Get the migration source.
$migrationManager = \Drupal::service('plugin.manager.config_entity_migration');
$migration = $migrationManager->createInstance($migration_id);
@vladdancer
vladdancer / gist:6c50601cb719604f092eb627cc833bf3
Created August 22, 2021 17:34
Create patch #drupal #module
git add -N .
git diff --staged > media_entity_soundcloud-v3-prevent-media-clear-old-configuration-3208259-2.patch
@vladdancer
vladdancer / downloadVideoFromPlaylistFile.sh
Created July 5, 2021 11:21
Download video from playlist file
ffmpeg -i 'https://example.com/playlist.m3u8' -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 ~/video_file.mp4
@vladdancer
vladdancer / info.sh
Created March 24, 2021 18:27
Lando, get external container port to connect to the DB. #lando #drupal #docker
lando info --filter service=database
# or
lando info --format=json | jq '.[] | select(.service=="database") | .external_connection.port '
# to suppress nodejs warnings run lando with
# see https://github.com/lando/lando/issues/2928
node --no-warnings /path/to/lando.js info --format=json | jq '.[] | select(.service=="database") | .external_connection.port'
@vladdancer
vladdancer / drupal_db_drush.sh
Last active July 16, 2024 20:04
Import/export drupal db dump #drush #drupal
# intstall database
# drush si --db-url=mysql://root:pass@localhost:port/dbname
drush si --db-url=mysql://drupal:drupal@mariadb/drupal
# export db
drush sql-dump > db.sql
# import db
drush sql-cli < db.sql
@vladdancer
vladdancer / composer.json
Last active February 25, 2021 10:51
Redis config for settings.php #drupal8 #redis
{
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "",
"role": ""
}
],
"repositories": [
@vladdancer
vladdancer / export.default.content.sh
Created February 24, 2021 13:40
export content in drupal
#!/bin/bash
# Note: the path is relative to the DRUPAL_ROOT
# drush dcer --folder
drush dcer taxonomy_term 11972 --folder=modules/custom/my_module/modules/my_module_demo_content/content
drush dcer question 13 --folder=modules/custom/my_module/modules/my_module_demo_content/content
@vladdancer
vladdancer / git-branches-by-commit-date.sh
Created January 20, 2021 09:01 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r