Skip to content

Instantly share code, notes, and snippets.

View vladdancer's full-sized avatar
🖖

Vlad Moyseenko vladdancer

🖖
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / Redirect.php
Created January 28, 2022 18:26
Add extra source records to migrate #drupal8 #drupal9 #migrate
<?php
final class Redirect extends SqlBase {
/**
* Return list of additional redirects that doesn't exist in source db.
*
* Some redirects are not in db, but we need to add them.
*
* @return array[]
@vladdancer
vladdancer / media--pp-external.html.twig
Created June 3, 2022 21:45
PP Media template example
{% if pp_media.asset.meta.type === 'image' %}
{{ attach_library('easy_responsive_images/resizer') }}
{% set srcset = [
asset.sizes['400w'].url ~ ' 600w',
asset.sizes['900w'].url ~ ' 900w',
asset.sizes['3000w'].url ~ ' 3000w',
] %}
<img src="{{ src }}" data-srcset="{{ srcset|join(',')|raw }}" alt="{{ pp_media.asset.meta.alt }}" loading="lazy" />
{% endif %}
@vladdancer
vladdancer / moderation_state_migration_example.yml
Created June 9, 2022 11:26
Map moderation_state field in migration #drupal8 #drupla9 #migrate
# https://www.drupal.org/project/workflow/issues/3016286
# https://www.drupal.org/project/drupal/issues/3157105#comment-13830538
process:
...
moderation_state:
plugin: default_value
default_value: published
process:
...
@vladdancer
vladdancer / drush-run-command-unser-user.drush.php
Created June 21, 2022 09:40
Run drush 9 command from specific user
// https://github.com/drush-ops/drush/issues/3396#issuecomment-1009268719
// Bulk generate using action: https://gist.github.com/seth-shaw-unlv/bd64930fa1f75be3aba05ade34433092
// accountSwitcher->switchTo(new UserSession(['uid' => 1]);
@vladdancer
vladdancer / find.sh
Created June 21, 2022 09:41
Find/search file by text
# https://stackoverflow.com/questions/1987926/how-do-i-recursively-grep-all-directories-and-subdirectories
grep --include="*.ext" -nRHI "text" ~/projects/