Skip to content

Instantly share code, notes, and snippets.

View sun's full-sized avatar
👌
Happy

Daniel Kudwien sun

👌
Happy
View GitHub Profile
@sun
sun / child-result-tranfer.patch
Created July 28, 2014 20:52
PHPUnit: Use php://fd/3 (custom file descriptor) to transfer child process results — FAILS on Windows
diff --git a/src/Util/PHP.php b/src/Util/PHP.php
index d3d36a0..e173775 100644
--- a/src/Util/PHP.php
+++ b/src/Util/PHP.php
@@ -84,7 +84,7 @@ public function runTestJob($job, PHPUnit_Framework_Test $test, PHPUnit_Framework
$_result = $this->runJob($job);
$this->processChildResult(
- $test, $result, $_result['stdout'], $_result['stderr']
+ $test, $result, $_result['result'], $_result['stdout'], $_result['stderr']
@sun
sun / php-file.sh
Created July 21, 2014 23:02
PHP CLI vs. STDIN / STDOUT / STDERR — https://bugs.php.net/bug.php?id=43283
$ echo "<?php var_dump(STDOUT);" > y.stdout
$ php y.stdout
resource(2) of type (stream)
@sun
sun / rewrite-tests.php
Created July 2, 2014 12:59
Rewrite D8 tests to convert getInfo() into PHPDoc
<?php
use Drupal\Core\DrupalKernel;
use Drupal\simpletest\TestDiscovery;
use Sun\StaticReflection\ReflectionClass;
use Sun\StaticReflection\ReflectionDocComment;
use Symfony\Component\HttpFoundation\Request;
$autoloader = require __DIR__ . '/../vendor/autoload.php';
@sun
sun / bench.basename.php
Created June 22, 2014 15:41
Bench basename() for namespaced class names
<?php
# Simple PHP 5.4+ bench script for CLI.
const ITERATIONS = 10000;
error_reporting(E_ALL | E_STRICT);
setlocale(LC_ALL, 'C');
register_shutdown_function(function () {
echo PHP_EOL;
$memory_peak_end = memory_get_peak_usage();
@sun
sun / config-dev.patch
Last active August 29, 2015 13:59
D8 config in files for development
diff --git a/sites/default/settings.php b/sites/default/settings.php
index b2ce930..9d0514e 100644
--- a/sites/default/settings.php
+++ b/sites/default/settings.php
@@ -611,7 +611,8 @@
* The 'bootstrap_config_storage' setting needs to be a callable that returns
* core.services.yml.
*/
- # $settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage');
+$settings['bootstrap_config_storage'] = 'Drupal\Core\Config\BootstrapConfigStorageFactory::getFileStorage';
@sun
sun / cc.php
Created March 16, 2014 22:45
D8 cc.php
<?php
/**
* @file
* Script to flush all caches in Drupal 8.
*
* Place this script into your Drupal document root; i.e., /cc.php
* and request it in your browser.
*/
@sun
sun / retest.sql
Last active August 29, 2015 13:57
PIFR retest SQL
SELECT
pd.test_id AS test_id,
-- Dataset is too large; sort in PHP instead.
pd.last_tested
FROM pift_data pd
-- Using an external aggregate as filter/join condition for a query
-- is the exact point where MySQL melts down :-/
INNER JOIN (
SELECT
MAX(pd2.test_id) AS maxid
@sun
sun / bench.php
Created February 6, 2014 23:17
ExtensionDiscovery benchmark script
<?php
# Simple PHP 5.4+ bench script for CLI.
use Symfony\Component\HttpFoundation\Request;
const ITERATIONS = 1;
error_reporting(E_ALL | E_STRICT);
require_once 'core/vendor/autoload.php';
require_once 'core/includes/bootstrap.inc';
@sun
sun / Site.php
Created January 16, 2014 06:07
Singleton
<?php
/**
* @file
* Contains \Drupal\Core\Utility\Site.
*/
namespace Drupal\Core\Utility;
use Drupal\Component\Utility\Settings;
@sun
sun / reinstall.php
Last active December 31, 2015 06:39
D8 reinstall.php
<?php
/**
* This gist is no longer maintained - it is a proper repo now:
*
* @see https://github.com/sun/drupal-reinstall
*/
# ██╗ ██╗██████╗ ██████╗ ███╗ ██╗ ██████╗