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 / drupal_8_9_creating_custom_module_using_drush_generate.md
Last active August 28, 2024 05:28
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": {
@davidjguru
davidjguru / get_a_list_with_the_most_changed_files_using_git.md
Created November 21, 2020 22:37
Git: Get a list with the most changed files from 12 months ago in a project folder

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 August 28, 2024 05:30
i18n: Loading a new Language in a Drupal installation
// 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 November 12, 2020 17:47 — forked from bdlangton/Blocks.md
Drupal 8 programmatic solutions

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 October 4, 2020 12:36
Installing a basic PHP setup in Debian / Ubuntu (7.4)
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 \
@davidjguru
davidjguru / light_local_deploy_of_drupal_setup.md
Last active August 28, 2024 05:30
Ultra-lightweight deploy of Drupal setup (without Apache or MySQL)

Pre-requisites

You will need a initial PHP setup in your OS. If you're in Debian / Ubuntu use the next gist in order to execute a basic script for installing the resources.
Gist: Installing a basic PHP setup in Debian / Ubuntu (7.4): https://gist.github.com/davidjguru/18e53e39a569a12ea79595ed7971b739.

Fast local deploy

:~$ cd workspace/
:~$ composer create-project drupal/recommended-project drupal_decoupled
:~$ cd drupal_decoupled/
:~$ composer require "drupal/jsonapi_extras" "drupal/paragraphs" "drupal/consumers" "drupal/simple_oauth" "drupal/subrequests"

@davidjguru
davidjguru / quick_deploy_of_drupal_9_using_DDEV.md
Last active August 28, 2024 05:42
Quick Deploy of a Drupal 9 Site in a local environment using DDEV.
$ mkdir example-drupal && cd example-drupal
$ ddev config --project-type=drupal9 --docroot=web --create-docroot
$ ddev composer create "drupal/recommended-project"
$ ddev composer require drush/drush drupal/admin_toolbar drupal/devel
$ ddev exec drush si --site-name=Example-Drupal --account-name=admin --account-pass=admin -y
$ ddev start && ddev launch
@davidjguru
davidjguru / ManagingActivitiesRegisterBlock.php
Created June 24, 2020 11:18
Rendering a Form inside a custom Block by code in Drupal 8 || 9
<?php
namespace Drupal\managing_activities\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@davidjguru
davidjguru / gist:126aa9f2a1ada52ac49fa500181fd82c
Created May 25, 2020 18:14 — forked from rajeshpv/gist:6356679
Install Balsamiq for ubuntu
helpfull links
(1) https://gist.github.com/cbednarski/5379830
(2) http://www.clarifylinux.org/2012/04/ubuntu-1204-tweak-and-hack-round-up.html
(3) http://jeffhendricks.net/?p=68
(4) BEST for 64 bit http://www.randomhacks.co.uk/how-to-install-balsamiq-mockups-on-ubuntu-13-10/
The steps I did
RUN>>
locate libgnome-keyring.so /usr/lib/i386-linux-gnu/libgnome-keyring.so.0 /usr/lib/i386-linux-gnu/libgnome-keyring.so.0.2.0