Skip to content

Instantly share code, notes, and snippets.

View LionsAd's full-sized avatar

Fabian Franz LionsAd

  • LionsAd
  • Schweiz
View GitHub Profile
@LionsAd
LionsAd / CFBackendPatch.diff
Created April 7, 2019 18:16
CFBackendPatch.diff
diff --git a/web/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php b/web/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php
--- a/web/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php
+++ b/web/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php
@@ -46,6 +46,9 @@ public function __construct($root, $site_path, CacheTagsChecksumInterface $check
else {
$this->backendClass = 'Drupal\Core\Cache\Apcu4Backend';
}
+
+ $this->backendClass = 'Drupal\Core\Cache\CFAwareApcuBackend';
+ //$this->backendClass = 'Drupal\Core\Cache\ShmBackend';
@LionsAd
LionsAd / CFAwareApcuBackend.php
Last active November 21, 2018 20:37
CFAwareApcuBackend -- ChainedFastAware APCu Cache backend
<?php
namespace Drupal\Core\Cache;
use Drupal\Component\Assertion\Inspector;
/**
* Stores cache items in the Alternative PHP Cache User Cache (APCu).
*/
class CFAwareApcuBackend extends ApcuBackend {
@LionsAd
LionsAd / spectre-thread.c
Last active February 21, 2019 17:42 — forked from ErikAugust/spectre.c
Spectre example code - using threads and showing detailed statistics
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <pthread.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
<?php
function yac_store() {
static $yac;
if (!isset($yac)) {
$yac = new Yac('');
}
return $yac;
<?php
/**
* @file
*
* Contains Drupal\newsletter_view\Controller\NewsletterViewNodeController
*/
namespace Drupal\newsletter_view\Controller;
@LionsAd
LionsAd / test_php7_crash.php
Created October 29, 2015 01:21
Test PHP7 crash with Drupal 8
<?php
function foo() {}
function bar() {}
function crash_merge($attached) {
$merge = [ 'html_head' => ['2']];
$attached = array_merge_recursive(
@LionsAd
LionsAd / big_pipe_aps.diff
Created October 1, 2015 19:12
Ajax Page State Reducing
diff --git a/core/modules/big_pipe/big_pipe.module b/core/modules/big_pipe/big_pipe.module
index 724cd1c..f1af3a4 100644
--- a/core/modules/big_pipe/big_pipe.module
+++ b/core/modules/big_pipe/big_pipe.module
@@ -18,8 +18,16 @@
function big_pipe_js_settings_alter(&$settings) {
// Store the settings for later usage.
if (isset($settings['bigPipeResponseMarker'])) {
- \Drupal::service('big_pipe')->setAjaxPageState(isset($settings['ajaxPageState']) ? $settings['ajaxPageState'] : NULL);
+ $ajax_page_state = isset($settings['ajaxPageState']) ? $settings['ajaxPageState'] : NULL;
@LionsAd
LionsAd / half-pipe.php
Created September 13, 2015 15:13
Half Pipe WIP
<?php
// ...
if (!empty($half_pipe_placeholders)) {
$extra_attachments = $this->doHalfPipe($page_parts[0], $half_pipe_placeholders);
// Print the extra attachments.
if (!empty($extra_attachments['library']) || !empty($extra_attachments['drupalSettings'])) {
$all_attachments = BubbleableMetadata::mergeAttachments($attachments, $extra_attachments);
@LionsAd
LionsAd / container-decorator-test.php
Last active September 2, 2015 17:14
Test script to test container decoration
<?php
require "autoload.php";
use Drupal\Component\DependencyInjection\Dumper\PhpArrayDumper;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/*
@LionsAd
LionsAd / hack-the-renderer.diff
Last active September 1, 2015 10:55
Cleanup renderer, prepare for passing just one cacheable metadata to doRender()
diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php
index f2be9ce..82f6228 100644
--- a/core/lib/Drupal/Core/Render/Renderer.php
+++ b/core/lib/Drupal/Core/Render/Renderer.php
@@ -131,10 +131,23 @@ public function renderRoot(&$elements) {
// Render in its own render context.
$this->isRenderingRoot = TRUE;
- $output = $this->executeInRenderContext(new RenderContext(), function () use (&$elements) {
- return $this->render($elements, TRUE);