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 / intro_gitlab_api_examples_from_php_using_guzzle.md
Created June 18, 2021 08:07
Drupal 8 || 9 - Getting info about projects and files using the Gitlab API v4 from PHP code

Well, maybe you need track some kind of information and data from Gitlab repositories and the Gitlab API (v4) seems to be very extensive and complex...ok, I understand you, really.

I had to connect a custom Drupal module to the Gitlab API in order to get some info, so I wrote down some notes with examples talkin' to the Gitlab API.

For the next examples, you only need to know your user id (no the @user, this is a keycode) and get an access token from your Gitlab profile settings. They are the basic resources requested by the Gitlab API for connections.

For more information, see the Gitlab API Resources documentation: https://docs.gitlab.com/ee/api/api_resources.html.

Author

@davidjguru
davidjguru / intro_drupal_8_9_reverse_geocoding_using_external_service_from_php.md
Last active August 28, 2024 05:25
Drupal 8 || 9 - Reverse Geocoding using external Service from PHP

I was developing an external query based in long/lat values in order to get certain addresses. For do this, I was using the geocoding library for PHP and some providers. I'm gathering here the main steps and how you can execute the integrations.

Maria Arias de Reyna, @delawen and Juan Luis Rodríguez, @juanluisrp guided me. They are the greatest GIS experts I know and they were very helpful here, givin' me some ideas and links to resources. Kudos.

Author

@davidjguru
davidjguru / create_configure_and_deploy_drupal_installation_using_DDEV.md
Last active August 28, 2024 05:25
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 August 28, 2024 05:26
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 August 28, 2024 05:26
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="[email protected]" --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 May 27, 2025 11:12
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'