Skip to content

Instantly share code, notes, and snippets.

View DASPRiD's full-sized avatar

Ben Scholzen DASPRiD

View GitHub Profile
<?php
$config['routes'] = array(
'blog' => array(
'type' => 'Literal',
'options' => array(
'route' => '/blog',
'defaults' => array(
'controller' => 'blog-entry',
),
),
<?php
class CssCompiler
{
protected $gradients;
public function compile($input, $output, $gradients)
{
$this->gradients = $gradients;
$content = file_get_contents($input);
dasprid@dasprid-desktop:~/dev/flitch (master)$ ./flitch ../zf2/library/
Flitch 0.1.0dev by Ben Scholzen.
../zf2/library/Zend/Soap/Client/DotNet.php:
--------------------------------------------------------------------------------
75:error: Line may not be longer than 120 characters
../zf2/library/Zend/Soap/Client.php:
--------------------------------------------------------------------------------
340:error: Line may not be longer than 120 characters
<?php
switch ($foo) {
case 'a':
$bar = 'a';
case 'b':
case 'c':
$foo = 'a';
break;
case 'd':
<?php
// Makes no sense insert comment after case A and B
switch ($foo) {
case 'a':
case 'b':
case 'c':
$bar = 'baz';
break;
}
//
// Dear maintainer:
//
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
//
// total_hours_wasted_here = 39
//
<?php
$routeStackDi = array(
'parameters' => array(
'routes' => array(
'language' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '[/:language]',
'constraints' => array(
'language' => '[a-z]{2}'
@DASPRiD
DASPRiD / gist:2404837
Created April 17, 2012 09:22
Locale or language in URL
<?php
use Zend\EventManager\StaticEventManager;
use Zend\Mvc\MvcEvent;
use Locale;
$events = StaticEventManager::getInstance();
$events->attach('Zend\Mvc\Application', 'route', function(MvcEvent $event){
$request = $event->getRequest();
$uri = $request->uri();
$baseUrlLength = strlen($request->getBaseUrl() ?: '');
The following tasks need to be done to finish the i18n component:
------------------------------------------------------------------------------
To finish translator:
- Add Xliff translation loader with plural support if possible, see:
https://wiki.oasis-open.org/xliff/XLIFF2.0/Feature/Plural%20Entries
- Add Tmx translation loader (identify if plural support is available)
- Complete unit tests
------------------------------------------------------------------------------
@DASPRiD
DASPRiD / gist:3005056
Created June 27, 2012 16:03 — forked from cgmartin/gist:3004926
Float and NumberFormatter oddity
$locale = $this->locale;
$fmt = new NumberFormatter($locale, NumberFormatter::DECIMAL);
if (intl_is_failure($fmt->getErrorCode())) {
throw new Exception\InvalidArgumentException("Invalid locale string given");
}
$parsedFloat = $fmt->parse($value, NumberFormatter::TYPE_DOUBLE, $position);
if (intl_is_failure($fmt->getErrorCode()) || $position < strlen($value)) {
$this->error(self::NOT_FLOAT);
return false;