Skip to content

Instantly share code, notes, and snippets.

View selwynpolit's full-sized avatar

Selwyn Polit selwynpolit

View GitHub Profile
@selwynpolit
selwynpolit / SrpAddFeedbackForm.php
Created June 7, 2021 21:34
How to add a cancel button to close an off_canvas form and make it act like the x or escape key
<?php
namespace Drupal\tea_teks_srp\Form;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Ajax\CloseModalDialogCommand;
use Drupal\Core\Ajax\CloseDialogCommand;
use Drupal\Core\Ajax\AjaxResponse;
@selwynpolit
selwynpolit / behat.yml
Last active May 18, 2021 22:10
troubleshooting behat testing with DDEV and Chromedriver
default:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\MinkContext
gherkin:
cache: ~
extensions:
@selwynpolit
selwynpolit / read_csv.php
Last active February 14, 2024 16:56
Php code to read a csv file of any size without exhausting memory and let you process it in chunks
/*
Reads a CSV file in chunks of 10 lines at a time
and returns them in an array of objects for processing.
Assumes the first line of the CSV file has headings
that will be used as the object name for the item you are
processing. i.e. the heading is CurrentURL then refer to
$item->CurrentURL
@selwynpolit
selwynpolit / config.yml
Created March 1, 2018 01:44
DrupalVM config.yml file for Mac OSX
---
# Available `vagrant_box` values include:
# - beet/box (pre-provisioned, based on Ubuntu 16.04)
# - geerlingguy/centos7
# - geerlingguy/centos6
# - geerlingguy/debian9
# - geerlingguy/debian8
# - geerlingguy/ubuntu1604
# - geerlingguy/ubuntu1404
vagrant_box: geerlingguy/ubuntu1604
/**
* Constructor.
*
* A Migration constructor takes an array of arguments as its
* first parameter. The arguments must be passed through to the parent
* constructor.
*
* @param array $arguments
* Arguments
*/
<script>
(function(dataLayer, $) {
var reachedBottom = false;
//returns true if view is at or below element
function scrolledToBottom(elem) {
var $elem = $(elem);
if ($elem.length > 0) {
var $window = $(window);
@selwynpolit
selwynpolit / gtm_video_tracker.html
Created February 2, 2016 22:44
gtm video tracker
<script type="text/javascript">
// This code loads the IFrame Player API code asynchronously.
(function GtmVideoTracker(){
var tag = document.createElement('script');
var firstScriptTag = document.getElementsByTagName('script')[0];
window.GTMplayers = window.GTMplayers || [];
tag.src = "https://www.youtube.com/iframe_api";
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
@selwynpolit
selwynpolit / migrate.migration.recipe_node.yml
Created December 10, 2015 16:46
Drupal 8 migration from sage api
# Migration configuration for recipe content.
id: recipe_node
label: Recipes from Sage
migration_group: recipe
source:
plugin: wfm_migrate_recipe
destination:
plugin: entity:node
process:
# Hardcode the destination node type (bundle) as 'migrate_example_recipe'.
This is a test