Skip to content

Instantly share code, notes, and snippets.

View kaido24's full-sized avatar
🎯
Focusing

Kaido Toomingas kaido24

🎯
Focusing
View GitHub Profile
@kaido24
kaido24 / gist:79129d207dede00adbc437d1cec2d902
Created October 24, 2022 10:32 — 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;"
@kaido24
kaido24 / responsive-video.less
Created February 11, 2020 21:22
responsive video drupal 8 media
.field--name-field-media-oembed-video {
position: relative;
margin: 20px 0;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
iframe {
position: absolute;
top: 0;
left: 0;
use Drupal\commerce_product\Entity\ProductVariation;
$productvar = ProductVariation::load(328);
$status = $productvar->delete();
ksm($status);
#!/bin/bash
cd
# set bash php to php7
echo "
alias php7=\"/usr/local/php71/bin/php\"
alias composer=\"php7 -d memory_limit=-1 ~/tools/composer.phar\"
alias drupal=\"php7 -d memory_limit=-1 ~/tools/drupal.phar\"" >> ~/.bash_profile
mkdir tools
cd tools
@kaido24
kaido24 / module_remover.sh
Last active January 17, 2018 20:37
remove drupal unused modules
#!/bin/bash
# Drupal 8 Use https://www.drupal.org/project/unused_modules module
# Next row code is for console dev tools at run at admin/config/development/unused_modules/projects/disabled
# var rows=jQuery('tbody tr');var results=[];jQuery.each(rows,function(i,v){locrow=jQuery(this);results.push(jQuery(locrow[0].children[0]).text());});console.log(results.join(' '));
# Usage run command: sh module_remover.sh at your composer path
module_list=(unused_module1 unused_module2)
for i in ${module_list[@]}; do
composer remove drupal/$i | rm -rf modules/$i
Remove all drupal 7 users exept those with id on $keep var.
$users = entity_load('user');
$keep = [
1,348,647,648,690,649,646
];
foreach ($users as $uid => $user) {
if (!in_array($uid, $keep)) {
user_delete($uid);
}
}
@kaido24
kaido24 / bootstrap_theme_generate.sh
Last active January 13, 2021 13:18
Generate Drupal 8 Bootstrap LESS prepared subtheme with grunt config.
#!/bin/bash -x
echo Are you at themes folder y/n?
read IS_THEME_FOLDER
if [ $IS_THEME_FOLDER != 'y' ];then
exit
fi
if ! [ -d bootstrap ];then
drush dl bootstrap
fi
@kaido24
kaido24 / .vimrc
Created June 21, 2016 19:30 — forked from rteijeiro/.vimrc
Vim config for Drupal project development
" Allow Vim-only settings even if they break vi keybindings.
set nocompatible
" Enable filetype detection.
filetype off
filetype plugin indent on
" Enable syntax highlighting
if &t_Co > 1
syntax enable