Skip to content

Instantly share code, notes, and snippets.

View pfaocle's full-sized avatar

Paul Byrne pfaocle

View GitHub Profile
@pfaocle
pfaocle / NodeParagraphTextarea.php
Created October 19, 2016 08:57
Migrate D6 node body into D8 Paragraphs field
<?php
/**
* @file
* Migrate D6 node body into D8 Paragraphs field.
*
* @see http://www.amitgoyal.in/2016/03/d6-d8-migration-d6-body-d8-paragraph-type-text.html
*/
namespace Drupal\ixis_migrate_from_d6\Plugin\migrate\process;
@pfaocle
pfaocle / git-prune-local-branches-with-deleted-remote.sh
Created April 5, 2016 09:26
Prune local tracking branches that do not exist on remote anymore
git fetch --prune && git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
@pfaocle
pfaocle / ContentTypes.php
Created March 11, 2016 09:50
Generic Codeception Cest for testing content types and fields with Drupal Content Type Registry
<?php
use \AcceptanceTester\AuthenticatedSteps;
use \Codeception\Module\Drupal\ContentTypeRegistry\ContentType;
use \Codeception\Module\Drupal\Pages\AdminContentTypesPage;
use \Codeception\Module\Drupal\Pages\AdminManageFieldsPage;
/**
* Test defined content types and fields.
*
* @guy AcceptanceTester\AuthenticatedSteps
@pfaocle
pfaocle / gen-d8-salt.sh
Created March 8, 2016 09:39
Generate Drupal 8 hash salt
drush eval "var_dump(Drupal\Component\Utility\Crypt::randomBytesBase64(55))"
@pfaocle
pfaocle / mysql_drop_tables.sh
Created February 11, 2016 12:29
Drop all tables in DB via command line
#!/usr/bin
mysqldump -u username -p --no-data dbname | grep ^DROP > drop.sql
mysql -u username -p dbname < drop.sql
rm drop.sql
@pfaocle
pfaocle / remove_null_filters.php
Created January 27, 2016 16:59
Remove null filters from migrated D8 text formats
<?php
use Drupal\filter\Plugin\Filter\FilterNull;
/**
* Run on migrated text formats which have "missing" or null filters.
*
* @see \Drupal\filter\FilterFormatFormBase::form()
*/
function _update_text_formats() {
@pfaocle
pfaocle / php-scream.sh
Created August 29, 2014 10:54
Run PHP script - ignore @ error suppressions and show a backtrace.
#!/bin/sh
# SCREAM ERR0R.
php -d xdebug.scream=1 vendor/bin/codecept build
@pfaocle
pfaocle / GuysInCest.php
Last active August 29, 2015 14:05
Best option for chucking around $I in Cest classes?
<?php
class CheeseCest
{
/**
* A test.
*
* @param AuthenticatedStepsInterface $I
* The Guy object being used to test.
*/
#!/bin/sh
cat **/*.(php|module|inc|css|js) | wc -l
@pfaocle
pfaocle / xcli.sh
Last active December 28, 2015 17:29
Enables xdebug for PHP CLI (e.g. Drush).
#XDEBUG_CONFIG="profiler_enable=1"
XDEBUG_CONFIG="idekey=phpstorm"
export XDEBUG_CONFIG