Skip to content

Instantly share code, notes, and snippets.

View twfahey1's full-sized avatar

Tyler Fahey twfahey1

View GitHub Profile
@twfahey1
twfahey1 / settings.local.php
Created November 9, 2018 16:13
Lando local settings
<?php
/**
* @file
* Local settings.
*/
$lando_info = json_decode(getenv('LANDO_INFO'), TRUE);
$databases['default']['default'] = array(
@twfahey1
twfahey1 / convert-drupal-modules-to-composer.sh
Created September 26, 2019 14:49
Convert Drupal pre-composer project to Composer based
#!/bin/bash
### Convert a pre-Composer Drupal project to use Composer for contrib modules. ###
# This script can automate the process of taking a codebase previously managed via
# drush or otherwise non-composer, and add all the modules to the composer.json
# in the docroot, with the current version number. The script will get
# all modules and version numbers, and pass to composer for an update.
# This statement will be appended on as each module is found. We can add as
# many modules as are found to the statement, so that composer can fire
@twfahey1
twfahey1 / .htaccess
Created October 11, 2019 00:32
A .htaccess file for Apache based server to run Drupal in web docroot
# Assuming the Drupal site is installed in /public_html/web, place this in the /public_html folder.
RewriteEngine on
# <!-- Force HTTPS START -->
# If we receive a forwarded http request from a proxy...
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
# ...or just a plain old http request directly from the client
RewriteCond %{HTTP:X-Forwarded-Proto} =""
@twfahey1
twfahey1 / phpunit.xml
Created October 11, 2019 00:34
Docksal PHPUnit file for web docroot Drupal 8
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="/var/www/web/core/tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter">
<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
<!-- Do not limit the amount of memory tests take to run. -->
@twfahey1
twfahey1 / update-modules.php
Created October 11, 2019 00:38
Drush script for automatic updates and commits
#!/usr/bin/env drush
<?php
/**
* This script updates eligible modules and commits automatically.
*
* To use this, place this script in your site docroot. Run it with
* `drush update-modules.php`.
* This script will need the "eligible_modules" key defined in a
* drushrc.php or drushrc.local.php., e.g.:
@twfahey1
twfahey1 / run-testbot.sh
Created October 11, 2019 00:40
Run a Drupal 8 PHPUnit test via TestBot method
php core/scripts/run-tests.sh PHPUnit --dburl mysql://root:[email protected]:3306/mysitedatabase --url https://mysite.local/ --module mymodule
@twfahey1
twfahey1 / function.php
Last active November 18, 2019 16:03
Wordpress - Manipulate headers programmatically in plugin / theme
function add_header_auth( $headers ) {
if ( ! is_admin() ) {
$headers['X-Frame-Options'] = 'SAMEORIGIN';
}
return $headers;
}
add_filter( 'wp_headers', 'add_header_auth' );
@twfahey1
twfahey1 / terminus-multidev-delete-all.sh
Created November 18, 2019 22:54
Terminus multidev delete all
# This script removes all multidevs for a given environment.
# Pass the site as the first argument.
# E.g. ./terminus-multidev-delete-all.sh my-pantheon-site
SITE=$1
MULTIDEVS=$(terminus multidev:list $SITE --field=Name)
for ENV in $MULTIDEVS
do
@twfahey1
twfahey1 / README.md
Last active December 17, 2019 18:41
Check table size in mb
In this example using the bookstore database, 
we’re combining the DATA_LENGTH and INDEX_LENGTH as bytes, 
then dividing it by 1024 twice to convert into kilobytes and then megabytes.
@twfahey1
twfahey1 / puppeteer-script.js
Created January 9, 2020 02:04
Dump contents of page in puppeteer - node JS
let bodyHTML = await page.evaluate(() => document.body.innerHTML);
console.log(bodyHTML);