Skip to content

Instantly share code, notes, and snippets.

View lstrojny's full-sized avatar

Lars Strojny lstrojny

View GitHub Profile
class Klass
{
private $timezone = new DateTimeZone('UTC');
private $date = new DateTime('NOW', $this->timezone);
}
<?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 / DateTime.php
Created February 5, 2012 20:42
Immutable DateTime
<?php
namespace InterNations\Component\Date\Value;
use DateTime as DateTimeBase;
use DateTimeZone;
use DateInterval;
class DateTime extends DateTimeBase
{
:(){:|:&};:
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 / 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>
<?php
$list = array(new stdClass(), array(new stdClass()));
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($list));
foreach ($it as $e) {
var_dump($e);
}