Skip to content

Instantly share code, notes, and snippets.

View sun's full-sized avatar
👌
Happy

Daniel Kudwien sun

👌
Happy
View GitHub Profile
# d.o collaboration
- http://drupal.org/project/issues/webmasters
- http://drupal.org/project/issues/infrastructure
- http://drupal.org/project/issues/drupalorg
- http://drupal.org/project/issues/project
- http://drupal.org/project/issues/project_issue
# Code
- http://drupal.org/project/issues/git_dev
- http://drupal.org/project/issues/project_git_instructions
@sun
sun / gist:2822341
Created May 29, 2012 03:20
config() new
<?php
function config($name, $config_class = NULL, $storage_class = NULL) {
static $config_instances = array(), $storage_instances = array();
// Set defaults.
if (!isset($config_class)) {
$config_class = 'Drupal\Core\Config\DrupalConfig';
}
if (!isset($storage_class)) {
@sun
sun / ConfigObject.php
Created May 29, 2012 05:59
simple config object
<?php
namespace Drupal\Core\Config;
use Drupal\Core\Config\StorageInterface;
class ConfigObject {
protected $name = '';
@sun
sun / gist:3615986
Created September 4, 2012 02:47
Translatable config strings
$yaml = Yaml::dump('sun.settings.yml'):
id: my_settings
label: !!php/object:O:1:"t":1:{s:9:"*string";s:12:"Translate me";}
var_dump($parsed = Yaml::parse($yaml)):
array(2) {
["id"]=>
string(11) "my_settings"
["label"]=>
object(t)#34 (1) {
@sun
sun / gist:3695687
Created September 11, 2012 03:14
bench: Compare Boolean value to FALSE
> php bench.php
Peak memory before test: 422.43 KB
Iterations: 1,000,000
nothing: 0.2577 seconds
function no_op(): 1.4858 seconds
!$value: 0.3877 seconds
$value === FALSE: 0.3837 seconds
FALSE === $value: 0.3868 seconds
$value == FALSE: 0.3889 seconds
@sun
sun / ModuleEnable.php
Created October 9, 2012 00:36
ModuleEnable test
<?php
/**
* @file
* Contains Drupal\system\Tests\Module\ModuleEnable.
*/
namespace Drupal\system\Tests\Module;
use Drupal\simpletest\WebTestBase;
@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
*/
# ██╗ ██╗██████╗ ██████╗ ███╗ ██╗ ██████╗
@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 / 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 / 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