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 / securityConfigSnippet.php
Created February 3, 2016 12:58
Legacy escape route securityConfigSnippet.php
<?php
// ...
$c->loadFromExtension(
'security',
[
'providers' => [
'legacy' => [
'id' => 'app.legacy_user_provider'
]
],
@jenkoian
jenkoian / mapRolesSnippet.php
Last active February 3, 2016 12:57
Legacy escape route mapRolesSnippet.php
<?php
// ...
/**
* Map legacy roles to symfony roles. Legacy roles are in following format:
* ['moderator' => '1']
*/
private function mapRoles()
{
if (empty($this->legacyRoles)) {
@jenkoian
jenkoian / LegacyAuthenticator.php
Last active February 3, 2016 13:56
Legacy escape route LegacyAuthenticator.php
<?php
namespace Acme\Framework\Security;
use Acme\Authentication\AuthenticationSessionInterface;
use Acme\Authentication\User;
use Acme\Authentication\UserManagerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@jenkoian
jenkoian / LegacyUserProvider.php
Last active February 3, 2016 13:57
Legacy escape route LegacyUserProvider.php
<?php
namespace Acme\Framework\Security;
use Acme\Authentication\User;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
@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
{
// ...
@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 / 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 / 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 / day1-part1.php
Last active December 8, 2015 13:55
Advent of Code 2015
<?php
$input = <<<INPUT
()()(()()()(()()((()((()))((()((((()()((((()))()((((())(((((((()(((((((((()(((())(()()(()((()()(()(())(()((((()((()()()((((())((((((()(()(((()())(()((((()))())(())(()(()()))))))))((((((((((((()())()())())(())))(((()()()((((()(((()(()(()()(()(()()(()(((((((())(())(())())))((()())()((((()()((()))(((()()()())))(())))((((())(((()())(())(()))(()((((()())))())((()(())(((()((((()((()(())())))((()))()()(()(()))))((((((((()())((((()()((((()(()())(((((()(()())()))())(((()))()(()(()(()((((()(())(()))(((((()()(()()()(()(((())())(((()()(()()))(((()()(((())())(()(())())()()(())()()()((()(((()(())((()()((())()))((()()))((()()())((((()(()()(()(((()))()(()))))((()(((()()()))(()(((())()(()((()())(()(()()(()())(())()(((()(()())()((((()((()))))())()))((()()()()(())()())()()()((((()))))(()(((()()(((((((())()))()((((()((())()(()())(())()))(()(()())(((((((())))(((()))())))))()))())((())(()()((())()())()))))()((()()())(())((())((((()())())()()()(((()))())))()()))())(()()()(()((((((()()))())()))()(((()(((())(
@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');