I've been thinking about efficently re-rendering Twig template in the browser recently...
Given this template:
<div>{{ variable }}</div>
{% if flag == true %}
<div>{{ variable2 }}</div>
{% endif %}
I've been thinking about efficently re-rendering Twig template in the browser recently...
Given this template:
<div>{{ variable }}</div>
{% if flag == true %}
<div>{{ variable2 }}</div>
{% endif %}
# This script attempts to create a patch file that includes all security fixes | |
# between two tags. | |
# Hypothetically, you could just apply the patch to your Drupal site after the | |
# script is finished successfully to be up to date. | |
# Biggest successful D7 patch - 7.36 => 7.58 | |
# Biggest successful D8 patch - 8.4.0 => 8.4.7 / 8.6.0 => 8.6.7 | |
# WARNING: This is an experimental patch generation method and may not be | |
# perfect. If you use this on production I take no responsibility for your |
<?php | |
use Symfony\Component\Process\Process; | |
// The total sleep time of this queue is 22, but it only takes ~10 seconds to | |
// run as new commands are started as soon as another finishes and the | |
// $concurrency limit is not met. | |
$command_queue = [ | |
'sleep 1', | |
'sleep 1', |
<?php | |
use Drupal\Component\Graph; | |
function chunk_graph(Graph $graph_object) { | |
// Sort the graph by weight. | |
$graph = $graph_object->searchAndSort(); | |
uasort($graph, 'Drupal\Component\Utility\SortArray::sortByWeightElement'); | |
// Ensure that graph nodes are sorted from least to most edges. | |
$graph = array_reverse($graph); |
<?php | |
// Download to Drupal root (where index.php is) and run "drush scr dump.php" | |
$storage = \Drupal::entityTypeManager()->getStorage('node'); | |
$nodes = $storage->loadMultiple(); | |
echo 'Processing ' . count($nodes) . ' nodes...' . "\n"; |
<?php | |
/** | |
* @file | |
* Allows Node to make command line requests without a web server. | |
* | |
* Example use with Node to POST content: | |
* const { spawnSync } = require('child_process'); | |
* const input = JSON.stringify({ path: '/some/path', content: 'request content' }); | |
* spawnSync(drush, ['php:script', 'request.php', '--script-path=some/script/path'], { input: input }); |
<?php | |
/** | |
* Implements hook_metatags_attachments_alter(). | |
* | |
* This function allows you to define fallback tokens in case a field is empty. | |
* | |
* If all fallback values are empty, the tag will be empty. | |
* | |
* Example: [node:field_image:medium]||[node:field_legacy_image:medium]||/fallback.png |
#!/usr/bin/env bash | |
# Use: Create an empty directory and download this file as netlifybug.sh | |
# Then, run "netlify link", then ./netlifybug.sh. | |
# Use default deploy path (".") at prompts. | |
# You should see a failed deploy first, then a successful deploy after. | |
mkdir -p subdir | |
touch index.html subdir/index.html | |
RAND=$(openssl rand -base64 12) |
services: | |
php: | |
image: tugboatqa/php:7.2-apache | |
default: true | |
depends: mysql | |
commands: | |
init: | |
- docker-php-ext-install opcache | |
- a2enmod headers rewrite | |
- wget -O /usr/local/bin/drush |
FROM php:7.2-apache | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends git zip openssh-client sqlite3 libsqlite3-dev | |
# This is copied from the official Docker "drupal" image's Dockerfile. | |
# install the PHP extensions we need | |
RUN set -ex; \ | |
\ | |
if command -v a2enmod; then \ |