Skip to content

Instantly share code, notes, and snippets.

View abelperezlindo's full-sized avatar
🏠
Working from home

abelpzl abelperezlindo

🏠
Working from home
  • Argentina
View GitHub Profile
@abelperezlindo
abelperezlindo / index.php
Created January 30, 2023 18:19
Merge images with GD in php
<?php
header('Content-type: image/png');
$mapa_base = imagecreatefrompng('/var/www/html/assets/images/a.png');
$rio_negro = imagecreatefrompng('/var/www/html/assets/images/b.png');
$bsas = imagecreatefrompng('/var/www/html/assets/images/c.png');
$cordoba = imagecreatefrompng('/var/www/html/assets/images/d.png');
imagealphablending($mapa_base, TRUE);
@abelperezlindo
abelperezlindo / .zshrc
Last active December 14, 2022 15:46
Mis alias
# Mis alias
# Respetar los drupal coding standarts
alias drupalcs="phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml"
# Mejorar el log de git
alias glog='git log --graph -50 --oneline'
# Descomprimir tar gz con "untar"
alias untar='tar -xvzf'
# copy output
alias copy="| xclip -selection clipboard"
@abelperezlindo
abelperezlindo / nymudule.module
Last active December 1, 2022 13:16
Placing Components with Drupal's Extra Fields in drupal 9
<?php
// In mymodule.module :
use Drupal\node\Entity\NodeType;
use \Drupal\Core\Entity\EntityInterface;
use \Drupal\Core\Entity\Display\EntityViewDisplayInterface;
/**
@abelperezlindo
abelperezlindo / index.php
Last active October 14, 2022 14:50
Example of using PHPWord to convert html to docx. Install PHPWord with Composer.
<?php
require_once './vendor/autoload.php';
// install phpword with composer:
// composer require phpoffice/phpword
use PhpOffice\PhpWord\Style\Language;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\Html;
@abelperezlindo
abelperezlindo / TesterForm.php
Created October 12, 2022 13:12
Drupal 8/9/10 Ajax form example when select box changed and multiple options can be selected. Displays a new form element for each selected option.
<?php
namespace Drupal\tester\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\State\State;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Messenger\MessengerInterface;
@abelperezlindo
abelperezlindo / getContentAsOptions.php
Created June 3, 2022 18:07
Obtener una lista de los tipos de contenido del sitio para usarlos como opciones en un menú desplegable en Drupal 9.
use Drupal\node\Entity\NodeType;
// Code ...
$node_types = NodeType::loadMultiple();
// If you need to display them in a drop down.
$options = []; // options are stored in this variable
foreach ($node_types as $node_type) {
// Get a list of site content types to use as options in a dropdown menu in Drupal 9.