Skip to content

Instantly share code, notes, and snippets.

@Maff-
Maff- / bench.php
Last active December 17, 2019 06:07
PHP Large Array Sum Micro Benchmark
<?php
declare(strict_types=1);
printf("Current PHP version: %s\n", phpversion());
$iterations = (int)($_SERVER['argv'][1] ?? 2000);
printf("Bench iterations: %d\n", $iterations);
$time = microtime(true);
//$input = array_map('intval', str_split(str_repeat(trim(file_get_contents('input.txt')), 100)));
@Maff-
Maff- / ServiceAvailabilityFunctionalTest.php
Created December 5, 2015 22:44
Symfony2 Service Availability Smoke Test
<?php
namespace AppBundle\Tests;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class ServiceAvailabilityFunctionalTest extends KernelTestCase
{
protected $serviceBlacklist = [
'request',
@Maff-
Maff- / DeprecatedTypeOptionsSniff.php
Created October 17, 2015 23:38
SymfonyCleanupStandard_Sniffs_Form_DeprecatedTypeOptionsSniff
<?php
class SymfonyCleanupStandard_Sniffs_Form_DeprecatedTypeOptionsSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff
{
/**
* @inheritdoc
*/
public function __construct()
{
parent::__construct(array(T_CLASS), array(T_FUNCTION), false);
@Maff-
Maff- / AppExtension.php
Created October 14, 2015 18:17
Let a Symfony bundle configure their own Doctrine EnumTypes via the PrependExtensionInterface
<?php
namespace AppBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
class AppExtension extends Extension implements PrependExtensionInterface
{
#target illustrator
function main()
{
var sourceDir,
destDir,
files,
sourceDoc,
sizes;
@Maff-
Maff- / config.yml
Last active August 29, 2015 14:23
PhpStormProtocol
# [...] #
framework:
# Uncomment the 'ide' option to turn all of the file paths in an exception
# page into clickable links that open the given file using your favorite IDE.
# Supported values are 'textmate', 'macvim', 'emacs' and 'sublime' shortcuts
# and any custom configuration string, such as: "phpstorm://open?file=%%f&line=%%l"
# See http://symfony.com/doc/current/reference/configuration/framework.html#ide
ide: "pstorm://open?file=%%f&line=%%l"
@Maff-
Maff- / BoolChoiceType.php
Created June 16, 2015 20:25
Symfony: Boolean as [No, Yes] radio Choice list
<?php
namespace AppBundle\Form\Type;
use AppBundle\Form\DataTransformer\BoolToIntTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class BoolChoiceType extends AbstractType
@Maff-
Maff- / projects.conf
Last active August 29, 2015 14:13
Dynamic Apache projects vhost
<VirtualHost *:80>
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/projects
<Directory /var/www/projects>
# enable the .htaccess rewrites
AllowOverride All
Require all granted
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@Maff-
Maff- / phpstorm7-colorscheme-default.xml
Created February 22, 2014 09:46
Export of Jetbrains PhpStorm 7 (IDEA 13) default colorscheme
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="CopyOfDefault" version="124" parent_scheme="Default">
<option name="LINE_SPACING" value="1.0" />
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monospaced" />
<colors />
<attributes>
<option name="ABSTRACT_CLASS_NAME_ATTRIBUTES">
<value />
</option>