Skip to content

Instantly share code, notes, and snippets.

@kerasai
kerasai / repeat.sh
Last active November 29, 2018 17:36
Repeat a migration when it fails due to not enough memory (Drupal, Pantheon, Terminus)
#!/usr/bin/env bash
# Adjust as needed to run desired migration in desired multidev.
SITE_ID=[site_env]
MIGRATION=[migration_id`]
CONTINUE=0
while [ $CONTINUE -eq 0 ]
do
echo "Running migration command..."
@kerasai
kerasai / container.php
Created December 7, 2018 04:03
Create a Symfony Container
<?php
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
// Build the container.
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__));
$loader->load('services.yml');
@kerasai
kerasai / error_reporting.php
Created December 7, 2018 04:04
PHP error reporting
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
@kerasai
kerasai / config_install.php
Created January 4, 2019 19:05
Install configuration from YML
<?php
/** @var \Drupal\Core\Config\StorageInterface $config_storage */
$config_storage = \Drupal::service('config.storage');
$path = drupal_get_path('module', 'module_name') . '/config/install';
$file_storage = new \Drupal\Core\Config\FileStorage($path);
$id = 'full.config.identifier';
$config_storage->write($id, $file_storage->read($id));
@kerasai
kerasai / xdebug.sh
Created January 25, 2019 12:13
Enables Xdebug CLI to be ran from the CLI
# Run one time, value must match value xdebug.idekey in the PHP config.
export XDEBUG_CONFIG="idekey=123"
export PHP_IDE_CONFIG="serverName=example.local"
# Toggle to enable/disable Xdebug.
export XDEBUG_CONFIG="remote_enable=1"
@kerasai
kerasai / bootstrap_node.sh
Last active September 5, 2019 17:28
Install Node
#!/usr/bin/env bash
# USE NVM instead https://github.com/nvm-sh/nvm.
set -e
cd /tmp
curl -O https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.xz
tar xf node-v10.15.1-linux-x64.tar.xz
@kerasai
kerasai / box.sh
Created February 21, 2019 23:51
Box PHAR Compilation
#!/usr/bin/bash
sudo mkdir -p /opt/box
cd /opt/box
sudo curl -OL https://github.com/humbug/box/releases/download/3.4.0/box.phar
sudo chmod +x box.phar
sudo mv box.phar box-3.4.0.phar
sudo update-alternatives --install /usr/bin/box box /opt/box/box-3.4.0.phar 10
@kerasai
kerasai / Pantheon RSYNC
Last active May 12, 2021 15:40
Pantheon RSYNC command to pull files, excluding the nonsense.
# https://pantheon.io/docs/rsync-and-sftp/
# $ENV is dev/test/live or multidev
# $SITE is UUID
# Ran from the 'sites/default' directory (or applicable site directory).
rsync -rvlz \
--copy-unsafe-links \
--size-only \
--ipv4 \
@kerasai
kerasai / renew.sh
Created May 30, 2019 14:30
Let's Encrypt Renewal
certbot certonly --manual --preferred-challenges dns --manual-public-ip-logging-ok -d '*.domain.com' -d domain.com
# update TXT records for authentication
sudo service apache2 reload
@kerasai
kerasai / renew.sh
Created May 30, 2019 14:30
Let's Encrypt Renewal
certbot certonly --manual --preferred-challenges dns --manual-public-ip-logging-ok -d '*.domain.com' -d domain.com
# update TXT records for authentication
sudo service apache2 reload