Skip to content

Instantly share code, notes, and snippets.

View vladdancer's full-sized avatar
🖖

Vlad Moyseenko vladdancer

🖖
View GitHub Profile
@vladdancer
vladdancer / custom_join.module
Created November 25, 2022 20:31 — forked from rubenvarela/custom_join.module
drupal 8, drupal 9 - Views - Add extra condition on join
<?php
/**
* @file
* Primary module hooks for custom_join module.
*/
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\views\ViewExecutable;
@vladdancer
vladdancer / gist:c896710a1453c8b27f82c4ac33e71509
Created November 8, 2022 14:24 — forked from jleehr/gist:7ac2a5de785881dfce99f7034547f07b
Drupal 8 - Migrate from public to private files
# Enable maintanance mode
drush state-set system.maintenance_mode 1
# Backup file field data
drush sql-query "CREATE TABLE media__field_file_bak AS SELECT * FROM media__field_file;"
drush sql-query "CREATE TABLE media_revision__field_file_bak AS SELECT * FROM media_revision__field_file;"
# Truncate file field tables (need to change storage settings)
drush sql-query "TRUNCATE media__field_file;"
drush sql-query "TRUNCATE media_revision__field_file;"
@vladdancer
vladdancer / mysqldump and mysqlpump backup.md
Created October 27, 2022 21:47 — forked from ebta/mysqldump and mysqlpump backup.md
Backup MySQL database using mysqldump & mysqlpump

Backup Using mysqldump

Mysqldump is a command-line utility that is used to generate the logical backup of the MySQL database. It produces the SQL Statements that can be used to recreate the database objects and data. The command can also be used to generate the output in the XML, delimited text, or CSV format.

Note: By default, mysqldump command does not dump the information_schema database, performance_schema, and MySQL Cluster ndbinfo database. If you want to include the information_schema tables, you must explicitly specify the name of the database in the mysqldump command, also include the —skip-lock-tables option.

mysqldump -uroot -p  --all-databases > all-databases.sql
mysqldump -uroot -p dbname > dbname.sql
mysqldump -uroot -p dbname table1 table2 > dbname_table_1_2.sql
@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 / 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
@vladdancer
vladdancer / Built_In.xml
Created March 5, 2017 20:34 — forked from mglaman/Built_In.xml
Configurations to run Drupal Commerce tests in PHPStorm. add to $PROJECT/.idea/runConfigurations. The compound "Commerce Test Runner" will launch PhanomJS, PHP's built in and then run Drupal Commerce's PHPUnit tests.
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Built-in" type="PhpBuiltInWebServerConfigurationType" factoryName="PHP Built-in Web Server" singleton="true" document_root="$PROJECT_DIR$/www" port="8080">
<method />
</configuration>
</component>
@vladdancer
vladdancer / flex.less
Last active August 29, 2015 14:28 — forked from codler/flex.less
Prefix flex for IE10 and Safari / iOS in LESS
/*! Prefix flex for IE10 and Safari / iOS in LESS
* https://gist.github.com/codler/2148ba4ff096a19f08ea
* Copyright (c) 2014 Han Lin Yap http://yap.nu; MIT license */
.display(@value) when (@value = flex) {
display: -ms-flexbox; // IE10
display: -webkit-flex; // Safari / iOS
}
.display(@value) when (@value = inline-flex) {
<?php
#!/usr/bin/env drush
// Example rebuild script
// local alias
$self_record = drush_sitealias_get_record('@self');
$self_name = '@' . $self_record['#name'];
'use strict';
(function() {
var mod = angular.module("App.services", []);
//register other services here...
/* pubsub - based on https://github.com/phiggins42/bloody-jquery-plugins/blob/master/pubsub.js*/
mod.factory('pubsub', function() {
var cache = {};