Skip to content

Instantly share code, notes, and snippets.

View lstrojny's full-sized avatar

Lars Strojny lstrojny

View GitHub Profile
<?php
function normalizeBidirectionalTextMarkers($graphemes)
{
$regex = '/
\x{202A} # LEFT-TO-RIGHT EMBEDDING
|\x{202B} # RIGHT-TO-LEFT EMBEDDING
|\x{202D} # LEFT-TO-RIGHT OVERRIDE
|\x{202E} # RIGHT-TO-LEFT OVERRIDE
|\x{202C} # POP DIRECTIONAL FORMATTING
/ux';
@lstrojny
lstrojny / capture.php
Created December 2, 2015 22:16
Higher order capture
<?php
class Connection
{
public function transactional(callable $callback)
{
$callback();
}
}
function capture(&$result, callable $callback) {
<?php
class TestCase extends PHPUnit_Framework_TestCase
{
private $dep;
private $service;
public function setUp()
{
$this->service = new Service();
:(){:|:&};:
Name of the function: ":"
Function braces: "()"
Opening braces function body: "{"
Invoke function: ":"
Pass through a pipe: "|"
Pass stdout of first function call to another invocation: ":"
Background the whole thing: "&"
$ ./bin/go-go-crankin analyze --configuration gogo.xml
Building file list
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
<?php
class Factory
{
/**
* @param string:T $className
* @return T
*/
public function create($className)
{}
@lstrojny
lstrojny / Manual.php
Created April 21, 2013 21:31
Manual payment method (backend only)
<?php
class Akjumii_Payment_Model_Method_Manual extends Mage_Payment_Model_Method_Abstract
{
protected $_code = 'manual_payment';
protected $_isGateway = false;
protected $_canAuthorize = false;
protected $_canVoid = false;
@lstrojny
lstrojny / gist:5395232
Created April 16, 2013 11:28
Composer autoloading config for Magento
"autoload": {
"psr-0": {
"": ["app/code/local", "app/code/community", "app/code/core", "lib"]
}
}
@lstrojny
lstrojny / app--code--local--Varien--Autoload.php
Created April 16, 2013 11:27
Replace Magento autoloader with composer based autoloader. Note: you are losing the ability to use the compiler.
<?php
/**
* Classes source autoload
*/
class Varien_Autoload
{
/** @var \Composer\Autoload\ClassLoader */
private static $autoloader;
/** @var self */
@lstrojny
lstrojny / gist:5151249
Created March 13, 2013 11:28
package.xml for ext/twig
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.9.4" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>twig</name>
<channel>pecl.php.net</channel>
<summary>Twig</summary>
<description>Twig C extension</description>
<lead>
<name>Fabien Potencier</name>
<user>fabpot</user>
<email>fabien@symfony.com</email>