Skip to content

Instantly share code, notes, and snippets.

Avatar

David Rodríguez davidjguru

View GitHub Profile
@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 \
@davidjguru
davidjguru / light_local_deploy_of_drupal_setup.md
Last active Oct 4, 2020
Ultra-lightweight deploy of Drupal setup (without Apache or MySQL)
View light_local_deploy_of_drupal_setup.md

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.txt
Created Sep 7, 2020
Quick Deploy of a Drupal 9 Site in a local environment using DDEV.
View quick_deploy_of_drupal_9_using_DDEV.txt
$ 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 Jun 24, 2020
Rendering a Form inside a custom Block by code in Drupal 8 || 9
View ManagingActivitiesRegisterBlock.php
<?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;
/**
View gist:126aa9f2a1ada52ac49fa500181fd82c
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
@davidjguru
davidjguru / __INDEX.txt
Created May 15, 2020 — forked from facine/__INDEX.txt
Drupal 8 - Examples
View __INDEX.txt
# Taxonomy terms:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_taxonomy_term-php
# Menu links:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_menu_link-php
# File items:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_file-php
# Nodes:
@davidjguru
davidjguru / installing_ddev_and_docker_engine.md
Created Apr 20, 2020
Local environments for Drupal 8 | 9: Install & Configure DDEV and the Docker Engine
View installing_ddev_and_docker_engine.md
You can’t perform that action at this time.