Skip to content

Instantly share code, notes, and snippets.

Avatar

David Rodríguez davidjguru

View GitHub Profile
@davidjguru
davidjguru / drush_create_admin_drupal_8_9.md
Created Apr 27, 2021
Create a new admin user in Drupal 8 or 9 by Drush
View drush_create_admin_drupal_8_9.md
$ drush user-create admin_drupal --mail="admindrupal@test.com" --password="admin_drupal"
$ drush user-add-role "administrator" admin_drupal
$ drush cr
@davidjguru
davidjguru / keys_for_titles_in_commits.md
Created Mar 29, 2021
Keys for title in git commits
View keys_for_titles_in_commits.md

Keys for titles in commits

  • (INI) - Initial commit in a repository.
  • (JVS) - Changes in JavaScript code or .js files.
  • (PHP) - Same as former but for PHP code or .php files.
  • (TWG) - Work over TWIG template files.
  • (BSH) - Related with bash scripting.
  • (CFG) - Changing configuration files.
  • (TXT) - Change content in text.
  • (DCK) - Adds changes in Dockerfile or Docker related resources.
@davidjguru
davidjguru / bash_aliases
Last active Apr 24, 2021
BASH Aliases commands for a Linux (Debian / Ubuntu) environment
View bash_aliases
## Morning Opertures
alias whatsup='service --status-all'
alias hello='sudo /etc/init.d/apache2 stop && cd workspace/project && ddev start && ddev launch'
alias hi='sudo systemctl stop apache2'
alias iad='systemctl is-active docker'
alias ports='nmap localhost'
alias dns="sudo systemd-resolve --status | grep 'DNS Servers'"
alias bye='shutdown -r now'
## Usual Instructions
@davidjguru
davidjguru / prompt_aliases_for_your_bashrc_file.md
Created Mar 11, 2021
Drupal 8 || 9 - Working from prompt using aliases
View prompt_aliases_for_your_bashrc_file.md

Introduction

Just go to your /home/user folder and edit your .bashrc file in order to include these aliases. Then reload the bashrc file and you'll get the new aliases available.

  1. :~$ cd ~
  2. :~$ vim .bashrc // :wq! (after paste the content)
  3. :~$ source .bashrc

Morning opertures

alias hello='sudo /etc/init.d/apache2 stop && cd workspace/project && ddev start && ddev launch'
alias hi=''sudo systemctl stop apache2'

@davidjguru
davidjguru / drupal_8_9_creating_custom_module_using_drush_generate.md
Last active Feb 22, 2021
Drupal 8 || 9 - Creating custom resources using `drush generate`
View drupal_8_9_creating_custom_module_using_drush_generate.md

Mother Command

$ drush generate

Response

Drush generate 10.3.6
Run drush generate [command] and answer a few questions in order to write starter code to your project.

Available commands: [...]

Creating Custom Module

@davidjguru
davidjguru / launch.json
Created Jan 31, 2021
Drupal 8 || 9: Enabling debugging in VSCode for DDEV-Local deploys
View launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"hostname": "0.0.0.0",
"port": 9000,
"pathMappings": {
@davidjguru
davidjguru / get_a_list_with_the_most_changed_files_using_git.md
Created Nov 21, 2020
Git: Get a list with the most changed files from 12 months ago in a project folder
View get_a_list_with_the_most_changed_files_using_git.md

In some lines

git log --format=format: --name-only --since=12.month \  
| egrep -v '^$' \  
| sort \  
| uniq -c \  
| sort -nr \  
| head -50
@davidjguru
davidjguru / i18n_loading_a_new_language_in_a_drupal_installation.md
Last active Nov 12, 2020
i18n: Loading a new Language in a Drupal installation
View i18n_loading_a_new_language_in_a_drupal_installation.md
// Sets the target and loads the current languages in your Drupal installation.
$code = 'pt';
$current_langcodes = \Drupal::languageManager()->getLanguages();
$current_langcodesList = array_keys($current_langcodes);
 
// Only creates the referred language if not exists.
if (!in_array($code, $current_langcodesList)){
    $language = ConfigurableLanguage::createFromLangcode($code);
    $language->save();
@davidjguru
davidjguru / Blocks.md
Created Nov 12, 2020 — forked from bdlangton/Blocks.md
Drupal 8 programmatic solutions
View Blocks.md

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
@davidjguru
davidjguru / install_basic_php_setup_debian_ubuntu.sh
Created Oct 4, 2020
Installing a basic PHP setup in Debian / Ubuntu (7.4)
View install_basic_php_setup_debian_ubuntu.sh
sudo apt --qq update &&
sudo apt -qq upgrade &&
sudo apt -yqq install \
php7.4 \
php7.4-bcmath \
php7.4-bz2 \
php7.4-curl \
php7.4-dev \
php7.4-gd \
php7.4-dom \