Skip to content

Instantly share code, notes, and snippets.

View johnny-aroza's full-sized avatar
🚴‍♂️
Hakuna Mata

johnny johnny-aroza

🚴‍♂️
Hakuna Mata
View GitHub Profile
@johnny-aroza
johnny-aroza / AddTranslation.php
Created May 3, 2024 10:06
Drupal add Translation through code
$language = \Drupal::languageManager()->getLanguage('es-ar');
$translatedNode = $entity->addTranslation($language->getId());
$translatedNode->setTitle('ec-er Title');
$translatedNode->save();
dump($translatedNode);
@johnny-aroza
johnny-aroza / EventSearchapi.php
Created May 3, 2024 09:57
Search API Event Suscriber to update custom value
<?php
declare(strict_types=1);
namespace Drupal\ecm_solr\EventSubscriber;
use Drupal\search_api\Event\SearchApiEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\search_api\Event\IndexingItemsEvent;
@johnny-aroza
johnny-aroza / proxy-drama.md
Last active January 18, 2021 03:23
Drupal 8 reverse proxy drama

If the environment is using load balancer or reverse proxy / keubernates pod / cloudflare your reading the right gist

As drupal as has removed hard coding the base url from the settings.php

add followig in settings.php

// add trusted patterns 
$settings['trusted_host_patterns'] = [
 '^dg8\.test\.dev$',
@johnny-aroza
johnny-aroza / phpspreadsheet.md
Last active November 6, 2020 06:47
Phpspreadsheet sheet cheatsheet

Get sheet count

 $spreadsheet = new Spreadsheet();
 $count = $spreadsheet->getSheetCount();
@johnny-aroza
johnny-aroza / fish.md
Last active March 19, 2021 09:48
Make the command line fish & bobfish theme for linux N & mac
@johnny-aroza
johnny-aroza / Lando-with Mac.md
Last active August 16, 2025 09:37
Lando - install in Mac
@johnny-aroza
johnny-aroza / cc zuhair
Created December 13, 2018 05:36
ubunutu backup
<h2>Necessary PHP 7.1 extensions to be installed</h2>
```
sudo apt-get install php7.1 php7.1-cli php7.1-common libapache2-mod-php7.1 php7.1-mysql php7.1-fpm php7.1-curl php7.1-gd php7.1-bz2 php7.1-mcrypt php7.1-json php7.1-tidy php7.1-mbstring php-redis php-memcached php7.1-xml
```
<h2>Install Chromium</h2>
````
sudo apt-get install chromium-browser
@johnny-aroza
johnny-aroza / fish-config.md
Last active October 14, 2019 12:32
config fish

file name - config.fish

path : ~/.config/fish/config.fish


set PATH $PATH $HOME/.composer/vendor/bin

@johnny-aroza
johnny-aroza / gist:3defd2e566bf20a021090792a2f9071a
Last active October 14, 2019 09:49
Custom code to create new mode for article and basic page

Drupal 7 method The following code snippet can be used wherever there is a requirement to add a new node, being sure to replace <title> and with their actual values.

global $user;
  $node = new stdClass();
  $node->title = "<title>";
  $node->type = "<node>";
  node_object_prepare($node); // Sets some defaults. Invokes hook_prepare() and hook_node_prepare().
@johnny-aroza
johnny-aroza / gist:b835c5f7ce4720523f7e36e389114ae1
Created August 1, 2018 07:53
Installing Screen recorder for ubuntu machine
Run the following command into the Terminal:
sudo apt install kazam
New Version With Broadcast
sudo apt-add-repository ppa:sylvain-pineau/kazam
sudo apt update
sudo apt install kazam