Skip to content

Instantly share code, notes, and snippets.

View pthurmond's full-sized avatar

Patrick Thurmond pthurmond

View GitHub Profile
@pthurmond
pthurmond / associative_array_splicer.php
Last active April 17, 2021 04:10
This is a tool to allow a programmer to easily insert a new associative index into a desired position in a PHP associative array.
View associative_array_splicer.php
<?php
/**
* Insert an associative array into a specific position in an array.
*
* @param array $original
* The original array to add to.
* @param array $new
* The new array of values to insert into the original.
* @param int $offset
* The position in the array ( 0 index ) where the new array should go.
@pthurmond
pthurmond / README_YouTube_Pause.md
Last active January 7, 2022 21:05
Pause YouTube videos on slide change. Example with SwiperJS and Drupal 9.
View README_YouTube_Pause.md

Notes

This requires one more thing. The YouTube video URL needs parameters to tell it to accept commands. In my application, which is Drupal 9, I use a hook to modify the URL of all YouTube video URLs.

Example URL: https://www.youtube.com/embed/f5piHKZPoP4?rel=0&autoplay=0&enablejsapi=1

Specifically, the "enablejsapi" parameter is what enables this. I will also share a php file with the Drupal hook I used for this.

To learn more about the optional parameters you can pass, look at this documentation: https://developers.google.com/youtube/player_parameters

@pthurmond
pthurmond / .gitignore
Last active July 26, 2022 20:44
Example of a Drupal 8 composer file with patches
View .gitignore
# Ignore directories generated by Composer
/drush/Commands/contrib/
/vendor/
/docroot/core/
/docroot/modules/contrib/
/docroot/themes/contrib/
/docroot/profiles/contrib/
/docroot/libraries/
/docroot/README.md
View Drupal Permissions Setup.md

Drupal Permissions Setup

I am writing this in conjunction with the setup of a new Drupal 10 site on my local. The setup is a little different than the instructions call for because I am doing the setup within Lando. This means that the permissions didn't come out right and editing the site files directly on my machine leads to having read-only access.

Work done here is on Mac OS X 13.5 Ventura. But should apply to any Mac or Linux machine.

To resolve that, I did the following things after the initial site setup with composer within Lando:

  1. First, I checked the directory permissions. You can do that with stat -f '%A %N' *.
  2. That shows me the permissions in numerical format. All the files should be 644 and the directories be 755.