Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Byrne pfaocle

View GitHub Profile
@pfaocle
pfaocle / NodeParagraphTextarea.php
Created Oct 19, 2016
Migrate D6 node body into D8 Paragraphs field
View NodeParagraphTextarea.php
<?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 Apr 5, 2016
Prune local tracking branches that do not exist on remote anymore
View git-prune-local-branches-with-deleted-remote.sh
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 Mar 11, 2016
Generic Codeception Cest for testing content types and fields with Drupal Content Type Registry
View ContentTypes.php
<?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 Mar 8, 2016
Generate Drupal 8 hash salt
View gen-d8-salt.sh
drush eval "var_dump(Drupal\Component\Utility\Crypt::randomBytesBase64(55))"
@pfaocle
pfaocle / mysql_drop_tables.sh
Created Feb 11, 2016
Drop all tables in DB via command line
View mysql_drop_tables.sh
#!/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 Jan 27, 2016
Remove null filters from migrated D8 text formats
View remove_null_filters.php
<?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 Aug 29, 2014
Run PHP script - ignore @ error suppressions and show a backtrace.
View php-scream.sh
#!/bin/sh
# SCREAM ERR0R.
php -d xdebug.scream=1 vendor/bin/codecept build
@pfaocle
pfaocle / GuysInCest.php
Last active Aug 29, 2015
Best option for chucking around $I in Cest classes?
View GuysInCest.php
<?php
class CheeseCest
{
/**
* A test.
*
* @param AuthenticatedStepsInterface $I
* The Guy object being used to test.
*/
View code-count.sh
#!/bin/sh
cat **/*.(php|module|inc|css|js) | wc -l
@pfaocle
pfaocle / xcli.sh
Last active Dec 28, 2015
Enables xdebug for PHP CLI (e.g. Drush).
View xcli.sh
#XDEBUG_CONFIG="profiler_enable=1"
XDEBUG_CONFIG="idekey=phpstorm"
export XDEBUG_CONFIG