Skip to content

Instantly share code, notes, and snippets.

View weitzman's full-sized avatar

Moshe Weitzman weitzman

View GitHub Profile
# Builds a MySQL image with local data directory. See 'command' in docker-compose.yml
# Approach borrowed from https://about.zoosk.com/en/engineering-blog/test-databases-docker-containers/.
FROM mysql:5.6
RUN ["mkdir", "–p", "/var/lib/mysql-image"]
RUN echo "[mysqld]" > /etc/mysql/conf.d/mass-vm.cnf \
&& echo "datadir = /var/lib/mysql-image" >> /etc/mysql/conf.d/mass-vm.cnf
`
@weitzman
weitzman / .ahoy.yml
Last active July 19, 2018 15:36
mass.gov blog post
ahoyapi: v2
commands:
exec:
# These env variables come from https://github.com/wodby/docker4drupal/issues/273
cmd: docker-compose exec -e COLUMNS=$(tput cols) -e LINES=$(tput lines) -e TERM=$TERM drupal "$@"
usage: Run a command in the container
bash:
cmd: ahoy exec bash
usage: Open a shell inside the container.
@weitzman
weitzman / config.diff
Last active November 10, 2017 13:20
Purger config mismatch - https://www.drupal.org/node/2922493
ubuntu@box921:~/mass$ git diff
diff --git a/conf/drupal/config/purge.logger_channels.yml b/conf/drupal/config/purge.logger_channels.yml
index e16c732..e5b869d 100644
--- a/conf/drupal/config/purge.logger_channels.yml
+++ b/conf/drupal/config/purge.logger_channels.yml
@@ -11,15 +11,3 @@ channels:
- 0
- 2
- 3
- -
@weitzman
weitzman / blog.md
Last active September 29, 2017 10:07
Porting Commands to Drush9

Drush 9 features a deep rewrite of our app, both user facing and internals. We created and open sourced AnnotatedCommand, OutputFormatters, and Config. We leveraged Symfony Console for our CLI fundmentals. For details on Drush9, see the video or slides from our Drupalcon Vienna presentation.

** ADD AN ANNOTATED COMMAND EXAMPLE **

Unfortunately, old commandfiles such as example.drush.inc no longer load in Drush 9. We've made it relatively painless to port this code to Drush 9:

** ADD A GIF OF GENERATOR **

  1. Using Drush 9 on a working site, run drush generate drush-command-file. generate is a wrapper for the Drupal Code Generator
@weitzman
weitzman / FeatuesCommands.php
Created June 11, 2017 11:15
Port Features to Drush9
<?php
namespace Drupal\features\Commands;
use Consolidation\OutputFormatters\StructuredData\RowsOfFields;
use Drupal\Component\Diff\DiffFormatter;
use Drupal\config_update\ConfigDiffInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\features\FeaturesAssignerInterface;
use Drupal\features\FeaturesGeneratorInterface;
use Drupal\features\FeaturesManagerInterface;
@weitzman
weitzman / # php56 - 2017-05-08_16-14-13.txt
Created June 7, 2017 14:43
php56 (homebrew/php/php56) on macOS 10.11.6 - Homebrew build logs
Homebrew build logs for homebrew/php/php56 on macOS 10.11.6
Build date: 2017-05-08 16:14:13
Outside the VM
In PHPStorm,
Run => Start Listening for PHP Connections
Run => Break at first line in PHP scripts
Inside the VM
Navigate to docroot and run:
XDEBUG_CONFIG="idekey=phpstorm remote_host=`netstat -rn | grep "^0.0.0.0 " | tr -s ' ' | cut -d " " -f2`" php -dzend_extension=xdebug.so -d xdebug.remote_enable=1 ../vendor/bin/drush st
Sets the XDEBUG_CONFIG environment variable. The value has two components:
@weitzman
weitzman / drush8
Created May 12, 2017 15:30
drush8 wrapper when inside a a drush9 composer project. This didn't work out due to Drush8's finder finding drush9 anyway.
#!/usr/bin/env sh
SELF_DIRNAME="`dirname -- "$0"`"
PATH=$SELF_DIRNAME:$PATH DRUSH_FINDER_SCRIPT="foo" drush.phar "$@"
@weitzman
weitzman / MigrationIsRunning.php
Created April 20, 2017 14:12
Determine if a migration is running
<?php
namespace Drupal\ras_comments;
use Drupal\migrate\Event\MigrateEvents;
use Drupal\migrate\Event\MigrateImportEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
@weitzman
weitzman / gist:b5de6ab86ac1ff07e9ae
Created October 17, 2014 18:12
config-rsync - not yet tested
/*
* Command callback.
*/
function drush_config_rsync() {
// Some boring option init stuff.
$backend_options = array('integrate' => TRUE);
$global_options = drush_redispatch_get_options() + array(
'strict' => 0,
);
if (drush_get_context('DRUSH_SIMULATE')) {