Skip to content

Instantly share code, notes, and snippets.

View jenkoian's full-sized avatar
👨‍💻
Works on my machine

Ian Jenkins jenkoian

👨‍💻
Works on my machine
View GitHub Profile
@jenkoian
jenkoian / .bowerrc.json
Created December 6, 2013 23:17
sample .bowerrc
{
directory: "src/Acme/Bundle/DemoBundle/Resources/public/vendor"
}
<?php
use \Symfony\Component\Form\FormInterface;
use \Symfony\Component\HttpFoundation\Request;
class FormSet
{
/**
* @var SplObjectStorage|FormInterface[]
*/
@jenkoian
jenkoian / SearchController.php
Last active August 29, 2015 14:02
Getting faceted results via reflection on 2.x version of elastica bundle.
<?php
/**
* @param Pagerfanta $paginatedResults
* @return array|null
*/
protected function getFacetsFromPaginatedResults(Pagerfanta $paginatedResults, $offset, $limit)
{
$paginatedAdapter = $paginatedResults->getAdapter();
$adapter = new \ReflectionProperty($paginatedAdapter, 'adapter');
@jenkoian
jenkoian / CommandBus.php
Last active August 29, 2015 14:06
Symfony container command bus example
<?php
namespace Acme\CommandBus;
use Acme\CommandInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class CommandBus implements CommandBusInterface
{
/**
@jenkoian
jenkoian / vowel-counter.php
Created February 19, 2015 13:29
Sainsburys VowelCounter Challenge
<?php
class VowelCounter {
function count($string) {
return array_reduce(str_split($string), function($vowelCount, $str) { return $vowelCount += in_array($str, ['a', 'e', 'i', 'o', 'u']);});
}
}
$vc = new VowelCounter();
echo $vc->count('php uk conference');
@jenkoian
jenkoian / day1-part1.php
Last active December 8, 2015 13:55
Advent of Code 2015
<?php
$input = <<<INPUT
()()(()()()(()()((()((()))((()((((()()((((()))()((((())(((((((()(((((((((()(((())(()()(()((()()(()(())(()((((()((()()()((((())((((((()(()(((()())(()((((()))())(())(()(()()))))))))((((((((((((()())()())())(())))(((()()()((((()(((()(()(()()(()(()()(()(((((((())(())(())())))((()())()((((()()((()))(((()()()())))(())))((((())(((()())(())(()))(()((((()())))())((()(())(((()((((()((()(())())))((()))()()(()(()))))((((((((()())((((()()((((()(()())(((((()(()())()))())(((()))()(()(()(()((((()(())(()))(((((()()(()()()(()(((())())(((()()(()()))(((()()(((())())(()(())())()()(())()()()((()(((()(())((()()((())()))((()()))((()()())((((()(()()(()(((()))()(()))))((()(((()()()))(()(((())()(()((()())(()(()()(()())(())()(((()(()())()((((()((()))))())()))((()()()()(())()())()()()((((()))))(()(((()()(((((((())()))()((((()((())()(()())(())()))(()(()())(((((((())))(((()))())))))()))())((())(()()((())()())()))))()((()()())(())((())((((()())())()()()(((()))())))()()))())(()()()(()((((((()()))())()))()(((()(((())(
@jenkoian
jenkoian / index.php
Last active February 3, 2016 13:23
Escape route from legacy index.php
<?php
// Composer autoloader
$loader = require __DIR__ . '/../vendor/autoload.php';
// Legacy config which includes legacy autoloader stuff
require_once __DIR__ . '/../html/config.php';
// Legacy bootstrapping code wrapped in a class implementing HttpKernelInterface to make it stackable
require __DIR__ . '/../html/Bootstrap.php';
@jenkoian
jenkoian / AppKernel.php
Last active February 3, 2016 13:59
Legacy escape route AppKernel.php
<?php
namespace Acme;
use application\App;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle;
@jenkoian
jenkoian / LanguageListener.php
Created February 3, 2016 09:56
Legacy escape route LanguageListener.php
<?php
namespace Acme\Listener;
use Acme\Language\LanguageInterface;
use Acme\Language\LanguageSessionInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
final class LanguageListener
{
@jenkoian
jenkoian / User.php
Last active February 3, 2016 13:58
Legacy escape route User.php
<?php
namespace Acme\Authentication;
use Acme\Avatar\AvatarInterface;
use Symfony\Component\Security\Core\User\UserInterface;
class User implements UserInterface
{
// ...