Skip to content

Instantly share code, notes, and snippets.

View davidjguru's full-sized avatar
🍅
Working within a pomodoro cycle

David Rodriguez davidjguru

🍅
Working within a pomodoro cycle
View GitHub Profile
@davidjguru
davidjguru / create_configure_and_deploy_drupal_installation_using_DDEV.md
Last active June 14, 2021 20:43
Drupal 8 || 9 - Create, configure and deploy a Drupal installation using DDEV

Quick Deploy of a Drupal 9 Site in a local environment using DDEV: This snippet is gathering some basic tasks with DDEV in order to create, config and then deploy a local Drupal installation. DDEV is a quite interesting development tool for Drupal, based in Docker and Docker-Compose. This tool can facilitate the development of Drupal projects.

Know more about DDEV:

@davidjguru
davidjguru / drupal_8_9_how_to_create_media_remote_video_entity_node_programmatically.md
Created June 9, 2021 18:49
Drupal 8 || 9 - How to create a media (remote video) entity node programmatically
use Drupal\media\Entity\Media;


// Model: https://www.youtube.com/embed/234Dfq985c1?enablejsapi=1&rel=0&showinfo=0&autoplay=1
$second_part = explode("/", $iframe_code)[4];
$video_code = explode("?", $second_part)[0];
$wellformed_url = "https://youtube.com/watch?v=" . $video_code;

// Create the new media item. 
@davidjguru
davidjguru / intro_drupal_truncate_watchdog_table_using_drush.md
Last active April 22, 2024 11:27
Drupal 8 || 9 : Truncate Watchdog table using Drush from a DDEV deploy.
@davidjguru
davidjguru / a_drupal_8_9_loading_set_of_files_to_image_field.md
Last active May 23, 2021 10:09
Drupal 8 || 9 - Loading a set of files in a image field programmatically

Intro

Sometimes you need create nodes by coding and add some resources to its fields, just like images. It's very common find examples about loading an image resource to an image field, ok. But what's going on when the field is multiple and you need load some images for the same image field in a node? Well, I wrote down a snippet with a specific case about it.

In this case I'm building local image files from an external source.

You can read more about creating nodes and fields programmatically here in my sketchbook:

https://davidjguru.github.io/blog/drupal-snippets-creating-nodes-by-code

@davidjguru
davidjguru / drush_create_admin_drupal_8_9.md
Created April 27, 2021 12:09
Create a new admin user in Drupal 8 or 9 by Drush
$ 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 March 29, 2021 10:15
Keys for title in git commits

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 April 29, 2024 17:54
BASH Aliases commands for a Linux (Debian / Ubuntu) environment
## 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 March 11, 2021 09:03
Drupal 8 || 9 - Working from prompt using aliases

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 February 22, 2021 09:10
Drupal 8 || 9 - Creating custom resources using `drush generate`

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 January 31, 2021 13:43
Drupal 8 || 9: Enabling debugging in VSCode for DDEV-Local deploys
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"hostname": "0.0.0.0",
"port": 9000,
"pathMappings": {