Skip to content

Instantly share code, notes, and snippets.

View pfaocle's full-sized avatar

Paul Byrne pfaocle

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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
@pfaocle
pfaocle / phpfordevelopers-exercises.php
Last active December 22, 2015 15:04
PHP for CMS Developers - Classes & Exceptions exercises
// "Main"
<?php
/**
* PHP for Developers - Exercises
*
* main/testing
*/
spl_autoload_register(function ($class_name) {
@pfaocle
pfaocle / sql_sync_wrapper.drush.inc.php
Last active December 21, 2015 22:09
An example of how to create a new Drush command which wraps an existing command.
<?php
/**
* @file
* An example of how to create a new Drush command which wraps an existing command, allowing some customisation.
*
* Note any file containing this snippet should be suffixed '.drush.inc', not '.drush.inc.php'.
*/
/* Implements COMMANDFILE_drush_command(). */
function sql_sync_wrapper_drush_command() {
@pfaocle
pfaocle / exiftool-fiddle.sh
Last active December 21, 2015 03:19
Use exiftool to fiddle the dates on photos (when I forget to set the date/time correctly on my camera).
#!/bin/sh
FILE_FORMAT="JPG"
# Show dates of all JPG files in current directory, in human readable format.
exiftool -d '%r %a, %B %e, %Y' -DateTimeOriginal -S -s -ext $FILE_FORMAT .
# Fiddle the dates - some date fields forward.
# Format is Y:M:D h:m:s
exiftool -F -AllDates+="2:6:0 0" *$FILE_FORMAT